Hi all,
I am using CQL spatial filter like BEYOND and DWITHIN and reading the docs at
http://docs.geoserver.org/stable/en/user/filter/ecql_reference.html#spatial-predicate
It seems that you may set the distance and the units according to “units is one of feet
, meters
, statute miles
, nautical miles
, kilometers
”
I tried with a very simple OL code snippet:
new OpenLayers.Layer.WMS(“countries”,
“http://localhost/geoserver/wms”,{
layers: “NaturalEarth:countries”,
format: “image/png”,
transparent: true,
cql_filter: “DWITHIN(geom,POINT(12.48 41.89),8,kilometers)”,
sld_body: sld
},
But I get a map where 8 is clearly interpreted as decimal degrees.
And it seems the same also looking at GeoServer’s log.
2013-11-03 22:16:15,452 DEBUG [org.geotools.jdbc] - SELECT “gid”,encode(ST_AsBinary(ST_Force_2D(“geom”)),‘base64’) as “geom” FROM “public”.“countries” WHERE (ST_DWithin(“geom”,ST_GeomFromText(‘POINT (12.48 41.89)’, 4326),8.0) AND “geom” && ST_GeomFromText(‘POLYGON ((-86.748515625 -17.787734375, -86.748515625 101.567734375, 111.708515
625 101.567734375, 111.708515625 -17.787734375, -86.748515625 -17.787734375))’, 4326))
2013-11-03 22:16:15,495 DEBUG [org.geotools.jdbc] - CLOSE CONNECTION
2013-11-03 22:16:15,497 DEBUG [org.geotools.rendering] - Style cache hit ratio: 0.9583333333333334 , hits 23, requests 24
2013-11-03 22:16:15,498 INFO [org.geoserver.wms] -
Request: getMap
Time =
Filter = [[ geom dwithin POINT (12.48 41.89), distance: 8.0 ]]
Format = image/png
Buffer = 0
Filters = [[ geom dwithin POINT (12.48 41.89), distance: 8.0 ]]
Height = 675
Width = 1125
Tiled = false
Palette = null
SRS = EPSG:4326
FeatureVersion = null
Styles = [StyleImpl[ name=Default Styler, DEFAULT]]
Layers = [org.geoserver.wms.MapLayerInfo@anonymised.com]
MaxFeatures = null
Crs = GEOGCS[“WGS 84”,
DATUM[“World Geodetic System 1984”,
SPHEROID[“WGS 84”, 6378137.0, 298.257223563, AUTHORITY[“EPSG”,“7030”]],
AUTHORITY[“EPSG”,“6326”]],
PRIMEM[“Greenwich”, 0.0, AUTHORITY[“EPSG”,“8901”]],
UNIT[“degree”, 0.017453292519943295],
AXIS[“Geodetic longitude”, EAST],
AXIS[“Geodetic latitude”, NORTH],
AUTHORITY[“EPSG”,“4326”]]
Bbox = ReferencedEnvelope[-86.396953125 : 111.356953125, -17.436171875 : 101.216171875]
RemoteOwsType = null
RemoteOwsURL = null
Env = {}
FormatOptions = {}
Angle = 0.0
CQLFilter = [[ geom dwithin POINT (12.48 41.89), distance: 8.0 ]]
Elevation =
FeatureId = null
StartIndex = null
ViewParams = null
BgColor = java.awt.Color[r=255,g=255,b=255]
Transparent = true
SldBody = NaturalEarth:countries1#0000001#FFFFCC0.65
ValidateSchema = false
Sld = null
SldVersion = null
TilesOrigin = null
Exceptions = SE_XML
Version = 1.1.1
Request = GetMap
Get = true
RawKvp = {BBOX=-86.396953125,-17.436171875,111.356953125,101.216171875, SERVICE=WMS, HEIGHT=675, REQUEST=GetMap, STYLES=, WIDTH=1125, CQL_FILTER=DWITHIN(geom,POINT(12.48 41.89),8,kilometers), TRANSPARENT=TRUE, VERSION=1.1.1, FORMAT=image/png, SLD_BODY=NaturalEarth:countries1#0000001#FFFFCC0.65, LAYERS=NaturalEarth:countries, SRS=EPSG:4326}
So is it the units binded to the SRS of the map and/or the layer?
Thanks for your help
Stefano
41.95581N 12.52854E