+ 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
|
import sys
|
||||||
from lxml import etree
|
from lxml import etree
|
||||||
from lxml import objectify
|
from lxml import objectify
|
||||||
|
import re
|
||||||
|
|
||||||
def name2expr(sym):
|
def name2expr(sym):
|
||||||
name = sym.attrib['name']
|
name = sym.attrib['name']
|
||||||
|
if re.match('^\[.*\]$',name) is None:
|
||||||
|
print>>sys.stderr,"Fixing %s" % name
|
||||||
expression = '[%s]' % name
|
expression = '[%s]' % name
|
||||||
sym.attrib['name'] = expression
|
sym.attrib['name'] = expression
|
||||||
|
|
||||||
|
@ -18,13 +21,15 @@ def fixup_pointsym(sym):
|
||||||
# sym.attrib.pop('type')
|
# sym.attrib.pop('type')
|
||||||
|
|
||||||
def fixup_sym_attributes(sym):
|
def fixup_sym_attributes(sym):
|
||||||
|
if not hasattr(sym,'CssParameter'):
|
||||||
|
return
|
||||||
attrib = {}
|
attrib = {}
|
||||||
for css in sym.CssParameter:
|
for css in sym.CssParameter:
|
||||||
key = css.attrib.get('name')
|
key = css.attrib.get('name')
|
||||||
value = css.text
|
value = css.text
|
||||||
attrib[key]=value
|
attrib[key]=value
|
||||||
sym.clear() # remove CssParameter children
|
sym.clear() # remove CssParameter elements
|
||||||
for k,v in attrib.items(): # insert attributes
|
for k,v in attrib.items(): # insert attributes instead
|
||||||
sym.attrib[k] = v
|
sym.attrib[k] = v
|
||||||
|
|
||||||
|
|
||||||
|
@ -52,8 +57,9 @@ if __name__ == "__main__":
|
||||||
if hasattr(rule,'LineSymbolizer') :
|
if hasattr(rule,'LineSymbolizer') :
|
||||||
for sym in rule.LineSymbolizer:
|
for sym in rule.LineSymbolizer:
|
||||||
fixup_sym_attributes(sym)
|
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)
|
print etree.tostring(tree,pretty_print=True,standalone=True)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue