<!DOCTYPE html><html><head><title></title><style type="text/css">p.MsoNormal,p.MsoNoSpacing{margin:0}</style></head><body><div>Hi Sander,<br></div><div><br></div><div>Does adding a PROJECTION block to your LAYER have an effect?<br></div><div>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.<br></div><div><br></div><div>Seth<br></div><div><br></div><div><br></div><div id="sig62266145"><div class="signature">--<br></div><div class="signature">web:http://geographika.co.uk<br></div><div class="signature">twitter: @geographika<br></div></div><div><br></div><div><br></div><div>On Wed, Nov 24, 2021, at 2:01 PM, Sander Pukk wrote:<br></div><blockquote type="cite" id="qt" style=""><div dir="ltr"><div>Hi there!<br></div><div><br></div><div>We have been running into an issue with WFS, EPSG:4326 and a filter (namely bbox) query.<br></div><div>We have been using MapServer for years and the current version we have is 7.6.4.<br></div><div>WMS and WFS are both enabled and WFS is configured for gml and geojson.<br></div><div><br></div><div>Our MapServer's main output is in EPSG:3301 projection and most of our clients use it like that.<br></div><div>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.<br></div><div><br></div><div>Our MapServer can also function in the regular 4326 and 3857 in WMS and WFS.<br></div><div>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.<br></div><div><br></div><div><b>Main problem:<br></b>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.</div><div>The response should be in 4326, but the transformation does not work. (Obvious from the database SQL).<br></div><div>Everything works in EPSG:3301.<br></div><div><br></div><div>I have obscured some URL and Layer names. <br></div><div>Our map file with a sample layer looks like this:<br></div><div><div style="color:rgb(212, 212, 212);background-color:rgb(30, 30, 30);font-family:Consolas, "Courier New", monospace;font-size:14px;line-height:19px;white-space:pre;"><div><span style="color:rgb(220, 220, 170);">MAP</span><br></div><div><br></div><div> <span style="color:rgb(220, 220, 170);">LEGEND</span><br></div><div> <span style="color:rgb(220, 220, 170);">LABEL</span><br></div><div> <span style="color:rgb(86, 156, 214);">TYPE</span> <span style="color:rgb(156, 220, 254);">truetype</span><br></div><div> <span style="color:rgb(86, 156, 214);">FONT</span> "Arial"<br></div><div> <span style="color:rgb(86, 156, 214);">SIZE</span> <span style="color:rgb(181, 206, 168);">10</span><br></div><div> <span style="color:rgb(86, 156, 214);">POSITION</span> <span style="color:rgb(156, 220, 254);">AUTO</span><br></div><div> <span style="color:rgb(220, 220, 170);">END</span><br></div><div> <span style="color:rgb(220, 220, 170);">END</span><br></div><div><br></div><div> <span style="color:rgb(86, 156, 214);">NAME</span> "<%NAME%>_keskkond"<br></div><div> <span style="color:rgb(86, 156, 214);">STATUS</span> <span style="color:rgb(156, 220, 254);">ON</span><br></div><div> <span style="color:rgb(86, 156, 214);">EXTENT</span> <%= node['mapserver']['extent'] %><br></div><div> FONTSET "<%= URL %>/fonts/current/fonts.list"<br></div><div> <span style="color:rgb(86, 156, 214);">IMAGETYPE</span> "png"<br></div><div> DEFRESOLUTION <span style="color:rgb(181, 206, 168);">96</span><br></div><div> RESOLUTION <span style="color:rgb(181, 206, 168);">96</span><br></div><div> <span style="color:rgb(86, 156, 214);">CONFIG</span> "MS_ERRORFILE" "infolayer.log"<br></div><div> <span style="color:rgb(86, 156, 214);">DEBUG</span> <span style="color:rgb(181, 206, 168);">0</span><br></div><div> <span style="color:rgb(86, 156, 214);">MAXSIZE</span> <span style="color:rgb(181, 206, 168);">10000</span><br></div><div> <span style="color:rgb(220, 220, 170);">OUTPUTFORMAT</span><br></div><div> <span style="color:rgb(86, 156, 214);">NAME</span> "png"<br></div><div> <span style="color:rgb(86, 156, 214);">DRIVER</span> <span style="color:rgb(156, 220, 254);">AGG</span>/<span style="color:rgb(156, 220, 254);">PNG</span><br></div><div> <span style="color:rgb(86, 156, 214);">MIMETYPE</span> "image/png"<br></div><div> <span style="color:rgb(86, 156, 214);">IMAGEMODE</span> <span style="color:rgb(156, 220, 254);">RGB</span><br></div><div> <span style="color:rgb(86, 156, 214);">EXTENSION</span> "png"<br></div><div> <span style="color:rgb(86, 156, 214);">FORMATOPTION</span> "QUANTIZE_FORCE=on"<br></div><div> <span style="color:rgb(220, 220, 170);">END</span><br></div><div><br></div><div> <span style="color:rgb(220, 220, 170);">OUTPUTFORMAT</span><br></div><div> <span style="color:rgb(86, 156, 214);">NAME</span> "geojson"<br></div><div> <span style="color:rgb(86, 156, 214);">DRIVER</span> "OGR/GEOJSON"<br></div><div> <span style="color:rgb(86, 156, 214);">MIMETYPE</span> "application/json; subtype=geojson; charset=utf-8"<br></div><div> <span style="color:rgb(86, 156, 214);">FORMATOPTION</span> "STORAGE=filesystem"<br></div><div> <span style="color:rgb(86, 156, 214);">FORMATOPTION</span> "FORM=SIMPLE"<br></div><div> <span style="color:rgb(220, 220, 170);">END</span><br></div><div><br></div><div> <span style="color:rgb(220, 220, 170);">WEB</span><br></div><div> <span style="color:rgb(220, 220, 170);">METADATA</span><br></div><div> "<span style="color:rgb(206, 145, 120);">wfs_title</span>" "infolayer"<br></div><div> "<span style="color:rgb(206, 145, 120);">wfs_enable_request</span>" "*"<br></div><div> "<span style="color:rgb(206, 145, 120);">wfs_encoding</span>" "UTF-8"<br></div><div> "<span style="color:rgb(206, 145, 120);">wms_title</span>" "infolayer"<br></div><div> "<span style="color:rgb(206, 145, 120);">wms_encoding</span>" "UTF-8"<br></div><div> "<span style="color:rgb(206, 145, 120);">wms_onlineresource</span>" "/mapserv?map=/app/gis/infokihid/infolayer.map&"<br></div><div> "<span style="color:rgb(206, 145, 120);">wfs_onlineresource</span>" "/mapserv?map=/app/gis/infokihid/infolayer.map&"<br></div><div> "<span style="color:rgb(206, 145, 120);">ows_srs</span>" "EPSG:3301 EPSG:3857 EPSG:4326"<br></div><div> "<span style="color:rgb(206, 145, 120);">ows_enable_request</span>" "*"<br></div><div> "<span style="color:rgb(206, 145, 120);">wfs_getfeature_formatlist</span>" "gml,geojson"<br></div><div> "<span style="color:rgb(206, 145, 120);">wms_feature_info_mime_type</span>" "application/json,application/json; subtype=geojson,application/vnd.ogc.gml,text/plain"<br></div><div> <span style="color:rgb(220, 220, 170);">END</span><br></div><div> <span style="color:rgb(220, 220, 170);">END</span><br></div><div><br></div><div> <span style="color:rgb(220, 220, 170);">PROJECTION</span><br></div><div> "init=epsg:3301"<br></div><div> <span style="color:rgb(220, 220, 170);">END</span><br></div><div><br></div><div><div style="line-height:19px;"><div><span style="color:rgb(220, 220, 170);">LAYER</span><br></div><div> <span style="color:rgb(86, 156, 214);">TEMPLATE</span> "dummy"<br></div><div> <span style="color:rgb(86, 156, 214);">NAME</span> "omavalitsus" <br></div><div> <span style="color:rgb(86, 156, 214);">STATUS</span> <span style="color:rgb(156, 220, 254);">off</span><br></div><div> <span style="color:rgb(86, 156, 214);">TYPE</span> <span style="color:rgb(156, 220, 254);">polygon</span><br></div><div> <span style="color:rgb(86, 156, 214);">CONNECTIONTYPE</span> <span style="color:rgb(156, 220, 254);">POSTGIS</span><br></div><div> <span style="color:rgb(86, 156, 214);">INCLUDE</span> "postgis.inc"<br></div><div> <span style="color:rgb(86, 156, 214);">DATA</span> "geom from omavalitsus using unique gid using srid=3301" <br></div><div> <span style="color:rgb(86, 156, 214);">LABELITEM</span> "nimetus"<br></div><div> <span style="color:rgb(86, 156, 214);">TYPE</span> <span style="color:rgb(156, 220, 254);">polygon</span><br></div><div> <span style="color:rgb(86, 156, 214);">MAXSCALEDENOM</span> <span style="color:rgb(181, 206, 168);">2000000</span><br></div><div><br></div><div> <span style="color:rgb(220, 220, 170);">METADATA</span><br></div><div> "gml_msGeometry_type" "polygon"<br></div><div> "<span style="color:rgb(206, 145, 120);">wfs_title</span>" "omavalitsus"<br></div><div> "<span style="color:rgb(206, 145, 120);">wms_title</span>" "omavalitsus"<br></div><div> "<span style="color:rgb(206, 145, 120);">wfs_srs</span>" "EPSG:3301"<br></div><div> "<span style="color:rgb(206, 145, 120);">wms_srs</span>" "EPSG:3301"<br></div><div> "<span style="color:rgb(206, 145, 120);">wms_extent</span>" "355000 6360000 754000 6660000"<br></div><div> "<span style="color:rgb(206, 145, 120);">gml_include_items</span>" "all"<br></div><div> "ows_include_items" "all"<br></div><div> "<span style="color:rgb(206, 145, 120);">wfs_srs</span>" "EPSG:3301"<br></div><div> "<span style="color:rgb(206, 145, 120);">gml_featureid</span>" "id"<br></div><div> "ows_featureid" "id"<br></div><div> <span style="color:rgb(220, 220, 170);">END</span><br></div><div><br></div><div> <span style="color:rgb(220, 220, 170);">CLASS</span><br></div><div> <span style="color:rgb(86, 156, 214);">NAME</span> omavalitsus<br></div><div> <span style="color:rgb(220, 220, 170);">STYLE</span><br></div><div> <span style="color:rgb(86, 156, 214);">COLOR</span> <span style="color:rgb(181, 206, 168);">234</span> <span style="color:rgb(181, 206, 168);">123</span> <span style="color:rgb(181, 206, 168);">43</span><br></div><div> <span style="color:rgb(86, 156, 214);">OPACITY</span> <span style="color:rgb(181, 206, 168);">15</span> <br></div><div> <span style="color:rgb(220, 220, 170);">END</span><br></div><div> <span style="color:rgb(220, 220, 170);">STYLE</span><br></div><div> <span style="color:rgb(86, 156, 214);">WIDTH</span> <span style="color:rgb(181, 206, 168);">2</span><br></div><div> <span style="color:rgb(86, 156, 214);">OUTLINECOLOR</span> <span style="color:rgb(181, 206, 168);">80</span> <span style="color:rgb(181, 206, 168);">80</span> <span style="color:rgb(181, 206, 168);">80</span><br></div><div> <span style="color:rgb(86, 156, 214);">OPACITY</span> <span style="color:rgb(181, 206, 168);">15</span><br></div><div> <span style="color:rgb(220, 220, 170);">END</span><br></div><div> <span style="color:rgb(220, 220, 170);">END</span><br></div><div><span style="color:rgb(220, 220, 170);">END</span><br></div></div></div></div><div><br></div><div><br></div><div>If we do a query without a bbox and want all the features, it works.<br></div><div><br></div><div>Example: <br></div><div><a href="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">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</a><br></div><div><br></div><div>WFS version 1.3.0 and 2.0.0<br></div><div>But if we add a bbox in OGC filter format or bbox, then it does not work anymore:<br></div><div><br></div><div>Example:<br></div><div><br></div><div><a href="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">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</a><br></div><div><br></div><div>OR OGC<br></div><div><br></div><div><a href="https://URL/mapserv?map=/app/gis/infokihid/infolayers_other.map&SERVICE=WFS&Version=2.0.0&REQUEST=GetFeature&typeNames={{LAYER}}&Filter=">https://URL/mapserv?map=/app/gis/infokihid/infolayers_other.map&SERVICE=WFS&Version=2.0.0&REQUEST=GetFeature&typeNames={{LAYER}}&Filter=</a><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><br></div><div><br></div><div><br></div><div>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.<br></div><div><br></div><div>SQL form the database where you can see the geom query part where transformation of geom contains/intersect etc happens, is is wrong:<br></div></div><div><div><br></div><pre class="qt-gmail-code-java" style="margin-top:0px;margin-bottom:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;max-height:30em;overflow-x:auto;overflow-y:auto;white-space:pre-wrap;font-size:12px;background-color:rgb(244, 245, 247);"><span style="color:rgb(23, 43, 77);">select </span><span class="colour" style="color:rgb(0, 145, 0);"><<FIELDS>></span><span class="colour" style="color:rgb(23, 43, 77);">,ST_AsBinary((</span><span class="qt-gmail-code-quote" style="color:rgb(0, 145, 0);">"geom"</span><span class="colour" style="color:rgb(23, 43, 77);">),</span><span class="qt-gmail-code-quote" style="color:rgb(0, 145, 0);">'NDR'</span><span class="colour" style="color:rgb(23, 43, 77);">) as geom,</span><span class="qt-gmail-code-quote" style="color:rgb(0, 145, 0);">"gid"</span><span class="colour" style="color:rgb(23, 43, 77);">::text from (select * from LAYER where kehtiv_alates < now() and (kehtiv_kuni > now() OR kehtiv_kuni is </span><span class="qt-gmail-code-keyword" style="color:rgb(145, 0, 145);">null</span><span class="colour" style="color:rgb(23, 43, 77);">)) as subquery where (</span><span class="qt-gmail-code-quote" style="color:rgb(0, 145, 0);">"geom"</span><span class="colour" style="color:rgb(23, 43, 77);"> && ST_GeomFromText(</span><span class="qt-gmail-code-quote" style="color:rgb(0, 145, 0);">'POLYGON((296500 6249000,296500 6761000,808500 6761000,808500 6249000,296500 6249000))'</span><span class="colour" style="color:rgb(23, 43, 77);">,3301)) AND ST_Distance(</span><span class="qt-gmail-code-quote" style="color:rgb(0, 145, 0);">"geom"</span><span class="colour" style="color:rgb(23, 43, 77);">, ST_GeomFromText(</span><span class="qt-gmail-code-quote" style="color:rgb(0, 145, 0);">'POLYGON((296500 6249000,296500 6761000,808500 6761000,808500 6249000,296500 6249000))'</span><span class="colour" style="color:rgb(23, 43, 77);">,3301)) = 0 and (st_contains(geom,ST_GeomFromText(</span><span class="qt-gmail-code-quote" style="color:rgb(0, 145, 0);">'POINT (25.0353080000000006 59.3267499999999970)'</span><span class="colour" style="color:rgb(23, 43, 77);">,3301)) = TRUE)</span><br></pre><div><br></div><div>The contains should be:<br></div></div><div><br></div><div><pre class="qt-gmail-code-java" style="margin-top:0px;margin-bottom:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;max-height:30em;overflow-x:auto;overflow-y:auto;white-space:pre-wrap;color:rgb(23, 43, 77);font-size:12px;background-color:rgb(244, 245, 247);">(st_contains(geom,ST_TRANSFORM(ST_GeomFromText(<span class="qt-gmail-code-quote" style="color:rgb(0, 145, 0);">'POINT (25.0353080000000006 59.3267499999999970)'</span>,4326),3301))<br></pre><div><br></div><div>One way to get a result is using WFS 1.0.0. It returns the result in EPSG:3301 but is correct.<br></div><div><br></div><div><a href="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">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</a><br></div><div><br></div><div>I have tried different OGC filters, but they all act the same when trying to do stuff in EPSG:4326.<br></div></div><div>Tried different WFS versions, coordinate order in OGC filter/manual bbox etc.<br></div><div>Even with the OGC filter being in EPSG:3301, but request in srs 4326.<br></div><div><div>Have not yet managed to get it.<br></div><div><br></div><div>So my questions are:<br></div><ol><li>Is there something wrong in our MAP/LAYER files? Do we need to change or add something?<br></li><li>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?<br></li></ol><div><br></div><div>Cheers,<br></div><div>Sander<br></div></div></div><div>_______________________________________________<br></div><div>MapServer-users mailing list<br></div><div><a href="mailto:MapServer-users@lists.osgeo.org">MapServer-users@lists.osgeo.org</a><br></div><div><a href="https://lists.osgeo.org/mailman/listinfo/mapserver-users">https://lists.osgeo.org/mailman/listinfo/mapserver-users</a><br></div><div><br></div></blockquote><div><br></div></body></html>