<div dir="ltr">Hi there!<br><br>We have been running into an issue with WFS, EPSG:4326 and a filter (namely bbox) query.<br>We have been using MapServer for years and the current version we have is 7.6.4.<br>WMS and WFS are both enabled and WFS is configured for gml and geojson.<br><br>Our MapServer's main output is in EPSG:3301 projection and most of our clients use it like that.<br>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><br>Our MapServer can also function in the regular 4326 and 3857 in WMS and WFS.<br>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><br><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.<br>The response should be in 4326, but the transformation does not work. (Obvious from the database SQL).<br>Everything works in EPSG:3301.<br><br>I have obscured some URL and Layer names. <br>Our map file with a sample layer looks like this:<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></div><br><div>  <span style="color:rgb(220,220,170)">LEGEND</span></div><div>    <span style="color:rgb(220,220,170)">LABEL</span></div><div>      <span style="color:rgb(86,156,214)">TYPE</span> <span style="color:rgb(156,220,254)">truetype</span></div><div>      <span style="color:rgb(86,156,214)">FONT</span> "Arial"</div><div>      <span style="color:rgb(86,156,214)">SIZE</span> <span style="color:rgb(181,206,168)">10</span></div><div>      <span style="color:rgb(86,156,214)">POSITION</span> <span style="color:rgb(156,220,254)">AUTO</span></div><div>    <span style="color:rgb(220,220,170)">END</span></div><div>  <span style="color:rgb(220,220,170)">END</span></div><br><div>  <span style="color:rgb(86,156,214)">NAME</span>           "<%NAME%>_keskkond"</div><div>  <span style="color:rgb(86,156,214)">STATUS</span>         <span style="color:rgb(156,220,254)">ON</span></div><div>  <span style="color:rgb(86,156,214)">EXTENT</span>         <%= node['mapserver']['extent'] %></div><div>  FONTSET        "<%= URL %>/fonts/current/fonts.list"</div><div>  <span style="color:rgb(86,156,214)">IMAGETYPE</span>      "png"</div><div>  DEFRESOLUTION <span style="color:rgb(181,206,168)">96</span></div><div>  RESOLUTION    <span style="color:rgb(181,206,168)">96</span></div><div>  <span style="color:rgb(86,156,214)">CONFIG</span> "MS_ERRORFILE" "infolayer.log"</div><div>  <span style="color:rgb(86,156,214)">DEBUG</span> <span style="color:rgb(181,206,168)">0</span></div><div>  <span style="color:rgb(86,156,214)">MAXSIZE</span> <span style="color:rgb(181,206,168)">10000</span></div><div>  <span style="color:rgb(220,220,170)">OUTPUTFORMAT</span></div><div>    <span style="color:rgb(86,156,214)">NAME</span> "png"</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></div><div>    <span style="color:rgb(86,156,214)">MIMETYPE</span> "image/png"</div><div>    <span style="color:rgb(86,156,214)">IMAGEMODE</span> <span style="color:rgb(156,220,254)">RGB</span></div><div>    <span style="color:rgb(86,156,214)">EXTENSION</span> "png"</div><div>    <span style="color:rgb(86,156,214)">FORMATOPTION</span> "QUANTIZE_FORCE=on"</div><div>  <span style="color:rgb(220,220,170)">END</span></div><br><div>  <span style="color:rgb(220,220,170)">OUTPUTFORMAT</span></div><div>    <span style="color:rgb(86,156,214)">NAME</span> "geojson"</div><div>    <span style="color:rgb(86,156,214)">DRIVER</span> "OGR/GEOJSON"</div><div>    <span style="color:rgb(86,156,214)">MIMETYPE</span> "application/json; subtype=geojson; charset=utf-8"</div><div>    <span style="color:rgb(86,156,214)">FORMATOPTION</span> "STORAGE=filesystem"</div><div>    <span style="color:rgb(86,156,214)">FORMATOPTION</span> "FORM=SIMPLE"</div><div>  <span style="color:rgb(220,220,170)">END</span></div><br><div>  <span style="color:rgb(220,220,170)">WEB</span></div><div>      <span style="color:rgb(220,220,170)">METADATA</span></div><div>        "<span style="color:rgb(206,145,120)">wfs_title</span>"                     "infolayer"</div><div>        "<span style="color:rgb(206,145,120)">wfs_enable_request</span>"            "*"</div><div>        "<span style="color:rgb(206,145,120)">wfs_encoding</span>"                  "UTF-8"</div><div>        "<span style="color:rgb(206,145,120)">wms_title</span>"                     "infolayer"</div><div>        "<span style="color:rgb(206,145,120)">wms_encoding</span>"                  "UTF-8"</div><div>        "<span style="color:rgb(206,145,120)">wms_onlineresource</span>"            "/mapserv?map=/app/gis/infokihid/infolayer.map&"</div><div>        "<span style="color:rgb(206,145,120)">wfs_onlineresource</span>"            "/mapserv?map=/app/gis/infokihid/infolayer.map&"</div><div>        "<span style="color:rgb(206,145,120)">ows_srs</span>"                       "EPSG:3301 EPSG:3857 EPSG:4326"</div><div>        "<span style="color:rgb(206,145,120)">ows_enable_request</span>"            "*"</div><div>        "<span style="color:rgb(206,145,120)">wfs_getfeature_formatlist</span>"     "gml,geojson"</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"</div><div>      <span style="color:rgb(220,220,170)">END</span></div><div>  <span style="color:rgb(220,220,170)">END</span></div><br><div>  <span style="color:rgb(220,220,170)">PROJECTION</span></div><div>      "init=epsg:3301"</div><div>  <span style="color:rgb(220,220,170)">END</span></div><br><div>
<div style="line-height:19px"><div><span style="color:rgb(220,220,170)">LAYER</span></div><div>  <span style="color:rgb(86,156,214)">TEMPLATE</span> "dummy"</div><div>    <span style="color:rgb(86,156,214)">NAME</span>                "omavalitsus"     </div><div>    <span style="color:rgb(86,156,214)">STATUS</span>              <span style="color:rgb(156,220,254)">off</span></div><div>    <span style="color:rgb(86,156,214)">TYPE</span>                <span style="color:rgb(156,220,254)">polygon</span></div><div>    <span style="color:rgb(86,156,214)">CONNECTIONTYPE</span>      <span style="color:rgb(156,220,254)">POSTGIS</span></div><div>    <span style="color:rgb(86,156,214)">INCLUDE</span>             "postgis.inc"</div><div>    <span style="color:rgb(86,156,214)">DATA</span>                "geom from omavalitsus using unique gid using srid=3301"     </div><div>    <span style="color:rgb(86,156,214)">LABELITEM</span>           "nimetus"</div><div>    <span style="color:rgb(86,156,214)">TYPE</span>                <span style="color:rgb(156,220,254)">polygon</span></div><div>    <span style="color:rgb(86,156,214)">MAXSCALEDENOM</span>       <span style="color:rgb(181,206,168)">2000000</span></div><br><div>    <span style="color:rgb(220,220,170)">METADATA</span></div><div>        "gml_msGeometry_type"   "polygon"</div><div>        "<span style="color:rgb(206,145,120)">wfs_title</span>"             "omavalitsus"</div><div>        "<span style="color:rgb(206,145,120)">wms_title</span>"             "omavalitsus"</div><div>        "<span style="color:rgb(206,145,120)">wfs_srs</span>"               "EPSG:3301"</div><div>        "<span style="color:rgb(206,145,120)">wms_srs</span>"               "EPSG:3301"</div><div>        "<span style="color:rgb(206,145,120)">wms_extent</span>"            "355000 6360000 754000 6660000"</div><div>        "<span style="color:rgb(206,145,120)">gml_include_items</span>"     "all"</div><div>        "ows_include_items"     "all"</div><div>        "<span style="color:rgb(206,145,120)">wfs_srs</span>"               "EPSG:3301"</div><div>        "<span style="color:rgb(206,145,120)">gml_featureid</span>"         "id"</div><div>        "ows_featureid"         "id"</div><div>    <span style="color:rgb(220,220,170)">END</span></div><br><div>    <span style="color:rgb(220,220,170)">CLASS</span></div><div>        <span style="color:rgb(86,156,214)">NAME</span> omavalitsus </div><div>        <span style="color:rgb(220,220,170)">STYLE</span></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></div><div>            <span style="color:rgb(86,156,214)">OPACITY</span> <span style="color:rgb(181,206,168)">15</span>  </div><div>        <span style="color:rgb(220,220,170)">END</span></div><div>        <span style="color:rgb(220,220,170)">STYLE</span></div><div>            <span style="color:rgb(86,156,214)">WIDTH</span> <span style="color:rgb(181,206,168)">2</span></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></div><div>            <span style="color:rgb(86,156,214)">OPACITY</span> <span style="color:rgb(181,206,168)">15</span></div><div>        <span style="color:rgb(220,220,170)">END</span></div><div>    <span style="color:rgb(220,220,170)">END</span></div><div><span style="color:rgb(220,220,170)">END</span></div></div>

</div></div><br><br>If we do a query without a bbox and want all the features, it works.<br><br>Example: <br><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><br>WFS version 1.3.0 and 2.0.0<br>But if we add a bbox in OGC filter format or bbox, then it does not work anymore:<br><br>Example:<br><br><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><br>OR OGC<br><br><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><br><br>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><br>SQL form the database where you can see the geom query part where transformation of geom contains/intersect etc happens, is is wrong:</div><div><br><pre class="gmail-code-java" style="margin-top:0px;margin-bottom:0px;padding:0px;max-height:30em;overflow:auto;white-space:pre-wrap;font-size:12px;background-color:rgb(244,245,247)"><span style="color:rgb(23,43,77)">select </span><font color="#009100"><<FIELDS>></font><font color="#172b4d">,ST_AsBinary((</font><span class="gmail-code-quote" style="color:rgb(0,145,0)">"geom"</span><font color="#172b4d">),</font><span class="gmail-code-quote" style="color:rgb(0,145,0)">'NDR'</span><font color="#172b4d">) as geom,</font><span class="gmail-code-quote" style="color:rgb(0,145,0)">"gid"</span><font color="#172b4d">::text from (select * from LAYER where kehtiv_alates < now() and (kehtiv_kuni > now() OR kehtiv_kuni is </font><span class="gmail-code-keyword" style="color:rgb(145,0,145)">null</span><font color="#172b4d">)) as subquery where (</font><span class="gmail-code-quote" style="color:rgb(0,145,0)">"geom"</span><font color="#172b4d"> && ST_GeomFromText(</font><span class="gmail-code-quote" style="color:rgb(0,145,0)">'POLYGON((296500 6249000,296500 6761000,808500 6761000,808500 6249000,296500 6249000))'</span><font color="#172b4d">,3301)) AND ST_Distance(</font><span class="gmail-code-quote" style="color:rgb(0,145,0)">"geom"</span><font color="#172b4d">, ST_GeomFromText(</font><span class="gmail-code-quote" style="color:rgb(0,145,0)">'POLYGON((296500 6249000,296500 6761000,808500 6761000,808500 6249000,296500 6249000))'</span><font color="#172b4d">,3301)) = 0 and (st_contains(geom,ST_GeomFromText(</font><span class="gmail-code-quote" style="color:rgb(0,145,0)">'POINT (25.0353080000000006 59.3267499999999970)'</span><font color="#172b4d">,3301)) = TRUE)</font></pre><br>The contains should be:</div><div><br></div><div><pre class="gmail-code-java" style="margin-top:0px;margin-bottom:0px;padding:0px;max-height:30em;overflow: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="gmail-code-quote" style="color:rgb(0,145,0)">'POINT (25.0353080000000006 59.3267499999999970)'</span>,4326),3301))</pre><br>One way to get a result is using WFS 1.0.0. It returns the result in EPSG:3301 but is correct.<br><br><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><br>I have tried different OGC filters, but they all act the same when trying to do stuff in EPSG:4326.</div><div>Tried different WFS versions, coordinate order in OGC filter/manual bbox etc.</div><div>Even with the OGC filter being in EPSG:3301, but request in srs 4326.</div><div>Have not yet managed to get it.<br><br>So my questions are:<br><ol><li>Is there something wrong in our MAP/LAYER files? Do we need to change or add something?</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?</li></ol><br>Cheers,<br>Sander</div></div>