Hi,
I’m trying to get some data via a WFS getFeature request using a CQL filter. Because there are mutliple polygons I’m trying to use the GEOMETRYCOLLECTION type, though it’s kind of difficult because I don’t seem to be able to find much documentation on it.
Anyway, I start by testing one polygon and try I try the following query:
[http://localhost:8080/geoserver/wfs?request=getfeature&service=wfs&version=1.1.0&typename=woodland_geometry&outputFormat=GML2&cql_filter=WITHIN(the_geom_data,GEOMETRYCOLLECTION(POLYGON((52.851417541503906](http://localhost:8080/geoserver/wfs?request=getfeature&service=wfs&version=1.1.0&typename=woodland_geometry&outputFormat=GML2&cql_filter=WITHIN(the_geom_data,GEOMETRYCOLLECTION(POLYGON((52.851417541503906) -3.413439273834228, … lots of co-ords here … 52.851417541503906 -3.413439273834228))))
and it returns with this error:
<ows:Exception exceptionCode=“NoApplicableCode”>
−
ows:ExceptionText
java.lang.ClassCastException: org.geotools.filter.AttributeExpressionImpl cannot be cast to org.opengis.filter.Filter
org.geotools.filter.AttributeExpressionImpl cannot be cast to org.opengis.filter.Filter
</ows:ExceptionText>
</ows:Exception>
I’m guessing because there’s only one polygon in there. To confirm my polygon was fine I removed the GEOMETRYCOLLECTION part (and associated set of brackets) leaving just the POLYGON and it worked fine. So I add another polygon to the original GEOMETRYCOLLECTION query and end up with this (full) URL - whitespace around the second “POLYGON” added to ease readability, it’s not there in the real URL:
[http://localhost:8080/geoserver/wfs?request=getfeature&service=wfs&version=1.1.0&typename=woodland_geometry&outputFormat=GML2&cql_filter=WITHIN(the_geom_data,GEOMETRYCOLLECTION(POLYGON((53.08063507080078](http://localhost:8080/geoserver/wfs?request=getfeature&service=wfs&version=1.1.0&typename=woodland_geometry&outputFormat=GML2&cql_filter=WITHIN(the_geom_data,GEOMETRYCOLLECTION(POLYGON((53.08063507080078) -3.30979323387146,53.08063507080078 -3.30979323387146,53.08061599731445 -3.2939405441284175,53.08058547973633 -3.2701609134674072,53.08052062988281 -3.2305266857147217,53.070770263671875 -3.1037306785583496,53.046566009521484 -2.95328688621521,52.4075927734375 -1.848714828491211,52.35076522827149 -1.8823108673095703,52.29383087158203 -1.9079525470733645,52.242000579833984 -1.9569034576416016,52.185508728027344 -2.0137128829956055,52.09197235107422 -2.1573872566223145,52.02230453491211 -2.315004587173462,51.97622299194336 -2.4712541103363037,51.968429565429695 -2.6575467586517334,51.98407745361328 -2.827788114547729,52.023231506347656 -2.9976468086242676,52.090553283691406 -3.1596114635467534,52.17179870605469 -3.3140738010406494,52.26703643798828 -3.5,52.376060485839844 -3.7101228237152095,52.49436950683593 -3.905970573425293,52.55587387084961 -3.992657423019409,52.612648010253906 -4.071794509887695,52.65527725219727 -4.1195454597473145,52.740592956542976 -4.19959020614624,52.80240631103516 -4.224368572235107,52.864402770996094 -4.225588798522949,52.91707611083985 -4.195035457611084,52.96981430053711 -4.148535251617432,53.00823211669922 -4.09372615814209,53.04185104370117 -4.038740158081055,53.06583023071288 -4.007350444793701,53.075428009033196 -3.9916074275970455,53.075428009033196 -3.9916074275970455,53.08063507080078 -3.30979323387146)), POLYGON ((52.13802719116211 -3.7055177688598633,52.13802719116211 -3.7055177688598633,52.138004302978516 -3.713274955749512,52.13794708251953 -3.736554622650147,52.03199005126954 -4.045796871185303,52.02721786499023 -4.045754909515381,52.012889862060554 -4.045632839202881,51.99382781982422 -4.037724494934082,51.97480010986328 -4.022078990936279,51.96532440185546 -4.006518840789795,51.95106506347656 -3.9909276962280273,51.93684387207032 -3.967607975006103,51.92261505126953 -3.9443008899688725,51.908382415771484 -3.921006202697754,51.89892196655274 -3.8977537155151367,51.884742736816406 -3.8590288162231445,51.87533187866211 -3.8203506469726567,51.87541580200195 -3.7971787452697754,51.8707160949707 -3.773988723754883,51.86603546142578 -3.7430832386016846,51.86617660522461 -3.696762800216675,51.87105941772461 -3.6581809520721436,51.885459899902344 -3.6273396015167236,51.899818420410156 -3.60421085357666,51.91896438598633 -3.5887959003448486,51.93809127807618 -3.565650463104248,51.9620018005371 -3.5502195358276367,51.985904693603516 -3.5425062179565425,52.014556884765625 -3.5425233840942383,52.03363037109374 -3.542536973953247,52.05265808105469 -3.542555332183838,52.06217575073242 -3.5425641536712646,52.076438903808594 -3.5503201484680176,52.0811882019043 -3.5580689907073975,52.090694427490234 -3.565826892852783,52.09544372558593 -3.573580503463745,52.10020065307617 -3.5735883712768555,52.10018920898437 -3.581336259841919,52.10018920898437 -3.581336259841919,52.13802719116211 -3.7055177688598633))))
I get a similar, but not identical error returned in the web-browser:
<ows:Exception exceptionCode=“NoApplicableCode”>
−
ows:ExceptionText
java.lang.ClassCastException: org.geotools.filter.LiteralExpressionImpl cannot be cast to org.opengis.filter.Filter
org.geotools.filter.LiteralExpressionImpl cannot be cast to org.opengis.filter.Filter
</ows:ExceptionText>
</ows:Exception>
There is also a new entry in the geoserver.log file:
2009-06-26 12:37:35,671 INFO [geoserver.wfs] -
Request: getServiceInfo
2009-06-26 12:37:35,671 ERROR [geoserver.ows] -
java.lang.ClassCastException: org.geotools.filter.LiteralExpressionImpl cannot be cast to org.opengis.filter.Filter
at org.geotools.filter.text.commons.AbstractFilterBuilder.getFilterList(AbstractFilterBuilder.java:131)
at org.geotools.filter.text.cql2.CQLCompiler.getFilterList(CQLCompiler.java:171)
at org.geotools.filter.text.commons.CompilerUtil.parseFilterList(CompilerUtil.java:214)
at org.geotools.filter.text.cql2.CQL.toFilterList(CQL.java:235)
at org.geotools.filter.text.cql2.CQL.toFilterList(CQL.java:186)
at org.geoserver.wfs.kvp.CQLFilterKvpParser.parse(CQLFilterKvpParser.java:26)
at org.geoserver.ows.util.KvpUtils.parse(KvpUtils.java:471)
at org.geoserver.ows.Dispatcher.parseKVP(Dispatcher.java:1069)
at org.geoserver.ows.Dispatcher.init(Dispatcher.java:246)
at org.geoserver.ows.Dispatcher.handleRequestInternal(Dispatcher.java:192)
at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)
at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:875)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:809)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:501)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1093)
at org.vfny.geoserver.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:108)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:265)
at org.acegisecurity.intercept.web.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:107)
at org.acegisecurity.intercept.web.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:72)
at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
at org.acegisecurity.ui.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:124)
at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
at org.acegisecurity.providers.anonymous.AnonymousProcessingFilter.doFilter(AnonymousProcessingFilter.java:125)
at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
at org.acegisecurity.ui.basicauth.BasicProcessingFilter.doFilter(BasicProcessingFilter.java:174)
at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
at org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(HttpSessionContextIntegrationFilter.java:249)
at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
at org.acegisecurity.util.FilterChainProxy.doFilter(FilterChainProxy.java:149)
at org.acegisecurity.util.FilterToBeanProxy.doFilter(FilterToBeanProxy.java:98)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
at org.geoserver.filters.LoggingFilter.doFilter(LoggingFilter.java:73)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
at org.geoserver.filters.ReverseProxyFilter.doFilter(ReverseProxyFilter.java:163)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
at org.geoserver.filters.GZIPFilter.doFilter(GZIPFilter.java:41)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:360)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:726)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:206)
at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:324)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:828)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:514)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
at org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:450)
Can anyone decipher the error messages I’m getting? Is it a bug in geoserver or am I using GEOMETRYCOLLECTION wrong?
Thanks,
Jonathan