OWSLib
OWSLib copied to clipboard
Implement remaining spatial filters in owslib.fes
Only BBOX is currently implemented
+1 for this to be implemented.
I'm currently working around with some simple envelope only code based on the owslib.fes.BBox code:
## owslib.fes only supports BBox spatial filter, so add a few more
## Modified by Luke Pinner (2014) from original owslib.fes.BBox code
class SpatialOp(OgcExpression):
"""Construct a BBox, two pairs of coordinates (west-south and east-north)"""
def __init__(self, operator, bbox, crs=None):
self.operator = operator
self.bbox = bbox
self.crs = crs
def toXML(self):
tmp = etree.Element(util.nspath_eval(self.operator, namespaces))
etree.SubElement(tmp, util.nspath_eval('ogc:PropertyName', namespaces)).text = 'ows:BoundingBox'
tmp2 = etree.SubElement(tmp, util.nspath_eval('gml:Envelope', namespaces))
if self.crs is not None:
tmp2.set('srsName', self.crs)
etree.SubElement(tmp2, util.nspath_eval('gml:lowerCorner', namespaces)).text = '%s %s' % (self.bbox[0], self.bbox[1])
etree.SubElement(tmp2, util.nspath_eval('gml:upperCorner', namespaces)).text = '%s %s' % (self.bbox[2], self.bbox[3])
return tmp
class Contains(SpatialOp):
def __init__(self, bbox, crs=None):
SpatialOp.__init__(self,'ogc:Contains',bbox,crs)
class Disjoint(SpatialOp):
def __init__(self, bbox, crs=None):
SpatialOp.__init__(self,'ogc:Disjoint',bbox,crs)
class Within(SpatialOp):
def __init__(self, bbox, crs=None):
SpatialOp.__init__(self,'ogc:Within',bbox,crs)
Is this issue still a work in progress ?
Fixed for WFS2.0 and POST requests in #780