Skip to main content
3 of 4
enhance readability
zeto31
  • 43
  • 1
  • 7

Using GeoServer WFS to GetFeature by Clicking on it on the map

Can someone point me to document of crafting a Geoserver WFS GetFeature request with CQL_Filters?

I've already read the GeoServer CQL_Filter Geometric filter section

I have a Geoserver WMS set up to return multiple polygon geometries (from a postgres database) on the map. I now want to click on the map and in its click event, send a WFS GetFeature request to find the attributes associated with that geometry.

I read the tutorial and it looks like CQL_Filter Contains is what I need but I'm having trouble finding the correct syntax. I'm working with this URL at the moment:

var requestUrl = 'http://localhost:8080/geoserver/wfs?&OUTPUTFORMAT=application/json&REQUEST=GetFeature&SERVICE=WFS&VERSION=1.1.1&srsName=EPSG:4326&TYPENAME=namespace:layer&CQL_FILTER=CONTAINS(geom, Point(' + location.longitude + ',' + location.latitude + '))';

When I post the above URL I get the following error:

<ows:ExceptionReport xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ows="http://www.opengis.net/ows/1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0.0" xsi:schemaLocation="http://www.opengis.net/ows/1.1 http://localhost:8080/geoserver/schemas/ows/1.1.0/owsAll.xsd">
  <ows:Exception exceptionCode="NoApplicableCode">
    <ows:ExceptionText>Could not parse CQL filter list.
Encountered &amp;quot;,&amp;quot; at line 1, column 40.&#13;
Was expecting one of:&#13;
    &amp;quot;-&amp;quot; ...&#13;
    &amp;lt;INTEGER_LITERAL&amp;gt; ...&#13;
    &amp;lt;FLOATING_LITERAL&amp;gt; ...&#13;
     Parsing : CONTAINS(geom, Point(-84.39313136004358,33.757086728151805)).</ows:ExceptionText>
  </ows:Exception>
</ows:ExceptionReport>

Thanks, Zi

zeto31
  • 43
  • 1
  • 7