Issue in using MapServer WFS Filter

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Issue in using MapServer WFS Filter

Kajod Sharma
Hi,

Greetings!

I hope this is a right platform to discuss my query regarding FILTER applied on MapServer WFS.

I'm new in this area and exploring some features of MapServer. I want to use GetFeature request of WFS to get features applied on any location on map. I'm using "MapServer version 7.0.4 (MS4W 3.2.1)" and trying to apply filter "Contains" for it.

I can see two problems when it applies Filter query on PostGIS:

1. It looks it adds an extra default geospatial filter in it while making a query to PostGIS. This default spatial filter is not stopping to return any result from PostGIS. Is there any way to exclude this default filter?
2. It seems Contains coordinates are not transformed properly according to SRS of data in PostGIS.

I've tries with different projection in map file and request message with no success.

Supporting data to give your input on my queries:

WFS request
*************************
Formatted Version:

http://localhost/cgi-bin/mapserv.exe?
service=WFS&
map=C:/Data/MapServerWFSSample.map&
request=GetFeature&
version=2.0.0&
typeName=SampleLayer&
FILTER=<Filter xmlns="http://www.opengis.net/ogc" xmlns:gml="http://www.opengis.net/gml" xmlns:ms="http://mapserver.gis.umn.edu/mapserver">
  <Contains>
    <PropertyName>wkb_Geometry</PropertyName>
    <gml:Point srsName="urn:ogc:def:crs:EPSG::4326">
      <gml:coordinates>0.112034,53.567972</gml:coordinates>
    </gml:Point>
  </Contains>
</Filter>

*************************

PostGIS query [Could see in log file]:
*************************
msPostGISLayerWhichShapes query: select "Attribute1","Attribute2","Attribute3",encode(ST_AsBinary(ST_Force2D("wkb_geometry"),'NDR'),'hex') as geom from SampleGeoDataTable where wkb_geometry && ST_GeomFromText('POLYGON((-0.999462804873474 -1.00102606014116,-0.999462804873474 -1.00102606014116,-0.999462804873474 -1.00102606014116,-0.999462804873474 -1.00102606014116,-0.999462804873474 -1.00102606014116))',find_srid('','SampleGeoDataTable','wkb_geometry')) and (st_contains(wkb_geometry,ST_GeomFromText('POINT (7853690.3631838141000000 -5506204.5232773330000000)')) = TRUE)
*************************

Similar WFS query to GeoServer works perfectly.

It would be very helpful if someone can help me on it. Thanks a lot in advance.

Map File looks like:

**************************************************
MAP
  NAME "Sample_WMS"
  CONFIG "PROJ_LIB" "C:\ms4w\proj\nad"
  CONFIG "MS_ERRORFILE" "C:/Data/ms_tmp/ms_error.txt"
  CONFIG "CPL_DEBUG" "ON"
  CONFIG "PROJ_DEBUG" "ON"
  STATUS ON
  PROJECTION
    "init=epsg:27700"
  END 
 
  WEB
   IMAGEPATH "C:/Data/ms_tmp/"
   IMAGEURL "/ms_tmp/"
   METADATA 
    "wfs_enable_request" "*"
    "wfs_title"         "My Global Map WFS Server"
    "wfs_srs"           "EPSG:4326 EPSG:900913 EPSG:27700"
    "wfs_boundingbox"    "EPSG:27700 749.099975585938 -90036.5 660460.875 1227306.5"     
   END
  END
 
  LAYER
   NAME "SampleLayer"
   STATUS DEFAULT
   TYPE POLYGON
   PROJECTION
    "init=epsg:27700"
   END  
   CONNECTIONTYPE POSTGIS
   CONNECTION "host=localhost port=5432 dbname=SampleGeoDataTable user=postgres password=hahaha"
   DATA "wkb_geometry from SampleLayer"
   CLASS
     STYLE
      COLOR      0 100 255
      OUTLINECOLOR 0 0 0
     END
   END
 
   METADATA     
    "wfs_enable_request" "*"
    "wfs_title"         "Sample WFS"
    "wfs_srs"           "EPSG:27700 EPSG:4326 EPSG:900913"
    "wfs_boundingbox"    "EPSG:27700 749.099975585938 -90036.5 660460.875 1227306.5"
    "gml_include_items" "all"
   END 
  END   
END

**************************************************

Regards,
Kajod

_______________________________________________
mapserver-users mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/mapserver-users
Reply | Threaded
Open this post in threaded view
|

Re: Issue in using MapServer WFS Filter

Steve.Toutant
Try adding &srsName="EPSG:4326" as a parameter
typeName=SampleLayer&srsName=EPSG:4326



De :        Kajod Sharma <[hidden email]>
A :        "[hidden email]" <[hidden email]>
Date :        2017-04-26 09:43
Objet :        [mapserver-users] Issue in using MapServer WFS Filter
Envoyé par :        "mapserver-users" <[hidden email]>




Hi,

Greetings!

I hope this is a right platform to discuss my query regarding FILTER applied on MapServer WFS.

I'm new in this area and exploring some features of MapServer. I want to use GetFeature request of WFS to get features applied on any location on map. I'm using "MapServer version 7.0.4 (MS4W 3.2.1)" and trying to apply filter "Contains" for it.

I can see two problems when it applies Filter query on PostGIS:

1. It looks it adds an extra default geospatial filter in it while making a query to PostGIS. This default spatial filter is not stopping to return any result from PostGIS. Is there any way to exclude this default filter?
2. It seems Contains coordinates are not transformed properly according to SRS of data in PostGIS.

I've tries with different projection in map file and request message with no success.

Supporting data to give your input on my queries:

WFS request
*************************
Formatted Version:

http://localhost/cgi-bin/mapserv.exe?
service=WFS&
map=C:/Data/MapServerWFSSample.map&
request=GetFeature&
version=2.0.0&
typeName=SampleLayer&
FILTER=<Filter xmlns="
http://www.opengis.net/ogc" xmlns:gml="http://www.opengis.net/gml" xmlns:ms="http://mapserver.gis.umn.edu/mapserver">
 <Contains>
   <PropertyName>wkb_Geometry</PropertyName>
   <gml:Point srsName="urn:ogc:def:crs:EPSG::4326">
     <gml:coordinates>0.112034,53.567972</gml:coordinates>
   </gml:Point>
 </Contains>
</Filter>

*************************

PostGIS query [Could see in log file]:
*************************
msPostGISLayerWhichShapes query: select "Attribute1","Attribute2","Attribute3",encode(ST_AsBinary(ST_Force2D("wkb_geometry"),'NDR'),'hex') as geom from SampleGeoDataTable where wkb_geometry && ST_GeomFromText('POLYGON((-0.999462804873474 -1.00102606014116,-0.999462804873474 -1.00102606014116,-0.999462804873474 -1.00102606014116,-0.999462804873474 -1.00102606014116,-0.999462804873474 -1.00102606014116))',find_srid('','SampleGeoDataTable','wkb_geometry')) and (st_contains(wkb_geometry,ST_GeomFromText('POINT (7853690.3631838141000000 -5506204.5232773330000000)')) = TRUE)
*************************

Similar WFS query to GeoServer works perfectly.

It would be very helpful if someone can help me on it. Thanks a lot in advance.

Map File looks like:

**************************************************
MAP
 NAME "Sample_WMS"
 CONFIG "PROJ_LIB" "C:\ms4w\proj\nad"
 CONFIG "MS_ERRORFILE" "C:/Data/ms_tmp/ms_error.txt"
 CONFIG "CPL_DEBUG" "ON"
 CONFIG "PROJ_DEBUG" "ON"
 STATUS ON
 PROJECTION
   "init=epsg:27700"
 END  
 
 WEB
  IMAGEPATH "C:/Data/ms_tmp/"
  IMAGEURL "/ms_tmp/"
  METADATA  
   "wfs_enable_request" "*"
   "wfs_title"         "My Global Map WFS Server"
   "wfs_srs"           "EPSG:4326 EPSG:900913 EPSG:27700"
   "wfs_boundingbox"    "EPSG:27700 749.099975585938 -90036.5 660460.875 1227306.5"    
  END
 END
 
 LAYER
  NAME "SampleLayer"
  STATUS DEFAULT
  TYPE POLYGON
  PROJECTION
   "init=epsg:27700"
  END  
  CONNECTIONTYPE POSTGIS
  CONNECTION "host=localhost port=5432 dbname=SampleGeoDataTable user=postgres password=hahaha"
  DATA "wkb_geometry from SampleLayer"
  CLASS
    STYLE
     COLOR      0 100 255
     OUTLINECOLOR 0 0 0
    END
  END
 
  METADATA      
   "wfs_enable_request" "*"
   "wfs_title"         "Sample WFS"
   "wfs_srs"           "EPSG:27700 EPSG:4326 EPSG:900913"
   "wfs_boundingbox"    "EPSG:27700 749.099975585938 -90036.5 660460.875 1227306.5"
   "gml_include_items" "all"
  END  
 END    
END

**************************************************

Regards,
Kajod
_______________________________________________
mapserver-users mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/mapserver-users

_______________________________________________
mapserver-users mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/mapserver-users
Reply | Threaded
Open this post in threaded view
|

Re: Issue in using MapServer WFS Filter

Kajod Sharma
Hi Steve,

Thanks for your response.

I have already tried with supplying SRS name in query. Now tried again, but results are still same.

Do you/someone know if I can somehow remove default spatial filter applied while MapServer makes a call to PostGIS?

Thanks.
 
Regards,
Kajod



From: Steve Toutant <[hidden email]>
To: Kajod Sharma <[hidden email]>
Cc: "[hidden email]" <[hidden email]>
Sent: Wednesday, 26 April 2017 3:05 PM
Subject: RE: [mapserver-users] Issue in using MapServer WFS Filter

Try adding &srsName="EPSG:4326" as a parameter
typeName=SampleLayer&srsName=EPSG:4326



De :        Kajod Sharma <[hidden email]>
A :        "[hidden email]" <[hidden email]>
Date :        2017-04-26 09:43
Objet :        [mapserver-users] Issue in using MapServer WFS Filter
Envoyé par :        "mapserver-users" <[hidden email]>





Hi,

Greetings!

I hope this is a right platform to discuss my query regarding FILTER applied on MapServer WFS.

I'm new in this area and exploring some features of MapServer. I want to use GetFeature request of WFS to get features applied on any location on map. I'm using "MapServer version 7.0.4 (MS4W 3.2.1)" and trying to apply filter "Contains" for it.

I can see two problems when it applies Filter query on PostGIS:

1. It looks it adds an extra default geospatial filter in it while making a query to PostGIS. This default spatial filter is not stopping to return any result from PostGIS. Is there any way to exclude this default filter?
2. It seems Contains coordinates are not transformed properly according to SRS of data in PostGIS.

I've tries with different projection in map file and request message with no success.

Supporting data to give your input on my queries:

WFS request
*************************
Formatted Version:

http://localhost/cgi-bin/mapserv.exe?
service=WFS&
map=C:/Data/MapServerWFSSample.map&
request=GetFeature&
version=2.0.0&
typeName=SampleLayer&
FILTER=<Filter xmlns="
http://www.opengis.net/ogc" xmlns:gml="http://www.opengis.net/gml" xmlns:ms="http://mapserver.gis.umn.edu/mapserver">
 <Contains>
   <PropertyName>wkb_Geometry</PropertyName>
   <gml:Point srsName="urn:ogc:def:crs:EPSG::4326">
     <gml:coordinates>0.112034,53.567972</gml:coordinates>
   </gml:Point>
 </Contains>
</Filter>

*************************

PostGIS query [Could see in log file]:
*************************
msPostGISLayerWhichShapes query: select "Attribute1","Attribute2","Attribute3",encode(ST_AsBinary(ST_Force2D("wkb_geometry"),'NDR'),'hex') as geom from SampleGeoDataTable where wkb_geometry && ST_GeomFromText('POLYGON((-0.999462804873474 -1.00102606014116,-0.999462804873474 -1.00102606014116,-0.999462804873474 -1.00102606014116,-0.999462804873474 -1.00102606014116,-0.999462804873474 -1.00102606014116))',find_srid('','SampleGeoDataTable','wkb_geometry')) and (st_contains(wkb_geometry,ST_GeomFromText('POINT (7853690.3631838141000000 -5506204.5232773330000000)')) = TRUE)
*************************

Similar WFS query to GeoServer works perfectly.

It would be very helpful if someone can help me on it. Thanks a lot in advance.

Map File looks like:

**************************************************
MAP
 NAME "Sample_WMS"
 CONFIG "PROJ_LIB" "C:\ms4w\proj\nad"
 CONFIG "MS_ERRORFILE" "C:/Data/ms_tmp/ms_error.txt"
 CONFIG "CPL_DEBUG" "ON"
 CONFIG "PROJ_DEBUG" "ON"
 STATUS ON
 PROJECTION
   "init=epsg:27700"
 END  
 
 WEB
  IMAGEPATH "C:/Data/ms_tmp/"
  IMAGEURL "/ms_tmp/"
  METADATA  
   "wfs_enable_request" "*"
   "wfs_title"         "My Global Map WFS Server"
   "wfs_srs"           "EPSG:4326 EPSG:900913 EPSG:27700"
   "wfs_boundingbox"    "EPSG:27700 749.099975585938 -90036.5 660460.875 1227306.5"    
  END
 END
 
 LAYER
  NAME "SampleLayer"
  STATUS DEFAULT
  TYPE POLYGON
  PROJECTION
   "init=epsg:27700"
  END  
  CONNECTIONTYPE POSTGIS
  CONNECTION "host=localhost port=5432 dbname=SampleGeoDataTable user=postgres password=hahaha"
  DATA "wkb_geometry from SampleLayer"
  CLASS
    STYLE
     COLOR      0 100 255
     OUTLINECOLOR 0 0 0
    END
  END
 
  METADATA      
   "wfs_enable_request" "*"
   "wfs_title"         "Sample WFS"
   "wfs_srs"           "EPSG:27700 EPSG:4326 EPSG:900913"
   "wfs_boundingbox"    "EPSG:27700 749.099975585938 -90036.5 660460.875 1227306.5"
   "gml_include_items" "all"
  END  
 END    
END

**************************************************

Regards,
Kajod
_______________________________________________
mapserver-users mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/mapserver-users




_______________________________________________
mapserver-users mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/mapserver-users
Reply | Threaded
Open this post in threaded view
|

Re: Issue in using MapServer WFS Filter

jmckenna
Administrator
In reply to this post by Kajod Sharma
Hi Kajod,

If you are using PostGIS, then I would set the 'wfs_extent' metadata at
the layer level of the mapfile (it looks like you tried that, with an
odd 'wfs_boundingbox' parameter): please review the syntax of the
wfs_extent parameter at
http://www.mapserver.org/ogc/wfs_server.html#layer-object

Then, next step is always to execute a GetCapabilities request and go
through that response and make sure there are no "WARNING" messages, and
make the changes in the mapfile to remove those warnings if necessary...

-jeff


--
Jeff McKenna
MapServer Consulting and Training Services
http://www.gatewaygeomatics.com/




On 2017-04-26 10:42 AM, Kajod Sharma wrote:

> Hi,
>
> Greetings!
>
> I hope this is a right platform to discuss my query regarding FILTER
> applied on MapServer WFS.
>
> I'm new in this area and exploring some features of MapServer. I want to
> use GetFeature request of WFS to get features applied on any location on
> map. I'm using "MapServer version 7.0.4 (MS4W 3.2.1)" and trying to
> apply filter "Contains" for it.
>
> I can see two problems when it applies Filter query on PostGIS:
>
> 1. It looks it adds an extra default geospatial filter in it while
> making a query to PostGIS. This default spatial filter is not stopping
> to return any result from PostGIS. Is there any way to exclude this
> default filter?
> 2. It seems Contains coordinates are not transformed properly according
> to SRS of data in PostGIS.
>
> I've tries with different projection in map file and request message
> with no success.
>
> Supporting data to give your input on my queries:
>
> WFS request
> *************************
> Formatted Version:
>
> http://localhost/cgi-bin/mapserv.exe?
> service=WFS&
> map=C:/Data/MapServerWFSSample.map&
> request=GetFeature&
> version=2.0.0&
> typeName=SampleLayer&
> FILTER=<Filter xmlns="http://www.opengis.net/ogc"
> xmlns:gml="http://www.opengis.net/gml"
> xmlns:ms="http://mapserver.gis.umn.edu/mapserver">
>   <*Contains*>
>     <PropertyName>wkb_Geometry</PropertyName>
>     <gml:Point srsName="urn:ogc:def:crs:EPSG::4326">
>       <gml:coordinates>0.112034,53.567972</gml:coordinates>
>     </gml:Point>
>   </*Contains*>
> </Filter>
> *************************
>
> PostGIS query [Could see in log file]:
> *************************
> msPostGISLayerWhichShapes query: select
> "Attribute1","Attribute2","Attribute3",encode(ST_AsBinary(ST_Force2D("wkb_geometry"),'NDR'),'hex')
> as geom from SampleGeoDataTable where */wkb_geometry &&
> ST_GeomFromText('POLYGON((-0.999462804873474
> -1.00102606014116,-0.999462804873474
> -1.00102606014116,-0.999462804873474
> -1.00102606014116,-0.999462804873474
> -1.00102606014116,-0.999462804873474
> -1.00102606014116))',find_srid('','SampleGeoDataTable','wkb_geometry'))/* and
> (st_contains(wkb_geometry,ST_GeomFromText('POINT
> (*/7853690.3631838141000000 -5506204.5232773330000000/*)')) = TRUE)
> *************************
>
> Similar WFS query to GeoServer works perfectly.
>
> It would be very helpful if someone can help me on it. Thanks a lot in
> advance.
>
> Map File looks like:
>
> **************************************************
> MAP
>   NAME "Sample_WMS"
>   CONFIG "PROJ_LIB" "C:\ms4w\proj\nad"
>   CONFIG "MS_ERRORFILE" "C:/Data/ms_tmp/ms_error.txt"
>   CONFIG "CPL_DEBUG" "ON"
>   CONFIG "PROJ_DEBUG" "ON"
>   STATUS ON
>   PROJECTION
>     "init=epsg:27700"
>   END
>
>   WEB
>    IMAGEPATH "C:/Data/ms_tmp/"
>    IMAGEURL "/ms_tmp/"
>    METADATA
>     "wfs_enable_request" "*"
>     "wfs_title"         "My Global Map WFS Server"
>     "wfs_srs"           "EPSG:4326 EPSG:900913 EPSG:27700"
>     "wfs_boundingbox"    "EPSG:27700 749.099975585938 -90036.5
> 660460.875 1227306.5"
>    END
>   END
>
>   LAYER
>    NAME "SampleLayer"
>    STATUS DEFAULT
>    TYPE POLYGON
>    PROJECTION
>     "init=epsg:27700"
>    END
>    CONNECTIONTYPE POSTGIS
>    CONNECTION "host=localhost port=5432 dbname=SampleGeoDataTable
> user=postgres password=hahaha"
>    DATA "wkb_geometry from SampleLayer"
>    CLASS
>      STYLE
>       COLOR      0 100 255
>       OUTLINECOLOR 0 0 0
>      END
>    END
>
>    METADATA
>     "wfs_enable_request" "*"
>     "wfs_title"         "Sample WFS"
>     "wfs_srs"           "EPSG:27700 EPSG:4326 EPSG:900913"
>     "wfs_boundingbox"    "EPSG:27700 749.099975585938 -90036.5
> 660460.875 1227306.5"
>     "gml_include_items" "all"
>    END
>   END
> END
> **************************************************
>
> Regards,
> Kajod
>
>


_______________________________________________
mapserver-users mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/mapserver-users
Reply | Threaded
Open this post in threaded view
|

Re: Issue in using MapServer WFS Filter

jratike80
Hi,

When it comes to extra spatial filter, there is a brand new metadata item for switching it off. See http://mapserver.org/ogc/wfs_server.html


wfs_use_default_extent_for_getfeature
    (Optional, since MapServer 7.0.4) Whether the MAP.EXTENT should be used in request to datasources in the absence of other spatial filter. This is the default behaviour, but this might affect performance in some use cases. In those cases, setting this item to NO will avoid he default spatial filter to be appended to the request. This is only implemented for OGR datasources.

However, with PostGIS the && query is fast. The weird part in your log
wkb_geometry &&
 ST_GeomFromText('POLYGON((-0.999462804873474
 -1.00102606014116,-0.999462804873474
 -1.00102606014116,-0.999462804873474
 -1.00102606014116,-0.999462804873474
 -1.00102606014116,-0.999462804873474
 -1.00102606014116))

means that the layer extent is not set correctly or Mapserver can't get is correctly from PostGIS which means data error on that side. For sure using the non-existing keyword wfs_boundingbox is not right. See what can be used from http://mapserver.org/ogc/wfs_server.html.

When you play with spatial filters I recommend to start by using the native SRS for the feature type in filters. Non-native SRS in filter should be transformed by the server but it is error prone. Your filter is also also a little bit fuzzy. gml:coordinates belongs to GML2 and was removed from GML2. But you are using service version 2.0 that defaults to GML3. Is the meaning that your filter is GML2 or GML3? That is a big difference because in the first case the axis order of EPSG:4326 coordinates is longitude-latitude but in the latter it is latitude-longitude. Do you search near the equator or from somewhere in Europe?

 <PropertyName>wkb_Geometry</PropertyName>
  <gml:Point srsName="urn:ogc:def:crs:EPSG::4326">
   <gml:coordinates>0.112034,53.567972</gml:coordinates>
   </gml:Point>

One more thing, "wfs_srs" metadata takes only one SRS, not a list.

If you send SQL for CREATE TABLE and for inserting one polygon into the table, and WFS filter you are using in your trials I thing I could find some time for testing.

-Jukka Rahkonen-
________________________________________
Jeff McKenna  wrote:
Re: [mapserver-users] Issue in using MapServer WFS Filter

Hi Kajod,

If you are using PostGIS, then I would set the 'wfs_extent' metadata at
the layer level of the mapfile (it looks like you tried that, with an
odd 'wfs_boundingbox' parameter): please review the syntax of the
wfs_extent parameter at
http://www.mapserver.org/ogc/wfs_server.html#layer-object

Then, next step is always to execute a GetCapabilities request and go
through that response and make sure there are no "WARNING" messages, and
make the changes in the mapfile to remove those warnings if necessary...

-jeff


--
Jeff McKenna
MapServer Consulting and Training Services
http://www.gatewaygeomatics.com/




On 2017-04-26 10:42 AM, Kajod Sharma wrote:

> Hi,
>
> Greetings!
>
> I hope this is a right platform to discuss my query regarding FILTER
> applied on MapServer WFS.
>
> I'm new in this area and exploring some features of MapServer. I want to
> use GetFeature request of WFS to get features applied on any location on
> map. I'm using "MapServer version 7.0.4 (MS4W 3.2.1)" and trying to
> apply filter "Contains" for it.
>
> I can see two problems when it applies Filter query on PostGIS:
>
> 1. It looks it adds an extra default geospatial filter in it while
> making a query to PostGIS. This default spatial filter is not stopping
> to return any result from PostGIS. Is there any way to exclude this
> default filter?
> 2. It seems Contains coordinates are not transformed properly according
> to SRS of data in PostGIS.
>
> I've tries with different projection in map file and request message
> with no success.
>
> Supporting data to give your input on my queries:
>
> WFS request
> *************************
> Formatted Version:
>
> http://localhost/cgi-bin/mapserv.exe?
> service=WFS&
> map=C:/Data/MapServerWFSSample.map&
> request=GetFeature&
> version=2.0.0&
> typeName=SampleLayer&
> FILTER=<Filter xmlns="http://www.opengis.net/ogc"
> xmlns:gml="http://www.opengis.net/gml"
> xmlns:ms="http://mapserver.gis.umn.edu/mapserver">
>   <*Contains*>
>     <PropertyName>wkb_Geometry</PropertyName>
>     <gml:Point srsName="urn:ogc:def:crs:EPSG::4326">
>       <gml:coordinates>0.112034,53.567972</gml:coordinates>
>     </gml:Point>
>   </*Contains*>
> </Filter>
> *************************
>
> PostGIS query [Could see in log file]:
> *************************
> msPostGISLayerWhichShapes query: select
> "Attribute1","Attribute2","Attribute3",encode(ST_AsBinary(ST_Force2D("wkb_geometry"),'NDR'),'hex')
> as geom from SampleGeoDataTable where */wkb_geometry &&
> ST_GeomFromText('POLYGON((-0.999462804873474
> -1.00102606014116,-0.999462804873474
> -1.00102606014116,-0.999462804873474
> -1.00102606014116,-0.999462804873474
> -1.00102606014116,-0.999462804873474
> -1.00102606014116))',find_srid('','SampleGeoDataTable','wkb_geometry'))/* and
> (st_contains(wkb_geometry,ST_GeomFromText('POINT
> (*/7853690.3631838141000000 -5506204.5232773330000000/*)')) = TRUE)
> *************************
>
> Similar WFS query to GeoServer works perfectly.
>
> It would be very helpful if someone can help me on it. Thanks a lot in
> advance.
>
> Map File looks like:
>
> **************************************************
> MAP
>   NAME "Sample_WMS"
>   CONFIG "PROJ_LIB" "C:\ms4w\proj\nad"
>   CONFIG "MS_ERRORFILE" "C:/Data/ms_tmp/ms_error.txt"
>   CONFIG "CPL_DEBUG" "ON"
>   CONFIG "PROJ_DEBUG" "ON"
>   STATUS ON
>   PROJECTION
>     "init=epsg:27700"
>   END
>
>   WEB
>    IMAGEPATH "C:/Data/ms_tmp/"
>    IMAGEURL "/ms_tmp/"
>    METADATA
>     "wfs_enable_request" "*"
>     "wfs_title"         "My Global Map WFS Server"
>     "wfs_srs"           "EPSG:4326 EPSG:900913 EPSG:27700"
>     "wfs_boundingbox"    "EPSG:27700 749.099975585938 -90036.5
> 660460.875 1227306.5"
>    END
>   END
>
>   LAYER
>    NAME "SampleLayer"
>    STATUS DEFAULT
>    TYPE POLYGON
>    PROJECTION
>     "init=epsg:27700"
>    END
>    CONNECTIONTYPE POSTGIS
>    CONNECTION "host=localhost port=5432 dbname=SampleGeoDataTable
> user=postgres password=hahaha"
>    DATA "wkb_geometry from SampleLayer"
>    CLASS
>      STYLE
>       COLOR      0 100 255
>       OUTLINECOLOR 0 0 0
>      END
>    END
>
>    METADATA
>     "wfs_enable_request" "*"
>     "wfs_title"         "Sample WFS"
>     "wfs_srs"           "EPSG:27700 EPSG:4326 EPSG:900913"
>     "wfs_boundingbox"    "EPSG:27700 749.099975585938 -90036.5
> 660460.875 1227306.5"
>     "gml_include_items" "all"
>    END
>   END
> END
> **************************************************
>
> Regards,
> Kajod
>
>


_______________________________________________
mapserver-users mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/mapserver-users
_______________________________________________
mapserver-users mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/mapserver-users
Reply | Threaded
Open this post in threaded view
|

Re: Issue in using MapServer WFS Filter

Kajod Sharma
Hi,

Still no much progress on it, is there anyone who faced the similar problem and got the solution?

Thanks.
 
Regards,
Kajod



From: Kajod Sharma <[hidden email]>
To: Rahkonen Jukka (MML) <[hidden email]>; Jeff McKenna <[hidden email]>; "[hidden email]" <[hidden email]>
Sent: Thursday, 27 April 2017 11:09 AM
Subject: Re: [mapserver-users] Issue in using MapServer WFS Filter

Thanks for valuable response.

I tried the solution suggested by you with putting NO for wfs_use_default_extent_for_getfeature. But still I can see default spatial filter in query.

I even tried with passing BBOX (which I don't want) in filter, but it's taking the default one...it's wierd :(

I'll try to get SQL for sample data and will share if I can.

Thanks.

Regards,
Kajod



From: Rahkonen Jukka (MML) <[hidden email]>
To: Jeff McKenna <[hidden email]>; "[hidden email]" <[hidden email]>
Sent: Wednesday, 26 April 2017 8:57 PM
Subject: Re: [mapserver-users] Issue in using MapServer WFS Filter

Hi,

When it comes to extra spatial filter, there is a brand new metadata item for switching it off. See http://mapserver.org/ogc/wfs_server.html


wfs_use_default_extent_for_getfeature
    (Optional, since MapServer 7.0.4) Whether the MAP.EXTENT should be used in request to datasources in the absence of other spatial filter. This is the default behaviour, but this might affect performance in some use cases. In those cases, setting this item to NO will avoid he default spatial filter to be appended to the request. This is only implemented for OGR datasources.

However, with PostGIS the && query is fast. The weird part in your log
wkb_geometry &&
ST_GeomFromText('POLYGON((-0.999462804873474
-1.00102606014116,-0.999462804873474
-1.00102606014116,-0.999462804873474
-1.00102606014116,-0.999462804873474
-1.00102606014116,-0.999462804873474
-1.00102606014116))

means that the layer extent is not set correctly or Mapserver can't get is correctly from PostGIS which means data error on that side. For sure using the non-existing keyword wfs_boundingbox is not right. See what can be used from http://mapserver.org/ogc/wfs_server.html.

When you play with spatial filters I recommend to start by using the native SRS for the feature type in filters. Non-native SRS in filter should be transformed by the server but it is error prone. Your filter is also also a little bit fuzzy. gml:coordinates belongs to GML2 and was removed from GML2. But you are using service version 2.0 that defaults to GML3. Is the meaning that your filter is GML2 or GML3? That is a big difference because in the first case the axis order of EPSG:4326 coordinates is longitude-latitude but in the latter it is latitude-longitude. Do you search near the equator or from somewhere in Europe?

<PropertyName>wkb_Geometry</PropertyName>
  <gml:Point srsName="urn:ogc:def:crs:EPSG::4326">
  <gml:coordinates>0.112034,53.567972</gml:coordinates>
  </gml:Point>

One more thing, "wfs_srs" metadata takes only one SRS, not a list.

If you send SQL for CREATE TABLE and for inserting one polygon into the table, and WFS filter you are using in your trials I thing I could find some time for testing.

-Jukka Rahkonen-
________________________________________
Jeff McKenna  wrote:
Re: [mapserver-users] Issue in using MapServer WFS Filter

Hi Kajod,

If you are using PostGIS, then I would set the 'wfs_extent' metadata at
the layer level of the mapfile (it looks like you tried that, with an
odd 'wfs_boundingbox' parameter): please review the syntax of the
wfs_extent parameter at
http://www.mapserver.org/ogc/wfs_server.html#layer-object

Then, next step is always to execute a GetCapabilities request and go
through that response and make sure there are no "WARNING" messages, and
make the changes in the mapfile to remove those warnings if necessary...

-jeff


--
Jeff McKenna
MapServer Consulting and Training Services
http://www.gatewaygeomatics.com/




On 2017-04-26 10:42 AM, Kajod Sharma wrote:

> Hi,
>
> Greetings!
>
> I hope this is a right platform to discuss my query regarding FILTER
> applied on MapServer WFS.
>
> I'm new in this area and exploring some features of MapServer. I want to
> use GetFeature request of WFS to get features applied on any location on
> map. I'm using "MapServer version 7.0.4 (MS4W 3.2.1)" and trying to
> apply filter "Contains" for it.
>
> I can see two problems when it applies Filter query on PostGIS:
>
> 1. It looks it adds an extra default geospatial filter in it while
> making a query to PostGIS. This default spatial filter is not stopping
> to return any result from PostGIS. Is there any way to exclude this
> default filter?
> 2. It seems Contains coordinates are not transformed properly according
> to SRS of data in PostGIS.
>
> I've tries with different projection in map file and request message
> with no success.
>
> Supporting data to give your input on my queries:
>
> WFS request
> *************************
> Formatted Version:
>
> http://localhost/cgi-bin/mapserv.exe?
> service=WFS&
> map=C:/Data/MapServerWFSSample.map&
> request=GetFeature&
> version=2.0.0&
> typeName=SampleLayer&
> FILTER=<Filter xmlns="http://www.opengis.net/ogc"
> xmlns:gml="http://www.opengis.net/gml"
> xmlns:ms="http://mapserver.gis.umn.edu/mapserver">
>  <*Contains*>
>    <PropertyName>wkb_Geometry</PropertyName>
>    <gml:Point srsName="urn:ogc:def:crs:EPSG::4326">
>      <gml:coordinates>0.112034,53.567972</gml:coordinates>
>    </gml:Point>
>  </*Contains*>
> </Filter>
> *************************
>
> PostGIS query [Could see in log file]:
> *************************
> msPostGISLayerWhichShapes query: select
> "Attribute1","Attribute2","Attribute3",encode(ST_AsBinary(ST_Force2D("wkb_geometry"),'NDR'),'hex')
> as geom from SampleGeoDataTable where */wkb_geometry &&
> ST_GeomFromText('POLYGON((-0.999462804873474
> -1.00102606014116,-0.999462804873474
> -1.00102606014116,-0.999462804873474
> -1.00102606014116,-0.999462804873474
> -1.00102606014116,-0.999462804873474
> -1.00102606014116))',find_srid('','SampleGeoDataTable','wkb_geometry'))/* and
> (st_contains(wkb_geometry,ST_GeomFromText('POINT
> (*/7853690.3631838141000000 -5506204.5232773330000000/*)')) = TRUE)
> *************************
>
> Similar WFS query to GeoServer works perfectly.
>
> It would be very helpful if someone can help me on it. Thanks a lot in
> advance.
>
> Map File looks like:
>
> **************************************************
> MAP
>  NAME "Sample_WMS"
>  CONFIG "PROJ_LIB" "C:\ms4w\proj\nad"
>  CONFIG "MS_ERRORFILE" "C:/Data/ms_tmp/ms_error.txt"
>  CONFIG "CPL_DEBUG" "ON"
>  CONFIG "PROJ_DEBUG" "ON"
>  STATUS ON
>  PROJECTION
>    "init=epsg:27700"
>  END
>
>  WEB
>    IMAGEPATH "C:/Data/ms_tmp/"
>    IMAGEURL "/ms_tmp/"
>    METADATA
>    "wfs_enable_request" "*"
>    "wfs_title"        "My Global Map WFS Server"
>    "wfs_srs"          "EPSG:4326 EPSG:900913 EPSG:27700"
>    "wfs_boundingbox"    "EPSG:27700 749.099975585938 -90036.5
> 660460.875 1227306.5"
>    END
>  END
>
>  LAYER
>    NAME "SampleLayer"
>    STATUS DEFAULT
>    TYPE POLYGON
>    PROJECTION
>    "init=epsg:27700"
>    END
>    CONNECTIONTYPE POSTGIS
>    CONNECTION "host=localhost port=5432 dbname=SampleGeoDataTable
> user=postgres password=hahaha"
>    DATA "wkb_geometry from SampleLayer"
>    CLASS
>      STYLE
>      COLOR      0 100 255
>      OUTLINECOLOR 0 0 0
>      END
>    END
>
>    METADATA
>    "wfs_enable_request" "*"
>    "wfs_title"        "Sample WFS"
>    "wfs_srs"          "EPSG:27700 EPSG:4326 EPSG:900913"
>    "wfs_boundingbox"    "EPSG:27700 749.099975585938 -90036.5
> 660460.875 1227306.5"
>    "gml_include_items" "all"
>    END
>  END
> END
> **************************************************
>
> Regards,
> Kajod
>
>


_______________________________________________
mapserver-users mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/mapserver-users

_______________________________________________
mapserver-users mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/mapserver-users





_______________________________________________
mapserver-users mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/mapserver-users
Reply | Threaded
Open this post in threaded view
|

Re: Issue in using MapServer WFS Filter

jratike80

Hi,


I saved the states.shp file from the demo data directory that installs with GeoServer into PostGIS.


This query finds Kansas:


<a href="http://localhost:8060/cgi-bin/mapserv.exe?service=WFS&amp;map=c:\ms4w_data\apps\states_pg.map&amp;request=GetFeature&amp;version=2.0.0&amp;typeNames=ms:states_pg&amp;FILTER=%3CFilter%3E%3CContains%3E%3CPropertyName%3EmsGeometry%3C/PropertyName%3E%3Cgml:Point%20srsName=%22urn:ogc:def:crs:EPSG::4326%22%3E%3Cgml:coordinates%3E40,-100%3C/gml:coordinates%3E%3C/gml:Point%3E%3C/Contains%3E%3C/Filter%3E">http://localhost:8060/cgi-bin/mapserv.exe?service=WFS&map=c:\ms4w_data\apps\states_pg.map&request=GetFeature&version=2.0.0&typeNames=ms:states_pg&FILTER=%3CFilter%3E%3CContains%3E%3CPropertyName%3EmsGeometry%3C/PropertyName%3E%3Cgml:Point%20srsName=%22urn:ogc:def:crs:EPSG::4326%22%3E%3Cgml:coordinates%3E40,-100%3C/gml:coordinates%3E%3C/gml:Point%3E%3C/Contains%3E%3C/Filter%3E


The SQL does contain the && comparison but is is not harmful.


My mapfile:


MAP
NAME "testname"
SIZE 800 800
EXTENT -180 -90 180 90
UNITS DD
IMAGECOLOR 20 250 250
SHAPEPATH "c:\ms4w\tmp"
IMAGETYPE "png"
OUTPUTFORMAT
  NAME "geojson"
  DRIVER "OGR/GEOJSON"
  MIMETYPE "application/json; subtype=geojson"
  FORMATOPTION "STORAGE=stream"
  FORMATOPTION "FORM=SIMPLE"
END
WEB
    METADATA
        "ows_enable_request" "*"
        "wms_bbox_extended" "true"
        "wfs_return_srs_as_urn" "true"
        "ows_srs" "CRS:84 EPSG:4326 EPSG:32634 EPSG:3857 EPSG:2923"
        "wms_title" "MS 6.1.1 WMS from Spatialite"
        "wfs_title" "MS 6.1.1 WFS from Spatialite"
        "wfs_abstract" "ööää"
        "wfs_onlineresource" "http://localhost:8060/cgi-bin/mapserv.exe?map=c:\ms4w\apps\wms-wfs.map"
       # "wfs_use_default_extent_for_getfeature" "no"
     END
END
DEBUG 10
CONFIG "PROJ_LIB" "C:/ms4w/proj/nad"
CONFIG "CPL_DEBUG" "ON"
CONFIG "SQLITE_LIST_ALL_TABLES" "TRUE"
CONFIG "MS_ERRORFILE" "c:/ms4w/tmp/debug.txt"
PROJECTION
"init=epsg:4326"
END
LAYER
NAME "states_pg"
STATUS DEFAULT
CONNECTIONTYPE POSTGIS
CONNECTION "dbname=xxx user=yyy"
DATA "geom from states using unique gid using srid=4326"
PROCESSING "CLOSE_CONNECTION=DEFER"
TYPE POLYGON
    STATUS ON
    PROJECTION
        "init=epsg:4326"
    END
            OPACITY 50
 METADATA
      "ows_title"         "states_pg" ##REQUIRED
      "wfs_srs"           "EPSG:4326" ## REQUIRED
      "gml_include_items" "all" ## Optional (serves all attributes for layer)
     # "gml_exclude_items" "STATE_NAME"
      "gml_featureid"     "gid" ## REQUIRED
      "gml_types" "auto"
      "wfs_getfeature_formatlist" "geojson"
 END
    CLASS
        STYLE
            COLOR 100 200 100
            OUTLINECOLOR 0 0 0
        END
 LABEL
    COLOR  150 150 150
    OUTLINECOLOR 255 255 255
    TYPE bitmap
    SIZE small
    POSITION UL
    #TEXT "[STATE_FIPS]"
    PARTIALS FALSE
    END    
  LABEL
    COLOR  150 150 150
    OUTLINECOLOR 255 255 255
    TYPE bitmap
    SIZE small
    POSITION LL
    #TEXT "[STATE_NAME]"
    PARTIALS FALSE
    END      
    END
END

END


-Jukka Rahkonen-



Lähettäjä: Kajod Sharma <[hidden email]>
Lähetetty: 4. toukokuuta 2017 12:20
Vastaanottaja: Rahkonen Jukka (MML); Jeff McKenna; [hidden email]
Aihe: Re: [mapserver-users] Issue in using MapServer WFS Filter
 
Hi,

Still no much progress on it, is there anyone who faced the similar problem and got the solution?

Thanks.
 
Regards,
Kajod



From: Kajod Sharma <[hidden email]>
To: Rahkonen Jukka (MML) <[hidden email]>; Jeff McKenna <[hidden email]>; "[hidden email]" <[hidden email]>
Sent: Thursday, 27 April 2017 11:09 AM
Subject: Re: [mapserver-users] Issue in using MapServer WFS Filter

Thanks for valuable response.

I tried the solution suggested by you with putting NO for wfs_use_default_extent_for_getfeature. But still I can see default spatial filter in query.

I even tried with passing BBOX (which I don't want) in filter, but it's taking the default one...it's wierd :(

I'll try to get SQL for sample data and will share if I can.

Thanks.

Regards,
Kajod



From: Rahkonen Jukka (MML) <[hidden email]>
To: Jeff McKenna <[hidden email]>; "[hidden email]" <[hidden email]>
Sent: Wednesday, 26 April 2017 8:57 PM
Subject: Re: [mapserver-users] Issue in using MapServer WFS Filter

Hi,

When it comes to extra spatial filter, there is a brand new metadata item for switching it off. See http://mapserver.org/ogc/wfs_server.html


wfs_use_default_extent_for_getfeature
    (Optional, since MapServer 7.0.4) Whether the MAP.EXTENT should be used in request to datasources in the absence of other spatial filter. This is the default behaviour, but this might affect performance in some use cases. In those cases, setting this item to NO will avoid he default spatial filter to be appended to the request. This is only implemented for OGR datasources.

However, with PostGIS the && query is fast. The weird part in your log
wkb_geometry &&
ST_GeomFromText('POLYGON((-0.999462804873474
-1.00102606014116,-0.999462804873474
-1.00102606014116,-0.999462804873474
-1.00102606014116,-0.999462804873474
-1.00102606014116,-0.999462804873474
-1.00102606014116))

means that the layer extent is not set correctly or Mapserver can't get is correctly from PostGIS which means data error on that side. For sure using the non-existing keyword wfs_boundingbox is not right. See what can be used from http://mapserver.org/ogc/wfs_server.html.

When you play with spatial filters I recommend to start by using the native SRS for the feature type in filters. Non-native SRS in filter should be transformed by the server but it is error prone. Your filter is also also a little bit fuzzy. gml:coordinates belongs to GML2 and was removed from GML2. But you are using service version 2.0 that defaults to GML3. Is the meaning that your filter is GML2 or GML3? That is a big difference because in the first case the axis order of EPSG:4326 coordinates is longitude-latitude but in the latter it is latitude-longitude. Do you search near the equator or from somewhere in Europe?

<PropertyName>wkb_Geometry</PropertyName>
  <gml:Point srsName="urn:ogc:def:crs:EPSG::4326">
  <gml:coordinates>0.112034,53.567972</gml:coordinates>
  </gml:Point>

One more thing, "wfs_srs" metadata takes only one SRS, not a list.

If you send SQL for CREATE TABLE and for inserting one polygon into the table, and WFS filter you are using in your trials I thing I could find some time for testing.

-Jukka Rahkonen-
________________________________________
Jeff McKenna  wrote:
Re: [mapserver-users] Issue in using MapServer WFS Filter

Hi Kajod,

If you are using PostGIS, then I would set the 'wfs_extent' metadata at
the layer level of the mapfile (it looks like you tried that, with an
odd 'wfs_boundingbox' parameter): please review the syntax of the
wfs_extent parameter at
http://www.mapserver.org/ogc/wfs_server.html#layer-object

Then, next step is always to execute a GetCapabilities request and go
through that response and make sure there are no "WARNING" messages, and
make the changes in the mapfile to remove those warnings if necessary...

-jeff


--
Jeff McKenna
MapServer Consulting and Training Services
http://www.gatewaygeomatics.com/




On 2017-04-26 10:42 AM, Kajod Sharma wrote:
> Hi,
>
> Greetings!
>
> I hope this is a right platform to discuss my query regarding FILTER
> applied on MapServer WFS.
>
> I'm new in this area and exploring some features of MapServer. I want to
> use GetFeature request of WFS to get features applied on any location on
> map. I'm using "MapServer version 7.0.4 (MS4W 3.2.1)" and trying to
> apply filter "Contains" for it.
>
> I can see two problems when it applies Filter query on PostGIS:
>
> 1. It looks it adds an extra default geospatial filter in it while
> making a query to PostGIS. This default spatial filter is not stopping
> to return any result from PostGIS. Is there any way to exclude this
> default filter?
> 2. It seems Contains coordinates are not transformed properly according
> to SRS of data in PostGIS.
>
> I've tries with different projection in map file and request message
> with no success.
>
> Supporting data to give your input on my queries:
>
> WFS request
> *************************
> Formatted Version:
>
> http://localhost/cgi-bin/mapserv.exe?
> service=WFS&
> map=C:/Data/MapServerWFSSample.map&
> request=GetFeature&
> version=2.0.0&
> typeName=SampleLayer&
> FILTER=<Filter xmlns="http://www.opengis.net/ogc"
> xmlns:gml="http://www.opengis.net/gml"
> xmlns:ms="http://mapserver.gis.umn.edu/mapserver">
>  <*Contains*>
>    <PropertyName>wkb_Geometry</PropertyName>
>    <gml:Point srsName="urn:ogc:def:crs:EPSG::4326">
>      <gml:coordinates>0.112034,53.567972</gml:coordinates>
>    </gml:Point>
>  </*Contains*>
> </Filter>
> *************************
>
> PostGIS query [Could see in log file]:
> *************************
> msPostGISLayerWhichShapes query: select
> "Attribute1","Attribute2","Attribute3",encode(ST_AsBinary(ST_Force2D("wkb_geometry"),'NDR'),'hex')
> as geom from SampleGeoDataTable where */wkb_geometry &&
> ST_GeomFromText('POLYGON((-0.999462804873474
> -1.00102606014116,-0.999462804873474
> -1.00102606014116,-0.999462804873474
> -1.00102606014116,-0.999462804873474
> -1.00102606014116,-0.999462804873474
> -1.00102606014116))',find_srid('','SampleGeoDataTable','wkb_geometry'))/* and
> (st_contains(wkb_geometry,ST_GeomFromText('POINT
> (*/7853690.3631838141000000 -5506204.5232773330000000/*)')) = TRUE)
> *************************
>
> Similar WFS query to GeoServer works perfectly.
>
> It would be very helpful if someone can help me on it. Thanks a lot in
> advance.
>
> Map File looks like:
>
> **************************************************
> MAP
>  NAME "Sample_WMS"
>  CONFIG "PROJ_LIB" "C:\ms4w\proj\nad"
>  CONFIG "MS_ERRORFILE" "C:/Data/ms_tmp/ms_error.txt"
>  CONFIG "CPL_DEBUG" "ON"
>  CONFIG "PROJ_DEBUG" "ON"
>  STATUS ON
>  PROJECTION
>    "init=epsg:27700"
>  END
>
>  WEB
>    IMAGEPATH "C:/Data/ms_tmp/"
>    IMAGEURL "/ms_tmp/"
>    METADATA
>    "wfs_enable_request" "*"
>    "wfs_title"        "My Global Map WFS Server"
>    "wfs_srs"          "EPSG:4326 EPSG:900913 EPSG:27700"
>    "wfs_boundingbox"    "EPSG:27700 749.099975585938 -90036.5
> 660460.875 1227306.5"
>    END
>  END
>
>  LAYER
>    NAME "SampleLayer"
>    STATUS DEFAULT
>    TYPE POLYGON
>    PROJECTION
>    "init=epsg:27700"
>    END
>    CONNECTIONTYPE POSTGIS
>    CONNECTION "host=localhost port=5432 dbname=SampleGeoDataTable
> user=postgres password=hahaha"
>    DATA "wkb_geometry from SampleLayer"
>    CLASS
>      STYLE
>      COLOR      0 100 255
>      OUTLINECOLOR 0 0 0
>      END
>    END
>
>    METADATA
>    "wfs_enable_request" "*"
>    "wfs_title"        "Sample WFS"
>    "wfs_srs"          "EPSG:27700 EPSG:4326 EPSG:900913"
>    "wfs_boundingbox"    "EPSG:27700 749.099975585938 -90036.5
> 660460.875 1227306.5"
>    "gml_include_items" "all"
>    END
>  END
> END
> **************************************************
>
> Regards,
> Kajod
>
>


_______________________________________________
mapserver-users mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/mapserver-users

_______________________________________________
mapserver-users mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/mapserver-users





_______________________________________________
mapserver-users mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/mapserver-users
Reply | Threaded
Open this post in threaded view
|

Re: Issue in using MapServer WFS Filter

Kajod Sharma
Hi Jukka Rahkonen,



Thanks a lot for your help and doing this exercise. I really appreciate it, it's really nice group to get/share inputs on any issue on MapServer.

Well I've found the solution now. I was missing EXTENT parameter in map file. After adding it according to source data, it started working. Thanks a lot Jukka.

Just want to mention a point here, it still has a default spatial filter in PostGIS query, but this time with correct coordinates according to EXTENT defined in map file.

Thanks again to all. Have a nice weekend!

Cheers!

Regards,
Kajod



From: Rahkonen Jukka (MML) <[hidden email]>
To: Jeff McKenna <[hidden email]>; "[hidden email]" <[hidden email]>; Kajod Sharma <[hidden email]>
Sent: Thursday, 4 May 2017 8:02 PM
Subject: Re: [mapserver-users] Issue in using MapServer WFS Filter

Hi,

I saved the states.shp file from the demo data directory that installs with GeoServer into PostGIS.

This query finds Kansas:

<a rel="nofollow" shape="rect" id="yiv6196364185yui_3_16_0_ym19_1_1493992961293_4477" target="_blank" onclick="return window.theMainWindow.showLinkWarning(this)" href="http://localhost:8060/cgi-bin/mapserv.exe?service=WFS&amp;map=c:\ms4w_data\apps\states_pg.map&amp;request=GetFeature&amp;version=2.0.0&amp;typeNames=ms:states_pg&amp;FILTER=%3CFilter%3E%3CContains%3E%3CPropertyName%3EmsGeometry%3C/PropertyName%3E%3Cgml:Point%20srsName=%22urn:ogc:def:crs:EPSG::4326%22%3E%3Cgml:coordinates%3E40,-100%3C/gml:coordinates%3E%3C/gml:Point%3E%3C/Contains%3E%3C/Filter%3E">http://localhost:8060/cgi-bin/mapserv.exe?service=WFS&map=c:\ms4w_data\apps\states_pg.map&request=GetFeature&version=2.0.0&typeNames=ms:states_pg&FILTER=%3CFilter%3E%3CContains%3E%3CPropertyName%3EmsGeometry%3C/PropertyName%3E%3Cgml:Point%20srsName=%22urn:ogc:def:crs:EPSG::4326%22%3E%3Cgml:coordinates%3E40,-100%3C/gml:coordinates%3E%3C/gml:Point%3E%3C/Contains%3E%3C/Filter%3E

The SQL does contain the && comparison but is is not harmful.

My mapfile:

MAP
NAME "testname"
SIZE 800 800
EXTENT -180 -90 180 90
UNITS DD
IMAGECOLOR 20 250 250
SHAPEPATH "c:\ms4w\tmp"
IMAGETYPE "png"
OUTPUTFORMAT
  NAME "geojson"
  DRIVER "OGR/GEOJSON"
  MIMETYPE "application/json; subtype=geojson"
  FORMATOPTION "STORAGE=stream"
  FORMATOPTION "FORM=SIMPLE"
END
WEB
    METADATA
        "ows_enable_request" "*"
        "wms_bbox_extended" "true"
        "wfs_return_srs_as_urn" "true"
        "ows_srs" "CRS:84 EPSG:4326 EPSG:32634 EPSG:3857 EPSG:2923"
        "wms_title" "MS 6.1.1 WMS from Spatialite"
        "wfs_title" "MS 6.1.1 WFS from Spatialite"
        "wfs_abstract" "ööää"
        "wfs_onlineresource" "http://localhost:8060/cgi-bin/mapserv.exe?map=c:\ms4w\apps\wms-wfs.map"
       # "wfs_use_default_extent_for_getfeature" "no"
     END
END
DEBUG 10
CONFIG "PROJ_LIB" "C:/ms4w/proj/nad"
CONFIG "CPL_DEBUG" "ON"
CONFIG "SQLITE_LIST_ALL_TABLES" "TRUE"
CONFIG "MS_ERRORFILE" "c:/ms4w/tmp/debug.txt"
PROJECTION
"init=epsg:4326"
END
LAYER
NAME "states_pg"
STATUS DEFAULT
CONNECTIONTYPE POSTGIS
CONNECTION "dbname=xxx user=yyy"
DATA "geom from states using unique gid using srid=4326"
PROCESSING "CLOSE_CONNECTION=DEFER"
TYPE POLYGON
    STATUS ON
    PROJECTION
        "init=epsg:4326"
    END
            OPACITY 50
 METADATA
      "ows_title"         "states_pg" ##REQUIRED
      "wfs_srs"           "EPSG:4326" ## REQUIRED
      "gml_include_items" "all" ## Optional (serves all attributes for layer)
     # "gml_exclude_items" "STATE_NAME"
      "gml_featureid"     "gid" ## REQUIRED
      "gml_types" "auto"
      "wfs_getfeature_formatlist" "geojson"
 END
    CLASS
        STYLE
            COLOR 100 200 100
            OUTLINECOLOR 0 0 0
        END
 LABEL
    COLOR  150 150 150
    OUTLINECOLOR 255 255 255
    TYPE bitmap
    SIZE small
    POSITION UL
    #TEXT "[STATE_FIPS]"
    PARTIALS FALSE
    END    
  LABEL
    COLOR  150 150 150
    OUTLINECOLOR 255 255 255
    TYPE bitmap
    SIZE small
    POSITION LL
    #TEXT "[STATE_NAME]"
    PARTIALS FALSE
    END      
    END
END

END

-Jukka Rahkonen-



<<<<< trimmed message >>>>>

On 2017-04-26 10:42 AM, Kajod Sharma wrote:
> Hi,
>
> Greetings!
>
> I hope this is a right platform to discuss my query regarding FILTER
> applied on MapServer WFS.
>
> I'm new in this area and exploring some features of MapServer. I want to
> use GetFeature request of WFS to get features applied on any location on
> map. I'm using "MapServer version 7.0.4 (MS4W 3.2.1)" and trying to
> apply filter "Contains" for it.
>
> I can see two problems when it applies Filter query on PostGIS:
>
> 1. It looks it adds an extra default geospatial filter in it while
> making a query to PostGIS. This default spatial filter is not stopping
> to return any result from PostGIS. Is there any way to exclude this
> default filter?
> 2. It seems Contains coordinates are not transformed properly according
> to SRS of data in PostGIS.
>
> I've tries with different projection in map file and request message
> with no success.
>
> Supporting data to give your input on my queries:
>
> WFS request
> *************************
> Formatted Version:
>
> http://localhost/cgi-bin/mapserv.exe?
> service=WFS&
> map=C:/Data/MapServerWFSSample.map&
> request=GetFeature&
> version=2.0.0&
> typeName=SampleLayer&
> FILTER=<Filter xmlns="http://www.opengis.net/ogc"
> xmlns:gml="http://www.opengis.net/gml"
> xmlns:ms="http://mapserver.gis.umn.edu/mapserver">
>  <*Contains*>
>    <PropertyName>wkb_Geometry</PropertyName>
>    <gml:Point srsName="urn:ogc:def:crs:EPSG::4326">
>      <gml:coordinates>0.112034,53.567972</gml:coordinates>
>    </gml:Point>
>  </*Contains*>
> </Filter>
> *************************
>
> PostGIS query [Could see in log file]:
> *************************
> msPostGISLayerWhichShapes query: select
> "Attribute1","Attribute2","Attribute3",encode(ST_AsBinary(ST_Force2D("wkb_geometry"),'NDR'),'hex')
> as geom from SampleGeoDataTable where */wkb_geometry &&
> ST_GeomFromText('POLYGON((-0.999462804873474
> -1.00102606014116,-0.999462804873474
> -1.00102606014116,-0.999462804873474
> -1.00102606014116,-0.999462804873474
> -1.00102606014116,-0.999462804873474
> -1.00102606014116))',find_srid('','SampleGeoDataTable','wkb_geometry'))/* and
> (st_contains(wkb_geometry,ST_GeomFromText('POINT
> (*/7853690.3631838141000000 -5506204.5232773330000000/*)')) = TRUE)
> *************************
>
> Similar WFS query to GeoServer works perfectly.
>
> It would be very helpful if someone can help me on it. Thanks a lot in
> advance.
>
> Map File looks like:
>
> **************************************************
> MAP
>  NAME "Sample_WMS"
>  CONFIG "PROJ_LIB" "C:\ms4w\proj\nad"
>  CONFIG "MS_ERRORFILE" "C:/Data/ms_tmp/ms_error.txt"
>  CONFIG "CPL_DEBUG" "ON"
>  CONFIG "PROJ_DEBUG" "ON"
>  STATUS ON
>  PROJECTION
>    "init=epsg:27700"
>  END
>
>  WEB
>    IMAGEPATH "C:/Data/ms_tmp/"
>    IMAGEURL "/ms_tmp/"
>    METADATA
>    "wfs_enable_request" "*"
>    "wfs_title"        "My Global Map WFS Server"
>    "wfs_srs"          "EPSG:4326 EPSG:900913 EPSG:27700"
>    "wfs_boundingbox"    "EPSG:27700 749.099975585938 -90036.5
> 660460.875 1227306.5"
>    END
>  END
>
>  LAYER
>    NAME "SampleLayer"
>    STATUS DEFAULT
>    TYPE POLYGON
>    PROJECTION
>    "init=epsg:27700"
>    END
>    CONNECTIONTYPE POSTGIS
>    CONNECTION "host=localhost port=5432 dbname=SampleGeoDataTable
> user=postgres password=hahaha"
>    DATA "wkb_geometry from SampleLayer"
>    CLASS
>      STYLE
>      COLOR      0 100 255
>      OUTLINECOLOR 0 0 0
>      END
>    END
>
>    METADATA
>    "wfs_enable_request" "*"
>    "wfs_title"        "Sample WFS"
>    "wfs_srs"          "EPSG:27700 EPSG:4326 EPSG:900913"
>    "wfs_boundingbox"    "EPSG:27700 749.099975585938 -90036.5
> 660460.875 1227306.5"
>    "gml_include_items" "all"
>    END
>  END
> END
> **************************************************
>
> Regards,
> Kajod
>
>










_______________________________________________
mapserver-users mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/mapserver-users