Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Minor
-
Resolution: Not A Bug
-
Affects Version/s: 1.3.1
-
Fix Version/s: None
-
Component/s: None
-
Labels:None
-
Environment:WinXP SP2, Java 1.4.2_10, Tomcat 5.0.28
-
Number of attachments :
Description
Requirement: GetFeatures query which retrieves all results whose geometries are related to the supplied geometry according to the following DE-9IM pattern: T********. The results from this query will be equivalent to [Intersects(geom1, geom2) And Not Touches(geom1, geom2)] but hopefully more efficient, as the latter will require two spatial evaluations for every matching result.
Attached is a sample shapefile based on BasicPolygons that contains two polygons with a shared boundary but whose interiors do not intersect. As expected, GetFeatures queries using Intersects AND NOT Touches work fine (e.g. return expected results), but the equivalent GetFeeatures query using the relatesPattern generates an error.
Sample GetFeatures query as run against the attached shapefile 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>
Geoserver returns the following error message:
org.xml.sax.SAXException: Attempted to construct illegal filter: Attempted to add sub expression in a bad state: complete
at org.geotools.filter.FilterFilter.endElement(FilterFilter.java:325)
at org.geotools.gml.GMLFilterGeometry.endElement(GMLFilterGeometry.java:204)
at org.geotools.gml.GMLFilterDocument.endElement(GMLFilterDocument.java:287)
at org.xml.sax.helpers.ParserAdapter.endElement(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanEndElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.xml.sax.helpers.ParserAdapter.parse(Unknown Source)
at org.vfny.geoserver.wfs.requests.readers.GetFeatureXmlReader.read(GetFeatureXmlReader.java:72)
at org.vfny.geoserver.servlets.AbstractService.doPost(AbstractService.java:375)
at org.vfny.geoserver.wfs.servlets.WfsDispatcher.doResponse(WfsDispatcher.java:286)
at org.vfny.geoserver.wfs.servlets.WfsDispatcher.doPost(WfsDispatcher.java:175)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.vfny.geoserver.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:122)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Unknown Source)
The query was run with the function as the left expression in a PropertyIsEqualTo and "true" as the right expression, with the same results. The query listed above should work though, since Geoserver does accept an expression as a direct child of "Filter" as shown by the response to a query sent with the following filter (all results returned):
<wfs:Query typeName="topp:TouchingPolygons">
<Filter>
<Function name="isValid">
<PropertyName>the_geom</PropertyName>
</Function>
</Filter>
</wfs:Query>
This should be working (and thus I'll investigate if it's still broken). Yet, this is hardly going to be any faster since no datastore supports relate, and as a result the sql quries would not leverage the spatial indexes.