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

Sander Pukk sander.pukk at gmail.com
Thu Nov 25 04:20:29 PST 2021


Hei!

Thanks, guys!

I tried all the different coordinate orders ( with the good old axis
orientation in mind), but I was missing the layer PROJECTION parameter like
Seth suggested.
It seems it is a combination of three things here:

   - PROJECTION missing in LAYER
   - Coordinate order in the request
   - Wfs_srs needs to be there like it was, but the main one is only
   needed. 3301 in my case

All in all, got it working, big thanks :) !

Cheers,
Sander



On Thu, Nov 25, 2021 at 11:12 AM Rahkonen Jukka (MML) <
jukka.rahkonen at maanmittauslaitos.fi> wrote:

> (resending to the list without the original mail, list has rather (too?)
> strict size limits, 40 KB)
>
>
>
> Hi,
>
>
>
> Perhaps you fell into the infamous axis order trap. With WFS 1.1.x and 2.0
> the coordinates of EPSG:4326 most be in latitude-longiture oreder. I
> modified you mapfile a bit for my test data that are in EPSG:3067, and this
> request
>
> http://localhost:8060/cgi-bin/mapserv.exe?map=c:/ms4w_data/wfstest.map&service=WFS&version=2.0.0&request=GetFeature&TypeNames=ms:testi_virolaisille&BBOX=60.1870614692821,24.9810192523929,60.2794267964524,25.1561900521738,urn:ogc:def:crs:EPSG::4326
>
> finds buildings from the database.  The SQL that Mapserver generates is:
>
>
>
> [Thu Nov 25 10:23:51 2021].654000 msPostGISLayerWhichShapes query: SELECT
> "fid"::text,"id"::text,"mtk_id"::text,"sijaintitarkkuus"::text,"aineistolahde"::text,"alkupvm"::text,"kohdeluokka"::text,"korkeustarkkuus"::text,"kayttotarkoitus"::text,"kerrosluku"::text,"pohjankorkeus"::text,"korkeusarvo"::text,ST_AsBinary(("geom"),'NDR')
> as geom,"fid"::text FROM rakennus WHERE "geom" &&
> ST_GeomFromText('POLYGON((388034.000000002
> 6673671.81841385,388034.000000002 6684239.6439825,398034
> 6684239.6439825,398034 6673671.81841385,388034.000000002
> 6673671.81841385))',3067)
>
>
>
> Notice that the re-projected polygon seems to be the envelope of the
> rotated bbox from the transformation and therefore it is bigger than the
> polygon that would be achieved by connecting the projected corner points as
> this test with gdaltranform shows.
>
>
>
> gdaltransform -s_srs epsg:4326 -t_srs epsg:3067
>
> 24.9810192523929 60.1870614692821
>
> 388034.000000002 6673956 0
>
> 25.1561900521738 60.279426796452
>
> 398033.999999999 6683955.99999996 0
>
>
>
> I add also my mapfile, I apologize that it is just a fast modification of
> some old mapfile and is not the cleanest possible.
>
>
>
> MAP
>
>
>
>     CONFIG "MS_ERRORFILE" "/ms4w_data/ms_error.txt"
>
>     EXTENT 19970 6597278 749676 7785300
>
>     PROJECTION
>
>     "init=epsg:3067"
>
>     END
>
>
>
>     OUTPUTFORMAT
>
>         NAME "OGRGML"
>
>         DRIVER "OGR/GML"
>
>         FORMATOPTION "STORAGE=stream"
>
>         FORMATOPTION "LCO:COORDINATE_PRECISION=10"
>
>       END
>
>
>
>       OUTPUTFORMAT
>
>           NAME "GeoJSON"
>
>           DRIVER "OGR/GEOJSON"
>
>           MIMETYPE "application/json; subtype=geojson; charset=utf-8"
>
>           FORMATOPTION "STORAGE=stream"
>
>           FORMATOPTION "FORM=SIMPLE"
>
>           FORMATOPTION "LCO:COORDINATE_PRECISION=10"
>
>       END
>
>
>
>
>
>
>
>     LAYER
>
>         NAME "testi_virolaisille"
>
>         STATUS ON
>
>         DEBUG 10
>
>         TYPE polygon
>
>
>
>         PROJECTION
>
>                           "init=epsg:3067"
>
>         END
>
>
>
>         METADATA
>
>           "ows_title" "viro_testi"
>
>           "ows_abstract" "viro_testi"
>
>           "wfs_getfeature_formatlist" "GeoJSON"
>
>        #   "gml_featureid" "id"
>
>           "gml_include_items" "all"
>
>        #   "gml_types" "auto"
>
>           "wfs_srs"  "EPSG:3067 EPSG:3857 EPSG:4326"
>
>         END
>
>         CONNECTIONTYPE POSTGIS
>
>         CONNECTION "host=localhost port=5432 dbname= user= password= "
>
>         DATA "geom from rakennus using SRID=3067"
>
>         CLASS
>
>             STYLE
>
>                 COLOR 255 0 0
>
>             END
>
>         END
>
>     END
>
>     WEB
>
>         MINSCALE 10
>
>         MAXSCALE 1550000
>
>         METADATA
>
>             "wms_title" "wfs_test"
>
>             "wfs_onlineresource"
> http://localhost:8060/cgi-bin/mapserv.exe?map=c:\ms4w_data\wfstest.map
>
>             "wms_srs" "EPSG:4326 EPSG:900913 EPSG:3857 EPSG:31370"
>
>             "wms_enable_request" "*"
>
>             "wms_feature_info_mime_type" "text/html"
>
>             "wms_format" "image/png"
>
>             "wfs_title" "wfs_test"
>
>             "wfs_srs" "EPSG:3067 EPSG:3857 EPSG:4326"
>
>             "wfs_enable_request" "*"
>
>             "wfs_precision" "10"
>
>             #"wfs_feature_info_mime_type" "text/html"
>
>         END
>
>
>
>     END
>
> END
>
>
>
> -Jukka Rahkonen-
> _______________________________________________
> 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/95861543/attachment-0001.html>


More information about the MapServer-users mailing list