I'm trying to figure out the best way to do a GetFeatures query in
GeoServer 1.3.1 which retrieves all results whose geometries are related
to my supplied geometry according to the following DE-9IM pattern:
T********
I should be able to do an Intersects(geom) AND NOT Touches(geom), but
I'm wondering if I could more efficiently make use of the relatesPattern
function. I created a sample shapefile based on BasicPolygons that
contains two polygons with a shared boundary but whose interiors do not
intersect. As expected, the Intersects AND NOT Touches works fine, but
I can't seem to get the relatesPattern function working.
My GetFeatures query looks like this:
<wfs:GetFeature service="WFS" version="1.0.0"
outputFormat="GML2"
xmlns:topp="http://www.openplans.org/topp"
xmlns:wfs="http://www.opengis.net/wfs"
xmlns="http://www.opengis.net/ogc"
xmlns:gml="http://www.opengis.net/gml"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.opengis.net/wfs
http://schemas.opengis.net/wfs/1.0.0/WFS-basic.xsd">
<wfs:Query typeName="topp:TouchingPolygons">
<Filter>
<Function name="relatePattern">
<PropertyName>the_geom</PropertyName>
<gml:MultiPolygon
srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">
<gml:polygonMember>
<gml:Polygon>
<gml:outerBoundaryIs>
<gml:LinearRing>
<gml:coordinates decimal="." cs="," ts=" ">-1,-1 -1,1
1,1 1,-1 -1,-1</gml:coordinates>
</gml:LinearRing>
</gml:outerBoundaryIs>
</gml:Polygon>
</gml:polygonMember>
</gml:MultiPolygon>
<Literal>T********</Literal>
</Function>
</Filter>
</wfs:Query>
</wfs:GetFeature>
I get an error message "org.xml.sax.SAXException: Attempted to construct
illegal filter: Attempted to add sub expression in a bad state:
complete" plus associated stack trace. The shapefile I'm using was
constructed (using ogr2ogr) from the following gml:
<?xml version="1.0" encoding="UTF-8"?>
<FeatureCollection>
<gml:boundedBy>
<gml:Box srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">
<gml:coordinates decimal="." cs="," ts=" ">-1,-1
3,1</gml:coordinates>
</gml:Box>
</gml:boundedBy>
<gml:featureMember>
<BasicPolygons fid="BasicPolygons.1">
<the_geom>
<gml:MultiPolygon
srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">
<gml:polygonMember>
<gml:Polygon>
<gml:outerBoundaryIs>
<gml:LinearRing>
<gml:coordinates decimal="." cs="," ts=" ">-1,-1 -1,1
1,1 1,-1 -1,-1</gml:coordinates>
</gml:LinearRing>
</gml:outerBoundaryIs>
</gml:Polygon>
</gml:polygonMember>
</gml:MultiPolygon>
</the_geom>
<ID>ID_LEFT</ID>
</BasicPolygons>
</gml:featureMember>
<gml:featureMember>
<BasicPolygons fid="BasicPolygons.3">
<the_geom>
<gml:MultiPolygon
srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">
<gml:polygonMember>
<gml:Polygon>
<gml:outerBoundaryIs>
<gml:LinearRing>
<gml:coordinates decimal="." cs="," ts=" ">1,1 3,1
3,-1 1,-1 1,1</gml:coordinates>
</gml:LinearRing>
</gml:outerBoundaryIs>
</gml:Polygon>
</gml:polygonMember>
</gml:MultiPolygon>
</the_geom>
<ID>ID_RIGHT</ID>
</BasicPolygons>
</gml:featureMember>
</FeatureCollection>
Has anybody successfully used the relatesPattern function in a
GetFeatures filter before? I'm open to the possibility that I'm using
the function in completely the wrong way. Also, should I even bother
with the relatesPattern function, i.e. will Intersects AND NOT Touches
be just as efficient?
Thanks for the help.
John Fletcher
Latitude Geographics Group Ltd.
jfletcher@anonymised.com www.latitudegeo.com
Head Office: 204 Market Square Victoria, BC Canada V8W 3C6
Tel: (250) 381-8130 Fax: (250) 381-8132
Geocortex Internet Mapping (www.geocortex.net) - Helping people succeed
with web-based geography