Ok so I have a PostgreSQL Table, to which I added a PostGIS geometry column using:

SELECT AddGeometryColumn ('public','my_table','geom',4326,'POINT',2);

Followed by:

UPDATE public.my_table
SET geom = st_geometryfromtext('POINT('|| lon ||' '|| lat ||')',4326);

I then publish this table as WFS 1.0.0 using Geoserver 2.12.0. When I make a query using filter

DWITHIN(geom, Point(lon lat), distanceInDegrees, meters)

my query returns geojson with zero features.

If I query using

DWITHIN(geom, Point(lon lat), distanceInMeters, meters)

then I get correct results within the specified radius. I simply cannot figure out why the units are meters and not degrees when native EPSG is 4326? In the past when I have published layers as 4326, DWITHIN always took only degree units.

The layer configs in Geoserver:

native srs - EPSG:4326

declared srs - EPSG:4326

srs handing - Force Declared

  • Can you repeat the issue if you save the states shapefile from the GeoServer demo data into PostGIS and publish it?
    – user30184
    Nov 16 '17 at 19:49
  • Isn't that to be expected? What happens if you specify the unit as degrees?
    – Ian Turton
    Nov 16 '17 at 20:29
  • @Ian Turton Degrees are expected, the parameter specifying the unit doesn't matter see reply to [this post] (gis.stackexchange.com/questions/132251/…). Geoserver expects a valid value but uses the native SRS to execute the DWITHIN regardless of what units you enter. Nov 17 '17 at 2:57
  • I think it used to do that but it is now fixed for postgis stores
    – Ian Turton
    Nov 17 '17 at 7:10
  • Apparently it still is not fixed, when I run DWITHIN(geom,Point(-77.051333 38.802610), 1,statute miles) I get zero features returned. But I get 17 features when I run DWITHIN(geom,Point(-77.051333 38.802610), 1609.34,meters). Unit as 'degrees' is not permited as I got the following response from Geoserver: Could not parse CQL filter list. Encountered "degrees" at line 1, column 45. Was expecting one of: "feet" ... "meters" ... "statute miles" ... "nautical miles" ... "kilometers" ... Nov 17 '17 at 14:14

Your Answer

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

Browse other questions tagged or ask your own question.