Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Refactored out _nsmap from all constructors -- it's always the same.

  • Loading branch information...
commit 81f356096a8b2301841bb97309966c8a2b8c9f1a 1 parent aa840df
David Zwarg authored
Showing with 161 additions and 126 deletions.
  1. +147 −112 sld/models.py
  2. +14 −14 sld/tests.py
View
259 sld/models.py
@@ -20,37 +20,72 @@
from StringIO import StringIO
class SLDNode(object):
- def __init__(self, parent, nsmap):
+ """
+ A base class for all python objects that relate directly to SLD elements.
+ An SLDNode contains references to the underlying parent node, underlying
+ element node, and the namespace map.
+
+ The SLDNode base class also contains utility methods to construct properties
+ for child SLDNode objects.
+ """
+
+ # The defined namespaces in SLD documents.
+ _nsmap = {
+ 'sld':"http://www.opengis.net/sld",
+ 'ogc':"http://www.opengis.net/ogc",
+ 'xlink':"http://www.w3.org/1999/xlink",
+ 'xsi':"http://www.w3.org/2001/XMLSchema-instance"
+ }
+
+ def __init__(self, parent):
+ """
+ Create a new SLDNode. It is not necessary to call this directly, because
+ all child classes should initialize the SLDNode internally.
+
+ @type parent: etree.Element
+ @param parent: The parent element of this node.
+ @type nsmap: dict
+ @param nsmap: The dictionary of namespaces.
+ """
self._parent = parent
- self._nsmap = nsmap
self._node = None
@staticmethod
- def makeproperty(ns, node, cls=None, name=None):
+ def makeproperty(ns, node, cls=None, name=None, docstring=None):
+ """
+ Make a property on an instance of an SLDNode, which relates to a specific
+ child node in the SLD specification.
+ """
def get_property(self):
+ """
+ A generic property getter.
+ """
if cls is None:
xpath = '%s:%s' % (ns, name)
else:
xpath = '%s:%s' % (ns, cls.__name__)
- xpath = self._node.xpath(xpath, namespaces=self._nsmap)
+ xpath = self._node.xpath(xpath, namespaces=SLDNode._nsmap)
if len(xpath) == 1:
if cls is None:
return xpath[0].text
else:
elem = cls.__new__(cls)
- cls.__init__(elem, self._node, self._nsmap)
+ cls.__init__(elem, self._node)
return elem
else:
return None
def set_property(self, value):
+ """
+ A generic property setter.
+ """
if cls is None:
xpath = '%s:%s' % (ns, name)
else:
xpath = '%s:%s' % (ns, cls.__name__)
- xpath = self._node.xpath(xpath, namespaces=self._nsmap)
+ xpath = self._node.xpath(xpath, namespaces=SLDNode._nsmap)
if len(xpath) == 1:
if cls is None:
xpath[0].text = value
@@ -58,43 +93,53 @@ def set_property(self, value):
xpath[0] = value._node
else:
if cls is None:
- elem = self._node.makeelement('{%s}%s' % (self._nsmap[ns], name), nsmap=self._nsmap)
+ elem = self._node.makeelement('{%s}%s' % (SLDNode._nsmap[ns], name), nsmap=SLDNode._nsmap)
elem.text = value
self._node.append(elem)
else:
self._node.append(value._node)
def del_property(self):
+ """
+ A generic property deleter.
+ """
if cls is None:
xpath = '%s:%s' % (ns, name)
else:
xpath = '%s:%s' % (ns, cls.__name__)
- xpath = self._node.xpath(xpath, namespaces=self._nsmap)
+ xpath = self._node.xpath(xpath, namespaces=SLDNode._nsmap)
if len(xpath) == 1:
self._node.remove(xpath[0])
-
- return property(get_property, set_property, del_property, "")
+ return property(get_property, set_property, del_property, docstring)
def get_or_create_element(self, ns, name):
- if len(self._node.xpath('%s:%s' % (ns, name), namespaces=self._nsmap)) == 1:
+ """
+ Attempt to get the only child element from this SLDNode. If the node
+ does not exist, create the element, attach it to the DOM, and return
+ the class object that wraps the node.
+ """
+ if len(self._node.xpath('%s:%s' % (ns, name), namespaces=SLDNode._nsmap)) == 1:
return getattr(self, name)
return self.create_element(ns, name)
def create_element(self, ns, name):
- elem = self._node.makeelement('{%s}%s' % (self._nsmap[ns], name), nsmap=self._nsmap)
+ """
+ Create
+ """
+ elem = self._node.makeelement('{%s}%s' % (SLDNode._nsmap[ns], name), nsmap=SLDNode._nsmap)
self._node.append(elem)
return getattr(self, name)
class CssParameter(SLDNode):
- def __init__(self, parent, nsmap, index):
- super(CssParameter, self).__init__(parent, nsmap)
- self._node = self._parent.xpath('sld:CssParameter', namespaces=self._nsmap)[index]
+ def __init__(self, parent, index):
+ super(CssParameter, self).__init__(parent)
+ self._node = self._parent.xpath('sld:CssParameter', namespaces=SLDNode._nsmap)[index]
def get_name(self):
return self._node.attrib['name']
@@ -120,16 +165,16 @@ def del_value(self):
class CssParameters(SLDNode):
- def __init__(self, parent, nsmap):
- super(CssParameters, self).__init__(parent, nsmap)
+ def __init__(self, parent):
+ super(CssParameters, self).__init__(parent)
self._node = None
- self._nodes = self._parent.xpath('sld:CssParameter', namespaces=self._nsmap)
+ self._nodes = self._parent.xpath('sld:CssParameter', namespaces=SLDNode._nsmap)
def __len__(self):
return len(self._nodes)
def __getitem__(self, key):
- return CssParameter(self._parent, self._nsmap, key)
+ return CssParameter(self._parent, key)
def __setitem__(self, key, value):
if isinstance(value, CssParameter):
@@ -142,55 +187,55 @@ def __delitem__(self, key):
class StyleItem(SLDNode):
- def __init__(self, parent, nsmap, name):
- super(StyleItem, self).__init__(parent, nsmap)
- xpath = self._parent.xpath('sld:'+name, namespaces=self._nsmap)
+ def __init__(self, parent, name):
+ super(StyleItem, self).__init__(parent)
+ xpath = self._parent.xpath('sld:'+name, namespaces=SLDNode._nsmap)
if len(xpath) < 1:
- self._node = self._parent.makeelement('{%s}%s' % (self._nsmap['sld'], name), nsmap=self._nsmap)
+ self._node = self._parent.makeelement('{%s}%s' % (SLDNode._nsmap['sld'], name), nsmap=SLDNode._nsmap)
self._parent.append(self._node)
else:
self._node = xpath[0]
@property
def CssParameters(self):
- return CssParameters(self._node, self._nsmap)
+ return CssParameters(self._node)
def create_cssparameter(self, name=None, value=None):
- elem = self._node.makeelement('{%s}CssParameter' % self._nsmap['sld'], nsmap=self._nsmap)
+ elem = self._node.makeelement('{%s}CssParameter' % SLDNode._nsmap['sld'], nsmap=SLDNode._nsmap)
self._node.append(elem)
if not (name is None or value is None):
elem.attrib['name'] = name
elem.text = value
- return CssParameter(self._node, self._nsmap, len(self._node)-1)
+ return CssParameter(self._node, len(self._node)-1)
class Fill(StyleItem):
- def __init__(self, parent, nsmap):
- super(Fill, self).__init__(parent, nsmap, 'Fill')
+ def __init__(self, parent):
+ super(Fill, self).__init__(parent, 'Fill')
class Font(StyleItem):
- def __init__(self, parent, nsmap):
- super(Font, self).__init__(parent, nsmap, 'Font')
+ def __init__(self, parent):
+ super(Font, self).__init__(parent, 'Font')
class Stroke(StyleItem):
- def __init__(self, parent, nsmap):
- super(Stroke, self).__init__(parent, nsmap, 'Stroke')
+ def __init__(self, parent):
+ super(Stroke, self).__init__(parent, 'Stroke')
class Symbolizer(SLDNode):
- def __init__(self, parent, nsmap, name):
- super(Symbolizer, self).__init__(parent, nsmap)
+ def __init__(self, parent, name):
+ super(Symbolizer, self).__init__(parent)
if name[len(name)-1] == '*':
name = name[0:-1] + 'Symbolizer'
- xpath = self._parent.xpath('sld:%s' % name, namespaces=self._nsmap)
+ xpath = self._parent.xpath('sld:%s' % name, namespaces=SLDNode._nsmap)
if len(xpath) < 1:
- self._node = self._parent.makeelement('{%s}%s' % (self._nsmap['sld'], name), nsmap=self._nsmap)
+ self._node = self._parent.makeelement('{%s}%s' % (SLDNode._nsmap['sld'], name), nsmap=SLDNode._nsmap)
self._parent.append(self._node)
else:
self._node = xpath[0]
@@ -210,33 +255,33 @@ def create_stroke(self):
class PolygonSymbolizer(Symbolizer):
- def __init__(self, parent, nsmap):
- super(PolygonSymbolizer, self).__init__(parent, nsmap, 'Polygon*')
+ def __init__(self, parent):
+ super(PolygonSymbolizer, self).__init__(parent, 'Polygon*')
class LineSymbolizer(Symbolizer):
- def __init__(self, parent, nsmap):
- super(LineSymbolizer, self).__init__(parent, nsmap, 'Line*')
+ def __init__(self, parent):
+ super(LineSymbolizer, self).__init__(parent, 'Line*')
class TextSymbolizer(Symbolizer):
- def __init__(self, parent, nsmap):
- super(TextSymbolizer, self).__init__(parent, nsmap, 'Text*')
+ def __init__(self, parent):
+ super(TextSymbolizer, self).__init__(parent, 'Text*')
class Mark(Symbolizer):
- def __init__(self, parent, nsmap):
- super(Mark, self).__init__(parent, nsmap, 'Mark')
+ def __init__(self, parent):
+ super(Mark, self).__init__(parent, 'Mark')
setattr(self.__class__, 'WellKnownName', SLDNode.makeproperty('sld', self._node, name='WellKnownName'))
class Graphic(SLDNode):
- def __init__(self, parent, nsmap):
- super(Graphic, self).__init__(parent, nsmap)
- xpath = self._parent.xpath('sld:Graphic', namespaces=self._nsmap)
+ def __init__(self, parent):
+ super(Graphic, self).__init__(parent)
+ xpath = self._parent.xpath('sld:Graphic', namespaces=SLDNode._nsmap)
if len(xpath) < 1:
- self._node = self._parent.makeelement('{%s}Graphic' % self._nsmap['sld'], nsmap=self._nsmap)
+ self._node = self._parent.makeelement('{%s}Graphic' % SLDNode._nsmap['sld'], nsmap=SLDNode._nsmap)
self._parent.append(self._node)
else:
self._node = xpath[0]
@@ -248,11 +293,11 @@ def __init__(self, parent, nsmap):
class PointSymbolizer(SLDNode):
- def __init__(self, parent, nsmap):
- super(PointSymbolizer, self).__init__(parent, nsmap)
- xpath = self._parent.xpath('sld:PointSymbolizer', namespaces=self._nsmap)
+ def __init__(self, parent):
+ super(PointSymbolizer, self).__init__(parent)
+ xpath = self._parent.xpath('sld:PointSymbolizer', namespaces=SLDNode._nsmap)
if len(xpath) < 1:
- self._node = self._parent.makeelement('{%s}PointSymbolizer' % self._nsmap['sld'], nsmap=self._nsmap)
+ self._node = self._parent.makeelement('{%s}PointSymbolizer' % SLDNode._nsmap['sld'], nsmap=SLDNode._nsmap)
self._parent.append(self._node)
else:
self._node = xpath[0]
@@ -261,11 +306,11 @@ def __init__(self, parent, nsmap):
class PropertyCriterion(SLDNode):
- def __init__(self, parent, nsmap, name):
- super(PropertyCriterion, self).__init__(parent, nsmap)
- xpath = self._parent.xpath('ogc:'+name, namespaces=self._nsmap)
+ def __init__(self, parent, name):
+ super(PropertyCriterion, self).__init__(parent)
+ xpath = self._parent.xpath('ogc:'+name, namespaces=SLDNode._nsmap)
if len(xpath) < 1:
- self._node = self._parent.makeelement('{%s}%s' % (self._nsmap['ogc'], name), nsmap=self._nsmap)
+ self._node = self._parent.makeelement('{%s}%s' % (SLDNode._nsmap['ogc'], name), nsmap=SLDNode._nsmap)
self._parent.append(self._node)
else:
self._node = xpath[0]
@@ -275,22 +320,22 @@ def __init__(self, parent, nsmap, name):
class Filter(SLDNode):
- def __init__(self, parent, nsmap):
- super(Filter, self).__init__(parent, nsmap)
- xpath = self._parent.xpath('ogc:Filter', namespaces=self._nsmap)
+ def __init__(self, parent):
+ super(Filter, self).__init__(parent)
+ xpath = self._parent.xpath('ogc:Filter', namespaces=SLDNode._nsmap)
if len(xpath) == 1:
self._node = xpath[0]
else:
- self._node = self._parent.makeelement('{%s}Filter' % self._nsmap['ogc'], nsmap=self._nsmap)
+ self._node = self._parent.makeelement('{%s}Filter' % SLDNode._nsmap['ogc'], nsmap=SLDNode._nsmap)
def __add__(self, other):
if not self._node.getparent() is None:
self._node.getparent().remove(self._node)
- elem = self._node.makeelement('{%s}And' % self._nsmap['ogc'])
+ elem = self._node.makeelement('{%s}And' % SLDNode._nsmap['ogc'])
elem.append(copy.copy(self._node[0]))
elem.append(copy.copy(other._node[0]))
- f = Filter(self._parent, self._nsmap)
+ f = Filter(self._parent)
f._node.append(elem)
return f
@@ -300,7 +345,7 @@ def __or__(x, y):
elem.append(copy.copy(x._node[0]))
elem.append(copy.copy(y._node[0]))
- f = Filter(x._parent, x._nsmap)
+ f = Filter(x._parent)
f._node.append(elem)
return f
@@ -308,34 +353,34 @@ def __or__(x, y):
def __getattr__(self, name):
if not name.startswith('PropertyIs'):
raise AttributeError('Property name must be one of: PropertyIsEqualTo, PropertyIsNotEqualTo, PropertyIsLessThan, PropertyIsLessThanOrEqualTo, PropertyIsGreaterThan, PropertyIsGreaterThanOrEqualTo, PropertyIsLike.')
- xpath = self._node.xpath('ogc:'+name, namespaces=self._nsmap)
+ xpath = self._node.xpath('ogc:'+name, namespaces=SLDNode._nsmap)
if len(xpath) == 0:
return None
- return PropertyCriterion(self._node, self._nsmap, name)
+ return PropertyCriterion(self._node, name)
def __setattr__(self, name, value):
if not name.startswith('PropertyIs'):
object.__setattr__(self, name, value)
return
- xpath = self._node.xpath('ogc:'+name, namespaces=self._nsmap)
+ xpath = self._node.xpath('ogc:'+name, namespaces=SLDNode._nsmap)
if len(xpath) > 0:
xpath[0] = value
else:
- elem = self._node.makeelement('{%s}%s' % (self._nsmap['ogc'], name), nsmap=self._nsmap)
+ elem = self._node.makeelement('{%s}%s' % (SLDNode._nsmap['ogc'], name), nsmap=SLDNode._nsmap)
self._node.append(elem)
def __delattr__(self, name):
- xpath = self._node.xpath('ogc:'+name, namespaces=self._nsmap)
+ xpath = self._node.xpath('ogc:'+name, namespaces=SLDNode._nsmap)
if len(xpath) > 0:
self._node.remove(xpath[0])
class Rule(SLDNode):
- def __init__(self, parent, nsmap, index, title=None):
- super(Rule, self).__init__(parent, nsmap)
- self._node = self._parent.xpath('sld:Rule', namespaces=self._nsmap)[index]
+ def __init__(self, parent, index, title=None):
+ super(Rule, self).__init__(parent)
+ self._node = self._parent.xpath('sld:Rule', namespaces=SLDNode._nsmap)[index]
setattr(self.__class__, 'Title', SLDNode.makeproperty('sld', self._node, name='Title'))
setattr(self.__class__, 'Filter', SLDNode.makeproperty('ogc', self._node, cls=Filter))
@@ -348,7 +393,7 @@ def normalize(self):
order = ['sld:Title','ogc:Filter','sld:PolygonSymbolizer',
'sld:LineSymbolizer', 'sld:TextSymbolizer', 'sld:PointSymbolizer']
for item in order:
- xpath = self._node.xpath(item, namespaces=self._nsmap)
+ xpath = self._node.xpath(item, namespaces=SLDNode._nsmap)
for xitem in xpath:
# move this to the end
self._node.remove(xitem)
@@ -378,7 +423,7 @@ def create_filter(self, propname=None, comparitor=None, value=None):
ftype = 'PropertyIsLike'
if not ftype is None:
- prop = PropertyCriterion(rfilter._node, self._nsmap, ftype)
+ prop = PropertyCriterion(rfilter._node, ftype)
prop.PropertyName = propname
if not value is None:
prop.Literal = value
@@ -394,21 +439,21 @@ def create_symbolizer(self, stype):
class Rules(SLDNode):
- def __init__(self, parent, nsmap):
- super(Rules, self).__init__(parent, nsmap)
+ def __init__(self, parent):
+ super(Rules, self).__init__(parent)
self._node = None
- self._nodes = self._parent.xpath('sld:Rule', namespaces=self._nsmap)
+ self._nodes = self._parent.xpath('sld:Rule', namespaces=SLDNode._nsmap)
def normalize(self):
for i,rnode in enumerate(self._nodes):
- rule = Rule(self._parent, self._nsmap, i-1)
+ rule = Rule(self._parent, i-1)
rule.normalize()
def __len__(self):
return len(self._nodes)
def __getitem__(self, key):
- rule = Rule(self._parent, self._nsmap, key)
+ rule = Rule(self._parent, key)
return rule
def __setitem__(self, key, value):
@@ -422,9 +467,9 @@ def __delitem__(self, key):
class FeatureTypeStyle(SLDNode):
- def __init__(self, parent, nsmap):
- super(FeatureTypeStyle, self).__init__(parent, nsmap)
- self._node = self._parent.xpath('sld:FeatureTypeStyle', namespaces=self._nsmap)[0]
+ def __init__(self, parent):
+ super(FeatureTypeStyle, self).__init__(parent)
+ self._node = self._parent.xpath('sld:FeatureTypeStyle', namespaces=SLDNode._nsmap)[0]
def normalize(self):
if not self.Rules is None:
@@ -432,34 +477,34 @@ def normalize(self):
@property
def Rules(self):
- return Rules(self._node, self._nsmap)
+ return Rules(self._node)
def create_rule(self, title, symbolizer=None):
- elem = self._node.makeelement('{%s}Rule' % self._nsmap['sld'], nsmap=self._nsmap)
+ elem = self._node.makeelement('{%s}Rule' % SLDNode._nsmap['sld'], nsmap=SLDNode._nsmap)
self._node.append(elem)
- rule = Rule(self._node, self._nsmap, len(self._node)-1)
+ rule = Rule(self._node, len(self._node)-1)
rule.Title = title
if symbolizer is None:
symbolizer = PointSymbolizer
- sym = symbolizer(rule._node, self._nsmap)
+ sym = symbolizer(rule._node)
if symbolizer == PointSymbolizer:
- gph = Graphic(sym._node, self._nsmap)
- mrk = Mark(gph._node, self._nsmap)
+ gph = Graphic(sym._node)
+ mrk = Mark(gph._node)
mrk.WellKnownName = 'square'
- fill = Fill(mrk._node, self._nsmap)
+ fill = Fill(mrk._node)
fill.create_cssparameter('fill', '#ff0000')
elif symbolizer == LineSymbolizer:
- stroke = Stroke(sym._node, self._nsmap)
+ stroke = Stroke(sym._node)
stroke.create_cssparameter('stroke', '#0000ff')
elif symbolizer == PolygonSymbolizer:
- fill = Fill(sym._node, self._nsmap)
+ fill = Fill(sym._node)
fill.create_cssparameter('fill', '#AAAAAA')
- stroke = Stroke(sym._node, self._nsmap)
+ stroke = Stroke(sym._node)
stroke.create_cssparameter('stroke', '#000000')
stroke.create_cssparameter('stroke-width', '1')
@@ -467,9 +512,9 @@ def create_rule(self, title, symbolizer=None):
class UserStyle(SLDNode):
- def __init__(self, parent, nsmap):
- super(UserStyle, self).__init__(parent, nsmap)
- self._node = self._parent.xpath('sld:UserStyle', namespaces=self._nsmap)[0]
+ def __init__(self, parent):
+ super(UserStyle, self).__init__(parent)
+ self._node = self._parent.xpath('sld:UserStyle', namespaces=SLDNode._nsmap)[0]
setattr(self.__class__, 'Title', SLDNode.makeproperty('sld', self._node, name='Title'))
setattr(self.__class__, 'Abstract', SLDNode.makeproperty('sld', self._node, name='Abstract'))
@@ -484,9 +529,9 @@ def create_featuretypestyle(self):
class NamedLayer(SLDNode):
- def __init__(self, parent, nsmap):
- super(NamedLayer, self).__init__(parent, nsmap)
- self._node = self._parent.xpath('sld:NamedLayer', namespaces=self._nsmap)[0]
+ def __init__(self, parent):
+ super(NamedLayer, self).__init__(parent)
+ self._node = self._parent.xpath('sld:NamedLayer', namespaces=SLDNode._nsmap)[0]
setattr(self.__class__, 'UserStyle', SLDNode.makeproperty('sld', self._node, cls=UserStyle))
setattr(self.__class__, 'Name', SLDNode.makeproperty('sld', self._node, name='Name'))
@@ -501,8 +546,9 @@ def create_userstyle(self):
class StyledLayerDescriptor(SLDNode):
_cached_schema = None
+
def __init__(self, sld_file=None):
- super(StyledLayerDescriptor, self).__init__(None,None)
+ super(StyledLayerDescriptor, self).__init__(None)
if StyledLayerDescriptor._cached_schema is None:
#logging.debug('Storing new schema into cache.')
@@ -527,21 +573,11 @@ def __init__(self, sld_file=None):
if not sld_file is None:
self._node = parse(sld_file)
- self._nsmap = self._node.getroot().nsmap
-
- ns = self._nsmap.pop(None)
- self._nsmap['sld'] = ns
if not self._schema.validate(self._node):
logging.warn('SLD File "%s" does not validate against the SLD schema.', sld_file)
else:
- self._nsmap = {
- 'sld':"http://www.opengis.net/sld",
- 'ogc':"http://www.opengis.net/ogc",
- 'xlink':"http://www.w3.org/1999/xlink",
- 'xsi':"http://www.w3.org/2001/XMLSchema-instance"
- }
- self._node = Element("{%s}StyledLayerDescriptor" % self._nsmap['sld'], version="1.0.0", nsmap=self._nsmap)
+ self._node = Element("{%s}StyledLayerDescriptor" % SLDNode._nsmap['sld'], version="1.0.0", nsmap=SLDNode._nsmap)
setattr(self.__class__, 'NamedLayer', SLDNode.makeproperty('sld', self._node, cls=NamedLayer))
@@ -554,7 +590,6 @@ def __del__(self):
def __deepcopy__(self, memo):
sld = StyledLayerDescriptor()
sld._node = copy.deepcopy(self._node)
- sld._nsmap = copy.deepcopy(self._nsmap)
return sld
@@ -582,11 +617,11 @@ def version(self):
return self._node.getroot().get('version')
@property
- def xmlns(self):
+ def xmlns(self, ns=None):
"""
Get the XML Namespace.
"""
- return self._node.getroot().nsmap[None]
+ return self._node.getroot().nsmap[ns]
def create_namedlayer(self, name):
namedlayer = self.get_or_create_element('sld', 'NamedLayer')
View
28 sld/tests.py
@@ -527,13 +527,13 @@ def test_filter_and(self):
featuretypestyle = userstyle.create_featuretypestyle()
rule = featuretypestyle.create_rule('test rule', PointSymbolizer)
- filter1 = Filter(rule._node, rule._nsmap)
- filter1.PropertyIsGreaterThan = PropertyCriterion(filter1._node, filter1._nsmap, 'PropertyIsGreaterThan')
+ filter1 = Filter(rule._node)
+ filter1.PropertyIsGreaterThan = PropertyCriterion(filter1._node, 'PropertyIsGreaterThan')
filter1.PropertyIsGreaterThan.PropertyName = 'number'
filter1.PropertyIsGreaterThan.Literal = '-10'
- filter2 = Filter(rule._node, rule._nsmap)
- filter2.PropertyIsLessThanOrEqualTo = PropertyCriterion(filter2._node, filter2._nsmap, 'PropertyIsLessThanOrEqualTo')
+ filter2 = Filter(rule._node)
+ filter2.PropertyIsLessThanOrEqualTo = PropertyCriterion(filter2._node, 'PropertyIsLessThanOrEqualTo')
filter2.PropertyIsLessThanOrEqualTo.PropertyName = 'number'
filter2.PropertyIsLessThanOrEqualTo.Literal = '10'
@@ -556,13 +556,13 @@ def test_filter_or(self):
featuretypestyle = userstyle.create_featuretypestyle()
rule = featuretypestyle.create_rule('test rule', PointSymbolizer)
- filter1 = Filter(rule._node, rule._nsmap)
- filter1.PropertyIsGreaterThan = PropertyCriterion(filter1._node, filter1._nsmap, 'PropertyIsGreaterThan')
+ filter1 = Filter(rule._node)
+ filter1.PropertyIsGreaterThan = PropertyCriterion(filter1._node, 'PropertyIsGreaterThan')
filter1.PropertyIsGreaterThan.PropertyName = 'number'
filter1.PropertyIsGreaterThan.Literal = '10'
- filter2 = Filter(rule._node, rule._nsmap)
- filter2.PropertyIsLessThan= PropertyCriterion(filter2._node, filter2._nsmap, 'PropertyIsLessThan')
+ filter2 = Filter(rule._node)
+ filter2.PropertyIsLessThan= PropertyCriterion(filter2._node, 'PropertyIsLessThan')
filter2.PropertyIsLessThan.PropertyName = 'number'
filter2.PropertyIsLessThan.Literal = '-10'
@@ -585,18 +585,18 @@ def test_filter_and_or(self):
featuretypestyle = userstyle.create_featuretypestyle()
rule = featuretypestyle.create_rule('test rule', PointSymbolizer)
- filter1 = Filter(rule._node, rule._nsmap)
- filter1.PropertyIsGreaterThan = PropertyCriterion(filter1._node, filter1._nsmap, 'PropertyIsGreaterThan')
+ filter1 = Filter(rule._node)
+ filter1.PropertyIsGreaterThan = PropertyCriterion(filter1._node, 'PropertyIsGreaterThan')
filter1.PropertyIsGreaterThan.PropertyName = 'number'
filter1.PropertyIsGreaterThan.Literal = '10'
- filter2 = Filter(rule._node, rule._nsmap)
- filter2.PropertyIsLessThan = PropertyCriterion(filter2._node, filter2._nsmap, 'PropertyIsLessThan')
+ filter2 = Filter(rule._node)
+ filter2.PropertyIsLessThan = PropertyCriterion(filter2._node, 'PropertyIsLessThan')
filter2.PropertyIsLessThan.PropertyName = 'number'
filter2.PropertyIsLessThan.Literal = '-10'
- filter3 = Filter(rule._node, rule._nsmap)
- filter3.PropertyIsEqualTo = PropertyCriterion(filter3._node, filter3._nsmap, 'PropertyIsEqualTo')
+ filter3 = Filter(rule._node)
+ filter3.PropertyIsEqualTo = PropertyCriterion(filter3._node, 'PropertyIsEqualTo')
filter3.PropertyIsEqualTo.PropertyName = 'value'
filter3.PropertyIsEqualTo.Literal = 'yes'
Please sign in to comment.
Something went wrong with that request. Please try again.