[GIS] Geoserver CQL Cross Layer Intersection Failing

cql-filterfiltergeoserverwfs

I am having trouble forming a properly formatted CQL request using geoServer cross layer filer functions and was hoping others could assist. My request is as follows:

http://localhost:8080/geoserver/wfs?request=GetFeature&typeName=AU:TownPoints&CQL_FILTER=INTERSECTS(the_geom,collectGeometries(queryCollection('AU:Districts','the_geom','CODE=A1')))&version=1.1.0

The intent is to select the towns that are within a selected District shape.

With the above request a null data set is returned:

<wfs:FeatureCollection xmlns:ogc="http://www.opengis.net/ogc" xmlns:AU="hidden.com" xmlns:tiger="http://www.census.gov" xmlns:cite="http://www.opengeospatial.net/cite" xmlns:nurc="http://www.nurc.nato.int" xmlns:sde="http://geoserver.sf.net" xmlns:wfs="http://www.opengis.net/wfs" xmlns:topp="http://www.openplans.org/topp" xmlns:it.geosolutions="http://www.geo-solutions.it" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sf="http://www.openplans.org/spearfish" xmlns:ows="http://www.opengis.net/ows" xmlns:gml="http://www.opengis.net/gml" xmlns:xlink="http://www.w3.org/1999/xlink" **numberOfFeatures="0"** timeStamp="2013-03-20T22:36:01.593Z" xsi:schemaLocation="hidden.com http://localhost:8080/geoserver/wfs?service=WFS&version=1.1.0&request=DescribeFeatureType&typeName=DHS%3ATownPoints http://www.opengis.net/wfs http://localhost:8080/geoserver/schemas/wfs/1.1.0/wfs.xsd">
<gml:featureMembers/>
</wfs:FeatureCollection>

I think the formatting of my query string 'CODE=A1' is wrong, so geoServer returns a null set for the queryCollection, meaning the intersection is being performed against a null set. (Note: CODE='A1' works fine if I query Districts directly.)

I have also tried 'CODE='A1'' and some other variations but this nesting always causes an exception similar to the following:

Could not parse CQL filter list. Encountered "A1" at line 1, column 92.
 Was expecting one of:
 ")" ...
 "," ...
 "/" ...
 "*" ...
 "+" ...
 "-" ...
 Parsing : INTERSECTS(the_geom,collectGeometries(queryCollection('AU:Districts','the_geom','CODE='A1''))).

I have looked at lots of examples but cannot find one with a filter string in the queryCollection function.

Best Answer

INTERSECTS(geom, collectGeometries(queryCollection('topp:states', 'the_geom', 'STATE_ABBR=" + "'" + "'" + 'CA' + "'" + "'" + "')))
Related Question