0

I am using GeoServer and am trying to understand one problem: Using this statement returns successfully the polygon intersecting with my BBOX. The layer is EPSG:2193

http://myserver/fwsys/wms?service=WFS&version=1.0&request=GetFeature&typeName=fwsys:fwsys_region&CQL_FILTER=BBOX(the_geom,19438298.842,%20-4502716.974,19702465.211,%20-4587714.950,%27EPSG:3857%27)

What I would like to point out here is that the layer is in EPSG:2931 - my request is in EPSG:3875. This works well

Now I followed the instructions and tried to do the same for a single point:

http://myserver/fwsys/wms?service=WFS&version=1.0&request=GetFeature&typeName=fwsys:fwsys_region&CQL_FILTER=POINT(the_geom,19438298.842,%20-4502716.974,%27EPSG:3857%27)

This returns the following error output:

<ServiceExceptionReport version="1.2.0" 
  xsi:schemaLocation="http://www.opengis.net/ogc http://schemas.opengis.net/wfs/1.0.0/OGC-exception.xsd">
  <ServiceException>
    Could not parse CQL filter list.
    Encountered "POINT ( the_geom" at line 1, column 1.
    Was expecting one of:
    "not" ...
    "include" ...
    "exclude" ...
    "(" ...
    "[" ...
    "id" ...
    "in" ...
    <IDENTIFIER> ...
    <DATE_TIME> ...
    <DATE> ...
    "-" ...
    <INTEGER_LITERAL> ...
    <FLOATING_LITERAL> ...
    <STRING_LITERAL> ...
    "true" ...
    "false" ...
    "point" ...
    "point" "(" "-" ...
    "point" "(" <INTEGER_LITERAL> ...
    "point" "(" <FLOATING_LITERAL> ...
    "point" "not" ...
    "point" "like" ...
    "point" "ilike" ...
    "point" "exists" ...
    "point" "does-not-exist" ...
    "point" "is" ...
    "point" "between" ...
    "point" "=" ...
    "point" ">" ...
    "point" "<" ...
    "point" ">=" ...
    "point" "<=" ...
    "point" "<>" ...
     Parsing : POINT(the_geom,19438298.842, -4502716.974,'EPSG:3857').
  </ServiceException>
</ServiceExceptionReport>

Is it possible to use 'POINT' in the way I do? What am I doing wrong?

  • 1
    By this thread CQL_FILTER does not support setting the SRID osgeo-org.1560.x6.nabble.com/…. Normal BBOX as a standard WFS parameter does support it, but in your example you use the CQL_FILTER called BBOX which is probably not the same. But check your other filter CQL_FILTER=POINT(the_geom,19438298.842,%20-4502716.974,%27EPSG:3857%27) because it seems very odd to me. What instruction did you follow? – user30184 Dec 1 '16 at 5:50
1

Use INTERSECT query and add the point as WKT :

CQL_FILTER=INTERSECTS(the_geom, Point(19438298.842 -4502716.974))

Regarding the SR, set it in your request, as below query :

&srs=EPSG%3A3857  

http://docs.geoserver.org/latest/en/user/services/wms/reference.html

Reference:
Using GeoServer WFS to GetFeature by clicking on the map

0

Important note for people like me who are brand new to CQL queries:
make sure you are using the correct units for your bounding box!

i.e in this syntax (using a Python variable I called 'filt3r'):

filt3r = "BBOX(the_geom,x_min, y_min, x_max, y_max)"

First of all, replace "the_geom" with the name of your geometry field; for me this is SHAPE

You need to make sure your extents are in the same units as the coordinate system (CRS) as your source data.

If in doubt as to what your CRS is, you need to get ahold of the "crs" JSON string, which looks like this:

{'name': 'urn:ogc:def:crs:EPSG::3005'}

That shows us our CRS has an EPSG code of 3005.

To get that JSON string, one can do a getFeature request using the 'requests' module in Python as follows (Python code) warning - this is involved; if you have an easier way to determine the CRS, do that instead!):

import requests
type_name = the_name_of_your_WFS_Layer #ex. type_name ="WHSE_LAND_AND_NATURAL_RESOURCE.PROT_HISTORICAL_FIRE_POLYS_SP"
params = {'service':'WFS', 'version':'2.0', 'request':'GetFeature', 'typeName':type_name, 'outputFormat':'application/json', 'SrsName':self.srs }
r_url = your_WFS_URL_plus_/ows? # ex. "https://openmaps.gov.bc.ca/geo/pub/WHSE_LAND_AND_NATURAL_RESOURCE.PROT_HISTORICAL_FIRE_POLYS_SP/ows?"
r = requests.get(r_url, params=params)
f = myWfs.get_features(t_name, filter = None) # optionally, use a filter here to return a smaller result set
if f is not None:
        print (f["crs"]['properties'])

Note that 'myWFS' above is an instance of a class, but for simplicity I did not show how that class gets set up.

Once you know your CRS, you can ensure your extents make sense (i.e are expressed in meters or feet rather than decimal degrees, for example).

In the end, my filt3r variable / BBOX string works when it looks like this:

filt3r = "BBOX(SHAPE, 1522517.382500, 745474.692100, 1615285.694100, 815813.841400)"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.