source: subversion/applications/rendering/parking/osray/osray_mapcss.py @ 22376

Last change on this file since 22376 was 22327, checked in by kdrangmeister, 9 years ago

mapcss

  • Property svn:mime-type set to text/plain
File size: 1.0 KB
Line 
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3import xml.etree.ElementTree as ET
4from ceyx.MapCSS import MapCSS
5
6# see http://wiki.openstreetmap.org/wiki/Ceyx#I_want_to_build_my_own_render_based_on_your_MapCSS_parser._How.3F
7
8class OSMstyle:
9    def __init__(self, cssfile):
10        # load and parse the CSS
11        self.mapcss    =  MapCSS(cssfile)
12
13    def get_style_for_ele(self, ele, zoom):
14        rules = self.mapcss.apply_to_ele(ele, zoom)
15        return rules
16
17if __name__ == '__main__':
18    osm2svg = OSMstyle("style.mapcss")
19    #create a fake element to ask the style for
20    ele = ET.Element("way")
21    tag = ET.SubElement(ele, "tag")
22    tag.set("k", "highway")
23    tag.set("v", "motorway")
24
25    print str(osm2svg.get_style_for_ele(ele,13))
26
27# example answer:
28# {'width': '4.5', 'color': '#809BC0', 'linecap': 'round', 'linecaps': 'round, linejoin: round', 'z-index': '0.1', 'font-color': 'black', 'casing-width': '5', 'font-family': 'DejaVu', 'text-halo-color': 'white', 'casing-color': '#202020'}
Note: See TracBrowser for help on using the repository browser.