AW: [mapserver-users] Spatial Filter with WFS

Fischer, Andreas Andreas.Fischer at kreis-unna.de
Tue Nov 23 11:30:28 EST 2010


Hi Jukka,
I tried another getFeature request using your syntax. I only replaced the 'EPSG:4326' to 'EPSG:25832' since the coordinates are in this reference system. Unfortunately I got the same result. It doesn't matter if I ask for VERSION=1.1.0 or VERSION=1.0.0 - I tried out both.

Request

http://192.168.2.117/cgi-bin/mapserv?map=/mapserver/mapfiles/u218768/ku_testwfs.map&REQUEST=getFeature&typename=folie001&SERVICE=WFS&VERSION=1.0.0&
Filter=
<ogc:Filter>
      <ogc:Intersects xmlns:gml='http://www.opengis.net/gml'>
      <ogc:PropertyName xmlns:topp="http://www.openplans.org/topp">topp:the_geom</ogc:PropertyName>
<gml:Polygon srsName="EPSG:25832">
      <gml:outerBoundaryIs>
      <gml:LinearRing>
      <gml:coordinates cs="," decimal="." ts=" ">409350.0,5709890.0 409350.0,5709910.0 409370.0,5709910.0 409370.0,5709890.0 409350.0,5709890.0</gml:coordinates>
      </gml:LinearRing>
      </gml:outerBoundaryIs>
      </gml:Polygon>
      </ogc:Intersects>
</ogc:Filter>


Response

  <?xml version="1.0" encoding="ISO-8859-1" ?> 
- <wfs:FeatureCollection xmlns:ms="http://mapserver.gis.umn.edu/mapserver" xmlns:gml="http://www.opengis.net/gml" xmlns:wfs="http://www.opengis.net/wfs" xmlns:ogc="http://www.opengis.net/ogc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://mapserver.gis.umn.edu/mapserver http://192.168.2.117/cgi-bin/mapserv?map=/mapserver/mapfiles/u218768/ku_testwfs.map&SERVICE=WFS&VERSION=1.1.0&REQUEST=DescribeFeatureType&TYPENAME=folie001&OUTPUTFORMAT=text/xml; subtype=gml/3.1.1 http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd" numberOfFeatures="4">
- <gml:boundedBy>
- <gml:Envelope srsName="EPSG:25832">
  <gml:lowerCorner>-1.000000 -1.000000</gml:lowerCorner> 
  <gml:upperCorner>-1.000000 -1.000000</gml:upperCorner> 
  </gml:Envelope>
  </gml:boundedBy>
  </wfs:FeatureCollection>

The only difference I could detect is the coordinates within the Envelope. 

With PostGIS datasource it is:
 
  	<gml:lowerCorner>-1.000000 -1.000000</gml:lowerCorner> 
  	<gml:upperCorner>-1.000000 -1.000000</gml:upperCorner>

With MapInfo it is:

	<gml:lowerCorner>-1.000000 -1.000000</gml:lowerCorner> 
	<gml:upperCorner>409388.231116 5709944.987211</gml:upperCorner>

Even if the upperCorner is set, it is not the upper Corner of the featureCollection (4 features), that should be selected by the filter condition. And in both cases I did not change the EXTENT of the MAP und LAYER sections (EXTENT 389965 5693582 420177 5732815, "wfs_extent" "389965 5693582 420177 5732815").

So please let me know, if you have another idea to solve this problem
Tanks again!
Best regards
Andreas



Mit freundlichen Grüßen
Im Auftrag

Andreas Fischer

Kreis Unna - Der Landrat
Zentrale Datenverarbeitung
Friedrich-Ebert-Straße 17
59425 Unna

Fon 02 3 03 27-44 16
Fax 0 23 03 27-28 96
andreas.fischer at kreis-unna.de
www.kreis-unna.de

Von: Rahkonen Jukka [mailto:Jukka.Rahkonen at mmmtike.fi] 
Gesendet: Dienstag, 23. November 2010 15:01
An: Yewondwossen Assefa; Fischer, Andreas
Cc: mapserver-users at lists.osgeo.org
Betreff: Re: [mapserver-users] Spatial Filter with WFS

Hi,
 
Andreas, you may be without a wsf:Query element.  Here is a WFS 1.0.0 request that works with Geoserver.
 
<?xml version="1.0" encoding="ISO-8859-1"?>
<wfs:GetFeature xmlns:ogc="http://www.opengis.net/ogc" xmlns:gml="http://www.opengis.net/gml" xmlns:wfs="http://www.opengis.net/wfs" service="WFS" version="1.0.0" maxFeatures="1000" outputFormat="GML2">
<wfs:Query xmlns:topp="http://www.openplans.org/topp" typeName="topp:states">
<ogc:Filter>
<ogc:Intersects xmlns:gml='http://www.opengis.net/gml' >
<ogc:PropertyName xmlns:topp="http://www.openplans.org/topp">
topp:the_geom</ogc:PropertyName>
<gml:Polygon srsName="EPSG:4326">
<gml:outerBoundaryIs>
<gml:LinearRing>
<gml:coordinates cs="," decimal="." ts=" ">
409350.0,5709890.0 409350.0,5709910.0 409370.0,5709910.0 409370.0,5709890.0 409350.0,5709890.0</gml:coordinates>
</gml:LinearRing>
</gml:outerBoundaryIs>
</gml:Polygon>
</ogc:Intersects>
</ogc:Filter>
</wfs:Query>
</wfs:GetFeature>
 
Y.A, a question for you:  I have thought that also the filters should be presented as gml3 with WFS 1.1.0 and thus posList should be used instead of coordinates. Am I wrong with this belief?  By the way, this is how Geoserver 2.1 beta 1 writes out on multipolygon as gml3
 
  
<topp:the_geom>
<gml:MultiSurface srsDimension="2" srsName="urn:x-ogc:def:crs:EPSG:4326">
<gml:surfaceMember>
<gml:Polygon>
<gml:exterior>
<gml:LinearRing>
<gml:posList>
37.51099000000001 -88.071564 37.476273000000006 -88.087883 37.442852 -88.311707 37.40930899999999 -88.359177 
 
-Jukka Rahkonen-
 
 

________________________________________
Lähettäjä: mapserver-users-bounces at lists.osgeo.org [mailto:mapserver-users-bounces at lists.osgeo.org] Puolesta Yewondwossen Assefa
Lähetetty: 23. marraskuuta 2010 15:43
Vastaanottaja: Rahkonen Jukka; Fischer, Andreas
Kopio: mapserver-users at lists.osgeo.org
Aihe: Re: [mapserver-users] Spatial Filter with WFS
Hi all,

As noted MapServer does not support gml:Surface. The original request with gml:Polygon seems to be correct.  
Andreas, is it possible to package it and send it to me off list. I can quickly check what the issue is.

regards,



 as noted Mapserver does not support gml:Surface. 

On 23/11/2010 8:26 AM, Rahkonen Jukka wrote: 
Hi,
 
This one may not be the only problem, but I would start by creating a valid WFS 1.1.0 request by giving a filter as gml3 or alternatively go on with using gml2 filter but changing version to WFS 1.0.0.  Here below is a WFS 1.1.0 request that works against deegree.  It does not necessarily work against Mapserver because it can well be that Mapserver does not support gml:Surface, even if the surface is a plain polygon as in this  case.  However, you see that gml3 does not use <gml:coordinates, it is using <gml:posList and it would be a miracle or Mapserver bug or both if your request works.
 
<?xml version="1.0" encoding="ISO-8859-1"?>
<wfs:GetFeature xmlns:ogc="http://www.opengis.net/ogc" xmlns:gml="http://www.opengis.net/gml" xmlns:wfs="http://www.opengis.net/wfs" service="WFS" version="1.1.0" maxFeatures="1000" outputFormat="text/xml; subtype=gml/3.1.1">
<wfs:Query xmlns:app="http://www.deegree.org/app" srsName="EPSG:26912" typeName="app:Counties">
<ogc:Filter>
<ogc:Intersects xmlns:gml='http://www.opengis.net/gml' >
<ogc:PropertyName xmlns:app="http://www.deegree.org/app">
app:position</ogc:PropertyName>
<gml:Surface srsName='EPSG:26912' >
<gml:patches>
<gml:PolygonPatch>
<gml:exterior>
<gml:LinearRing>
<gml:posList srsDimension='2' count='6'>
87.0 198.0 149.0 239.0 261.0 202.0 263.0 89.0 161.0 80.0 87.0 198.0</gml:posList>
</gml:LinearRing>
</gml:exterior>
</gml:PolygonPatch>
</gml:patches>
</gml:Surface>
</ogc:Intersects>
</ogc:Filter>
</wfs:Query>
</wfs:GetFeature>
 
-Jukka Rahkonen-
 
 
 
 
--------------------------------------------------------------------------------
Lähettäjä: mapserver-users-bounces at lists.osgeo.org [mailto:mapserver-users-bounces at lists.osgeo.org] Puolesta Fischer, Andreas
Lähetetty: 22. marraskuuta 2010 19:36
Vastaanottaja: mapserver-users at lists.osgeo.org
Aihe: [mapserver-users] Spatial Filter with WFS
 

Dear MapServer-User,
 
I configured MapServer version 5.6.5 as WMS- and WFS-Server to offer information about land and properties. I use PostgreSQL/PostGIS (8.4.4/1.5.1) as datastore in this case. The spatial reference system is EPSG:25832 und the type of the geometry is MULTIPOLYGON. OS is Suse Linux Enterprise Server 11, Servicepack1.
 

WMS and WFS work fine until I use a spatial filter within the getFeature-Request of the WFS. In this case the response doesn't deliver any features. Nevertheless the number of features (e.g. numberOf Features='4') is correct. I tried this out with a couple of different boundingboxes and the known number of features that intersect these boundigboxes. In all cases I do not get any features back, but always the right number. So it seems that at least the intersection of the boundingbox and my data works correctly.
 
Please take a look at the following request and response that illustrate that problem:
 
Request:
 
http://myserver/cgi-bin/mapserv?map=/mapserver/mapfiles/u218768/ku_testwfs.map&REQUEST=getFeature&typename=folie001&SERVICE=WFS&VERSION=1.1.0&
 
Filter=<ogc:Filter>
 
                <Intersects>
 
                        <ogc:PropertyName>msGeometry</ogc:PropertyName>
 
                        <gml:Polygon srsName='EPSG:25832'>
 
                                <gml:outerBoundaryIs>
 
                                        <gml:LinearRing>
 
                                                <gml:coordinates>409350,5709890 409350,5709910 409370,5709910 409370,5709890 409350,5709890</gml:coordinates>
 
                                        </gml:LinearRing>
 
                                </gml:outerBoundaryIs>
 
                        </gml:Polygon>
 
                </Intersects>
 
        </ogc:Filter>
 

Response
 

<?xml version="1.0" encoding="ISO-8859-1" ?> 
 
<wfs:FeatureCollection xmlns:ms="http://mapserver.gis.umn.edu/mapserver" xmlns:gml="http://www.opengis.net/gml" xmlns:wfs=http://www.opengis.net/wfs xmlns:ogc="http://www.opengis.net/ogc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://mapserver.gis.umn.edu/mapserver http://myserver/cgi-bin/mapserv?map=/mapserver/mapfiles/u218768/ku_testwfs.map&SERVICE=WFS&VERSION=1.1.0&REQUEST=DescribeFeatureType&TYPENAME=folie001&OUTPUTFORMAT=text/xml; subtype=gml/3.1.1 http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd" numberOfFeatures="4">
 
<gml:boundedBy>
 
<gml:Envelope srsName="EPSG:25832">
 
                        <gml:lowerCorner>-1.000000 -1.000000</gml:lowerCorner> 
 
                                <gml:upperCorner>-1.000000 -1.000000</gml:upperCorner> 
 
                </gml:Envelope>
 
        </gml:boundedBy>
 
</wfs:FeatureCollection>
 
 
 
Indeed of this behavior the WFS returns features when I do not use a spatial filter. Therefore in my opinion the WFS should be configured right in general. To me the spatial filter seems to be the problem. Unfortunately I do not have any ideas what is going wrong.
 

For more information you can take a look at my MapFile and a part of the capabilities document returned from the WFS below:
 

MAP
 
        NAME "ku_testwfs"
 
        STATUS ON
 
        SIZE 400 520
 
        EXTENT 389965 5693582 420177 5732815
 
        UNITS METERS
 
        PROJECTION
 
                "init=epsg:25832"
 
        END
 
        SYMBOLSET "/mapserver/symbols/symbols_alk.sym"
 
        FONTSET "/mapserver/fonts/fonts.fnt"
 
        IMAGECOLOR 255 255 255
 
        WEB
 
                IMAGEPATH "/mapbender/mb262/http/tmp/"
 
                IMAGEURL "http://myserver/mapbender/tmp/"
 
                METADATA
 
                        "ows_onlineresource" "http://myserver/cgi-bin/mapserv?map=/mapserver/mapfiles/u218768/ku_testwfs.map"
 
                        "ows_title" "Liegenschaftskarte, Kreis Unna"
 
                        "ows_accessconstraints" "Nutzung nur für den Dienstgebrauch."
 
                        "ows_abstract" "Flurstücksfolie der Liegenschaftskarte."
 
                        "ows_contactperson" "Andreas Fischer"
 
                        "ows_contactorganization" "Kreis Unna"
 
                        "ows_contactposition" "Zentrale Datenverarbeitung, Geodatenmanagement"
 
                        "wms_srs" "EPSG:25832 EPSG:31462 EPSG:31463 EPSG:31466 EPSG:31467 EPSG:4326"
 
                        "wms_feature_info_mime_type" "text/html"
 
                        "wfs_srs" "EPSG:25832"
 
                END #METADATA  
 
        END #WEB
 
        
 
        LAYER
 
                NAME "folie001"
 
                STATUS ON
 
                TYPE POLYGON
 
                DUMP TRUE
 
                CONNECTIONTYPE postgis
 
                CONNECTION "user=dbuser password=dbpassword dbname=dbname host=dbhost port=dbport"
 
                DATA "the_geom from ku_view_folie001 USING UNIQUE objnr USING SRID=25832"
 
    
 
                METADATA
 
                        "ows_title" "Flurstücke"   
 
                        "wms_srs" "EPSG:25832 EPSG:31462 EPSG:31463 EPSG:31466 EPSG:31467 EPSG:4326"    
 
                        "wms_feature_info_mime_type" "text/html"
 
                        "wfs_srs" "EPSG:25832"
 
                        "wfs_extent" "389965 5693582 420177 5732815" 
 
                        "gml_include_items" "all"
 
                        "gml_featureid" "objnr"
 
                END #METADATA
 
        
 
                CLASS
 
                        NAME "Flurstücke"
 
                        STYLE
 
                                OUTLINECOLOR 0 0 0
 
                                WIDTH 1
 
                        END # STYLE
 
                END  # CLASS
 
        END #LAYER
 
END #MAPFILE
 
[...]
 
- <     FeatureTypeList>
 
- <     Operations>
 
  <Query /> 
 
  </Operations>
 
- <FeatureType>
 
  <Name>folie001</Name> 
 
  <Title>Flurstücke</Title> 
 
  <SRS>EPSG:25832</SRS> 
 
  <LatLongBoundingBox minx="389965" miny="5.69358e+06" maxx="420177" maxy="5.73282e+06" /> 
 
 </FeatureType>
 
 </FeatureTypeList>
 
- <ogc:Filter_Capabilities>
 
- <ogc:Spatial_Capabilities>
 
- <ogc:Spatial_Operators>
 
  <ogc:Equals /> 
 
  <ogc:Disjoint /> 
 
  <ogc:Touches /> 
 
  <ogc:Within /> 
 
  <ogc:Overlaps /> 
 
  <ogc:Crosses /> 
 
  <ogc:Intersect /> 
 
  <ogc:Contains /> 
 
  <ogc:DWithin /> 
 
  <ogc:BBOX /> 
 
 </ogc:Spatial_Operators>
 
 </ogc:Spatial_Capabilities>
 
- <ogc:Scalar_Capabilities>
 
  <ogc:Logical_Operators /> 
 
- <ogc:Comparison_Operators>
 
  <ogc:Simple_Comparisons /> 
 
  <ogc:Like /> 
 
  <ogc:Between /> 
 
 </ogc:Comparison_Operators>
 
 </ogc:Scalar_Capabilities>
 
 </ogc:Filter_Capabilities>
 
 </WFS_Capabilities>
 

(The LatLongBoundingBox in this case is obviously not in units of LatLon but represent the boundingbox in the offered SRS 25832. This seems to be strange since thes doesn' t occur in the WMS-capabilities document. In this document the LatLongBoundingBox und the BoundingBox in the source SRS are both all right.)
 
I even tried different versions of MapServer and I discovered a slight difference with other versions. If I change my datasource from PostGIS to OGR/MapInfo Tab former versions of MapServer (5.4.2/5.2.3) provide features as well. But just in case of OGR/MapInfo Tab - not with PostGIS in use! As I have to use PostGIS I'm interested in any hints to solve this problem.
 
Therefore I would be glad to hear from you!
 

Thanks so far and best regards!
 
Andreas
 

Mit freundlichen Grüßen
 
Im Auftrag
 
Andreas Fischer
 
Kreis Unna - Der Landrat
 
Zentrale Datenverarbeitung
 
Friedrich-Ebert-Straße 17
 
59425 Unna
 
Fon 02 3 03 27-44 16
 
Fax 0 23 03 27-28 96
 
andreas.fischer at kreis-unna.de
 
www.kreis-unna.de
 

Diese E-Mail wurde beim Ausgang auf Viren geprueft. Wegen der potentiellen Gefahr auf den Uebertragungswegen wird zu einer Vireneingangskontrolle geraten. Eine Haftung für Virenfreiheitwird ausgeschlossen.

_______________________________________________
mapserver-users mailing list
mapserver-users at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapserver-users



-- 
----------------------------------------------------------------
Assefa Yewondwossen           
Software Analyst   

Email: yassefa at dmsolutions.ca    
http://www.dmsolutions.ca/

Phone: (613) 565-5056 (ext 14)
Fax:   (613) 565-0925
----------------------------------------------------------------

Diese E-Mail wurde beim Ausgang auf Viren geprueft. Wegen der 
potentiellen Gefahr auf den Uebertragungswegen wird zu einer 
Vireneingangskontrolle geraten. Eine Haftung für Virenfreiheit
wird ausgeschlossen.





More information about the mapserver-users mailing list