Skip to content

Commit

Permalink
test invalid gml:posList geometry (#621)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomkralidis committed Aug 25, 2020
1 parent b5a657e commit b9e649a
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 5 deletions.
2 changes: 2 additions & 0 deletions pycsw/ogc/fes/fes1.py
Expand Up @@ -293,6 +293,8 @@ def _get_comparison_expression(elem):
where = boq.join(queries) if (boq is not None and boq != ' not ') \
else queries[0]

print("WHERE", where)
print("VALUES", values)
return where, values


Expand Down
22 changes: 17 additions & 5 deletions pycsw/ogc/gml/gml3.py
Expand Up @@ -41,14 +41,24 @@
DEFAULT_SRS = crs.Crs('urn:x-ogc:def:crs:EPSG:6.11:4326')


def _poslist2wkt(poslist, axisorder):
def _poslist2wkt(poslist, axisorder, geomtype):
"""Repurpose gml:posList into WKT aware list"""

tmp = poslist.split()
poslist2 = []

xlist = tmp[1::2]
ylist = tmp[::2]
if geomtype == 'polygon':
len_ = 8
elif geomtype == 'line':
len_ = 4

if len(tmp) < len_:
msg = 'Invalid number of coordinates in geometry'
LOGGER.error(msg)
raise RuntimeError(msg)

xlist = tmp[::2]
ylist = tmp[1::2]

if axisorder == 'yx':
for i, j in zip(ylist, xlist):
Expand Down Expand Up @@ -134,7 +144,8 @@ def _get_linestring(self):
Missing gml:posList')
else:
self.wkt = 'LINESTRING(%s)' % _poslist2wkt(tmp.text,
self.crs.axisorder)
self.crs.axisorder,
'line')

def _get_polygon(self):
"""Parse gml:Polygon"""
Expand All @@ -147,7 +158,8 @@ def _get_polygon(self):
Missing gml:posList')
else:
self.wkt = 'POLYGON((%s))' % _poslist2wkt(tmp.text,
self.crs.axisorder)
self.crs.axisorder,
'polygon')

def _get_envelope(self):
"""Parse gml:Envelope"""
Expand Down
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- PYCSW_VERSION -->
<csw:GetRecordsResponse xmlns:csw="http://www.opengis.net/cat/csw/2.0.2" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dct="http://purl.org/dc/terms/" xmlns:gmd="http://www.isotc211.org/2005/gmd" xmlns:gml="http://www.opengis.net/gml" xmlns:ows="http://www.opengis.net/ows" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0.2" xsi:schemaLocation="http://www.opengis.net/cat/csw/2.0.2 http://schemas.opengis.net/csw/2.0.2/CSW-discovery.xsd">
<csw:SearchStatus timestamp="PYCSW_TIMESTAMP"/>
<csw:SearchResults numberOfRecordsMatched="2" numberOfRecordsReturned="2" nextRecord="0" recordSchema="http://www.opengis.net/cat/csw/2.0.2" elementSet="brief">
<csw:BriefRecord>
<dc:identifier>urn:uuid:94bc9c83-97f6-4b40-9eb8-a8e8787a5c63</dc:identifier>
<dc:title>Mauris sed neque</dc:title>
<dc:type>http://purl.org/dc/dcmitype/Dataset</dc:type>
<ows:BoundingBox crs="urn:x-ogc:def:crs:EPSG:6.11:4326" dimensions="2">
<ows:LowerCorner>47.59 -4.1</ows:LowerCorner>
<ows:UpperCorner>51.22 0.89</ows:UpperCorner>
</ows:BoundingBox>
</csw:BriefRecord>
<csw:BriefRecord>
<dc:identifier>urn:uuid:9a669547-b69b-469f-a11f-2d875366bbdc</dc:identifier>
<dc:title>Ñunç elementum</dc:title>
<dc:type>http://purl.org/dc/dcmitype/Dataset</dc:type>
<ows:BoundingBox crs="urn:x-ogc:def:crs:EPSG:6.11:4326" dimensions="2">
<ows:LowerCorner>44.79 -6.17</ows:LowerCorner>
<ows:UpperCorner>51.13 -2.23</ows:UpperCorner>
</ows:BoundingBox>
</csw:BriefRecord>
</csw:SearchResults>
</csw:GetRecordsResponse>
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- PYCSW_VERSION -->
<ows:ExceptionReport xmlns:csw="http://www.opengis.net/cat/csw/2.0.2" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dct="http://purl.org/dc/terms/" xmlns:gmd="http://www.isotc211.org/2005/gmd" xmlns:gml="http://www.opengis.net/gml" xmlns:ows="http://www.opengis.net/ows" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2.0" language="en-US" xsi:schemaLocation="http://www.opengis.net/ows http://schemas.opengis.net/ows/1.0.0/owsExceptionReport.xsd">
<ows:Exception exceptionCode="InvalidParameterValue" locator="service">
<ows:ExceptionText>Invalid Constraint: Invalid Filter request: Invalid number of coordinates in geometry</ows:ExceptionText>
</ows:Exception>
</ows:ExceptionReport>
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
<csw:GetRecords xmlns:csw="http://www.opengis.net/cat/csw/2.0.2" xmlns:ogc="http://www.opengis.net/ogc" service="CSW" version="2.0.2" resultType="results" startPosition="1" maxRecords="5" outputFormat="application/xml" outputSchema="http://www.opengis.net/cat/csw/2.0.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/cat/csw/2.0.2 http://schemas.opengis.net/csw/2.0.2/CSW-discovery.xsd" xmlns:gml="http://www.opengis.net/gml">
<csw:Query typeNames="csw:Record">
<csw:ElementSetName>brief</csw:ElementSetName>
<csw:Constraint version="1.1.0">
<ogc:Filter>
<ogc:Intersects>
<ogc:PropertyName>ows:BoundingBox</ogc:PropertyName>
<gml:Polygon srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">
<gml:exterior>
<gml:LinearRing>
<gml:posList srsDimension="2">47.00 -5.00 55.00 -5.00 55.00 20.00 47.00 20.00 47.00 -5.00</gml:posList>
</gml:LinearRing>
</gml:exterior>
</gml:Polygon>
</ogc:Intersects>
</ogc:Filter>
</csw:Constraint>
</csw:Query>
</csw:GetRecords>

@@ -0,0 +1,26 @@
<csw:GetRecords
xmlns:csw="http://www.opengis.net/cat/csw/2.0.2"
xmlns:gml="http://www.opengis.net/gml"
xmlns:ogc="http://www.opengis.net/ogc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ows="http://www.opengis.net/ows" outputSchema="http://www.opengis.net/cat/csw/2.0.2"
outputFormat="application/xml" version="2.0.2" service="CSW" resultType="results" maxRecords="1000"
xsi:schemaLocation="http://www.opengis.net/cat/csw/2.0.2 http://schemas.opengis.net/csw/2.0.2/CSW-discovery.xsd">
<csw:Query typeNames="csw:Record">
<csw:ElementSetName>full</csw:ElementSetName>
<csw:Constraint version="1.1.0">
<ogc:Filter>
<ogc:Intersects>
<ogc:PropertyName>ows:BoundingBox</ogc:PropertyName>
<gml:Polygon srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">
<gml:exterior>
<gml:LinearRing>
<gml:posList srsDimension="2">11 16 49 17 10 10</gml:posList>
</gml:LinearRing>
</gml:exterior>
</gml:Polygon>
</ogc:Intersects>
</ogc:Filter>
</csw:Constraint>
</csw:Query>
</csw:GetRecords>

0 comments on commit b9e649a

Please sign in to comment.