[mapserver-users] WFS bbox/intersect etc query from custom projection to EPSG:4326

Sander Pukk sander.pukk at gmail.com
Wed Nov 24 23:21:20 PST 2021


Hei!

Unfortunately it did not change the behaviour.

Regards,
Sander

On Wed, Nov 24, 2021 at 5:33 PM Seth G <sethg at geographika.co.uk> wrote:

> Hi Sander,
>
> Does adding a PROJECTION block to your LAYER have an effect?
> Even if the layer projection is the same as the MAP I think I've run into
> a few combinations where setting explicitly on the layer helped.
>
> Seth
>
>
> --
> web:http://geographika.co.uk
> twitter: @geographika
>
>
> On Wed, Nov 24, 2021, at 2:01 PM, Sander Pukk wrote:
>
> Hi there!
>
> We have been running into an issue with WFS, EPSG:4326 and a filter
> (namely bbox) query.
> We have been using MapServer for years and the current version we have is
> 7.6.4.
> WMS and WFS are both enabled and WFS is configured for gml and geojson.
>
> Our MapServer's main output is in EPSG:3301 projection and most of our
> clients use it like that.
> The bbox OGC WFS filters work in that projection and another more "robust"
> approach by limiting bbox into a 20x20 pixel square in the request.
>
> Our MapServer can also function in the regular 4326 and 3857 in WMS and
> WFS.
> But one of our clients is doing their things in 4326 and we noticed an
> issue when querying WFS with a bbox/intersect filter in that projection.
>
>
> *Main problem:*Trying to reverse geocode from WFS service (capable of
> 3301, 4326 and 3857) where underlying data is in EPSG:3301 and request
> comes in 4326.
> The response should be in 4326, but the transformation does not work.
> (Obvious from the database SQL).
> Everything works in EPSG:3301.
>
> I have obscured some URL and Layer names.
> Our map file with a sample layer looks like this:
> MAP
>
>   LEGEND
>     LABEL
>       TYPE truetype
>       FONT "Arial"
>       SIZE 10
>       POSITION AUTO
>     END
>   END
>
>   NAME           "<%NAME%>_keskkond"
>   STATUS         ON
>   EXTENT         <%= node['mapserver']['extent'] %>
>   FONTSET        "<%= URL %>/fonts/current/fonts.list"
>   IMAGETYPE      "png"
>   DEFRESOLUTION 96
>   RESOLUTION    96
>   CONFIG "MS_ERRORFILE" "infolayer.log"
>   DEBUG 0
>   MAXSIZE 10000
>   OUTPUTFORMAT
>     NAME "png"
>     DRIVER AGG/PNG
>     MIMETYPE "image/png"
>     IMAGEMODE RGB
>     EXTENSION "png"
>     FORMATOPTION "QUANTIZE_FORCE=on"
>   END
>
>   OUTPUTFORMAT
>     NAME "geojson"
>     DRIVER "OGR/GEOJSON"
>     MIMETYPE "application/json; subtype=geojson; charset=utf-8"
>     FORMATOPTION "STORAGE=filesystem"
>     FORMATOPTION "FORM=SIMPLE"
>   END
>
>   WEB
>       METADATA
>         "wfs_title"                     "infolayer"
>         "wfs_enable_request"            "*"
>         "wfs_encoding"                  "UTF-8"
>         "wms_title"                     "infolayer"
>         "wms_encoding"                  "UTF-8"
>         "wms_onlineresource"
>  "/mapserv?map=/app/gis/infokihid/infolayer.map&"
>         "wfs_onlineresource"
>  "/mapserv?map=/app/gis/infokihid/infolayer.map&"
>         "ows_srs"                       "EPSG:3301 EPSG:3857 EPSG:4326"
>         "ows_enable_request"            "*"
>         "wfs_getfeature_formatlist"     "gml,geojson"
>         "wms_feature_info_mime_type"
>  "application/json,application/json;
> subtype=geojson,application/vnd.ogc.gml,text/plain"
>       END
>   END
>
>   PROJECTION
>       "init=epsg:3301"
>   END
>
> LAYER
>   TEMPLATE "dummy"
>     NAME "omavalitsus"
>     STATUS off
>     TYPE polygon
>     CONNECTIONTYPE   POSTGIS
>     INCLUDE "postgis.inc"
>     DATA "geom from omavalitsus using unique gid using srid=3301"
>     LABELITEM           "nimetus"
>     TYPE                polygon
>     MAXSCALEDENOM       2000000
>
>     METADATA
>         "gml_msGeometry_type"   "polygon"
>         "wfs_title"             "omavalitsus"
>         "wms_title"             "omavalitsus"
>         "wfs_srs"               "EPSG:3301"
>         "wms_srs"               "EPSG:3301"
>         "wms_extent"            "355000 6360000 754000 6660000"
>         "gml_include_items"     "all"
>         "ows_include_items"     "all"
>         "wfs_srs"               "EPSG:3301"
>         "gml_featureid" "id"
>         "ows_featureid" "id"
>     END
>
>     CLASS
>         NAME omavalitsus
>         STYLE
>             COLOR   234 123 43
>             OPACITY 15
>         END
>         STYLE
>             WIDTH 2
>             OUTLINECOLOR 80 80 80
>             OPACITY 15
>         END
>     END
> END
>
>
> If we do a query without a bbox and want all the features, it works.
>
> Example:
>
> https://URL/mapserv?map=/app/gis/infokihid/infolayers_other.map&service=WFS&request=GetFeature&version=1.1.0&typename={{LAYER}}&outputformat=gml3&srsName=EPSG:4326
>
> WFS version 1.3.0 and 2.0.0
> But if we add a bbox in OGC filter format or bbox, then it does not work
> anymore:
>
> Example:
>
>
> https://URL/mapserv?map=/app/gis/infokihid/infolayers_other.map&service=WFS&request=GetFeature&version=1.1.0&typename={{LAYER}}&outputformat=gml3&srsName=EPSG:4326&bbox=24.753586,59.29725,24.773586,59.31725,urn:x-ogc:def:crs:EPSG:4326
>
> OR OGC
>
>
> https://URL/mapserv?map=/app/gis/infokihid/infolayers_other.map&SERVICE=WFS&Version=2.0.0&REQUEST=GetFeature&typeNames={{LAYER}}&Filter=<Filter><contains><PropertyName>Geometry</PropertyName><gml:Point
> srsName="urn:ogc:def:crs:EPSG::4326"><gml:coordinates>25.035308,59.32675</gml:coordinates></gml:Point></contains></Filter>
>
>
> Some documentation hints that OGC filter needs to be in the same SRID as
> the underlying data so I guess that shouldn't be working.
>
> SQL form the database where you can see the geom query part where
> transformation of geom contains/intersect etc happens, is is wrong:
>
> select <<FIELDS>>,ST_AsBinary(("geom"),'NDR') as geom,"gid"::text from (select * from LAYER where kehtiv_alates < now() and (kehtiv_kuni > now() OR kehtiv_kuni is null)) as subquery where ("geom" && ST_GeomFromText('POLYGON((296500 6249000,296500 6761000,808500 6761000,808500 6249000,296500 6249000))',3301)) AND ST_Distance("geom", ST_GeomFromText('POLYGON((296500 6249000,296500 6761000,808500 6761000,808500 6249000,296500 6249000))',3301)) = 0 and (st_contains(geom,ST_GeomFromText('POINT (25.0353080000000006 59.3267499999999970)',3301)) = TRUE)
>
>
> The contains should be:
>
> (st_contains(geom,ST_TRANSFORM(ST_GeomFromText('POINT (25.0353080000000006 59.3267499999999970)',4326),3301))
>
>
> One way to get a result is using WFS 1.0.0. It returns the result in
> EPSG:3301 but is correct.
>
>
> https://URL/mapserv?map=/app/gis/infokihid/infolayers_other.map&service=WFS&request=GetFeature&version=1.0.0&typename={{LAYER}}&outputformat=gml3&srsName=EPSG:4326&bbox=24.753586,59.29725,24.773586,59.31725,urn:x-ogc:def:crs:EPSG:4326
>
> I have tried different OGC filters, but they all act the same when trying
> to do stuff in EPSG:4326.
> Tried different WFS versions, coordinate order in OGC filter/manual bbox
> etc.
> Even with the OGC filter being in EPSG:3301, but request in srs 4326.
> Have not yet managed to get it.
>
> So my questions are:
>
>    1. Is there something wrong in our MAP/LAYER files? Do we need to
>    change or add something?
>    2. Could/Should it be possible to do what we are trying to do, when
>    the main projection is something different then all the request parameters?
>
>
> Cheers,
> Sander
> _______________________________________________
> MapServer-users mailing list
> MapServer-users at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/mapserver-users
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20211125/8f03ceb6/attachment-0001.html>


More information about the MapServer-users mailing list