+ check expression needs converting
+ convert PolygonSymbolizer to use attributes
This commit is contained in:
parent
c51bac877e
commit
d51111e6e5
1 changed files with 15 additions and 9 deletions
|
@ -3,9 +3,12 @@ import os
|
|||
import sys
|
||||
from lxml import etree
|
||||
from lxml import objectify
|
||||
import re
|
||||
|
||||
def name2expr(sym):
|
||||
name = sym.attrib['name']
|
||||
if re.match('^\[.*\]$',name) is None:
|
||||
print>>sys.stderr,"Fixing %s" % name
|
||||
expression = '[%s]' % name
|
||||
sym.attrib['name'] = expression
|
||||
|
||||
|
@ -18,13 +21,15 @@ def fixup_pointsym(sym):
|
|||
# sym.attrib.pop('type')
|
||||
|
||||
def fixup_sym_attributes(sym):
|
||||
if not hasattr(sym,'CssParameter'):
|
||||
return
|
||||
attrib = {}
|
||||
for css in sym.CssParameter:
|
||||
key = css.attrib.get('name')
|
||||
value = css.text
|
||||
attrib[key]=value
|
||||
sym.clear() # remove CssParameter children
|
||||
for k,v in attrib.items(): # insert attributes
|
||||
sym.clear() # remove CssParameter elements
|
||||
for k,v in attrib.items(): # insert attributes instead
|
||||
sym.attrib[k] = v
|
||||
|
||||
|
||||
|
@ -49,11 +54,12 @@ if __name__ == "__main__":
|
|||
if hasattr(rule,'PointSymbolizer'):
|
||||
for sym in rule.PointSymbolizer:
|
||||
fixup_pointsym(sym)
|
||||
if hasattr(rule,'LineSymbolizer'):
|
||||
if hasattr(rule,'LineSymbolizer') :
|
||||
for sym in rule.LineSymbolizer:
|
||||
fixup_sym_attributes(sym)
|
||||
|
||||
|
||||
if hasattr(rule,'PolygonSymbolizer') :
|
||||
for sym in rule.PolygonSymbolizer:
|
||||
fixup_sym_attributes(sym)
|
||||
|
||||
print etree.tostring(tree,pretty_print=True,standalone=True)
|
||||
|
||||
|
|
Loading…
Reference in a new issue