<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>Spatial Filter with WFS</TITLE>
<META content="text/html; charset=iso-8859-1" http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 8.00.6001.18702"></HEAD>
<BODY>
<DIV><FONT color=#0000ff size=2 face=Arial>Hi,<BR> <BR>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.<BR> <BR><?xml version="1.0"
encoding="ISO-8859-1"?><BR><wfs:GetFeature xmlns:ogc="<A
href="http://www.opengis.net/ogc">http://www.opengis.net/ogc</A>" xmlns:gml="<A
href="http://www.opengis.net/gml">http://www.opengis.net/gml</A>" xmlns:wfs="<A
href="http://www.opengis.net/wfs">http://www.opengis.net/wfs</A>" service="WFS"
version="1.1.0" maxFeatures="1000" outputFormat="text/xml;
subtype=gml/3.1.1"><BR><wfs:Query xmlns:app="<A
href="http://www.deegree.org/app">http://www.deegree.org/app</A>"
srsName="EPSG:26912"
typeName="app:Counties"><BR><ogc:Filter><BR><ogc:Intersects
xmlns:gml='http://www.opengis.net/gml' ><BR><ogc:PropertyName
xmlns:app="<A
href="http://www.deegree.org/app">http://www.deegree.org/app</A>"><BR>app:position</ogc:PropertyName><BR><gml:Surface
srsName='EPSG:26912'
><BR><gml:patches><BR><gml:PolygonPatch><BR><gml:exterior><BR><gml:LinearRing><BR><gml:posList
srsDimension='2' count='6'><BR>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><BR></gml:LinearRing><BR></gml:exterior><BR></gml:PolygonPatch><BR></gml:patches><BR></gml:Surface><BR></ogc:Intersects><BR></ogc:Filter><BR></wfs:Query><BR></wfs:GetFeature></FONT></DIV>
<DIV> </DIV>
<DIV><FONT color=#0000ff size=2 face=Arial>-Jukka
Rahkonen-<BR> </FONT></DIV>
<DIV> </DIV>
<DIV><FONT color=#0000ff size=2 face=Arial></FONT> </DIV>
<DIV> </DIV>
<DIV><FONT color=#0000ff size=2
face=Arial>--------------------------------------------------------------------------------<BR>Lähettäjä:
<A
href="mailto:mapserver-users-bounces@lists.osgeo.org">mapserver-users-bounces@lists.osgeo.org</A>
[mailto:mapserver-users-bounces@lists.osgeo.org] Puolesta Fischer,
Andreas<BR>Lähetetty: 22. marraskuuta 2010 19:36<BR>Vastaanottaja: <A
href="mailto:mapserver-users@lists.osgeo.org">mapserver-users@lists.osgeo.org</A><BR>Aihe:
[mapserver-users] Spatial Filter with WFS</FONT></DIV>
<DIV> </DIV><FONT color=#0000ff size=2 face=Arial>
<DIV><BR>Dear MapServer-User,</DIV>
<DIV> </DIV>
<DIV>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.</DIV>
<DIV> </DIV>
<DIV><BR>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.</DIV>
<DIV> </DIV>
<DIV>Please take a look at the following request and response that illustrate
that problem:</DIV>
<DIV> </DIV>
<DIV>Request:</DIV>
<DIV> </DIV>
<DIV><A
href="http://myserver/cgi-bin/mapserv?map=/mapserver/mapfiles/u218768/ku_testwfs.map&REQUEST=getFeature&typename=folie001&SERVICE=WFS&VERSION=1.1.0">http://myserver/cgi-bin/mapserv?map=/mapserver/mapfiles/u218768/ku_testwfs.map&REQUEST=getFeature&typename=folie001&SERVICE=WFS&VERSION=1.1.0</A>&</DIV>
<DIV> </DIV>
<DIV>Filter=<ogc:Filter></DIV>
<DIV> </DIV>
<DIV>
<Intersects></DIV>
<DIV> </DIV>
<DIV>
<ogc:PropertyName>msGeometry</ogc:PropertyName></DIV>
<DIV> </DIV>
<DIV>
<gml:Polygon srsName='EPSG:25832'></DIV>
<DIV> </DIV>
<DIV>
<gml:outerBoundaryIs></DIV>
<DIV> </DIV>
<DIV>
<gml:LinearRing></DIV>
<DIV> </DIV>
<DIV>
<gml:coordinates>409350,5709890 409350,5709910 409370,5709910
409370,5709890 409350,5709890</gml:coordinates></DIV>
<DIV> </DIV>
<DIV>
</gml:LinearRing></DIV>
<DIV> </DIV>
<DIV>
</gml:outerBoundaryIs></DIV>
<DIV> </DIV>
<DIV>
</gml:Polygon></DIV>
<DIV> </DIV>
<DIV>
</Intersects></DIV>
<DIV> </DIV>
<DIV> </ogc:Filter></DIV>
<DIV> </DIV>
<DIV><BR>Response</DIV>
<DIV> </DIV>
<DIV><BR><?xml version="1.0" encoding="ISO-8859-1" ?> </DIV>
<DIV> </DIV>
<DIV><wfs:FeatureCollection xmlns:ms="<A
href="http://mapserver.gis.umn.edu/mapserver">http://mapserver.gis.umn.edu/mapserver</A>"
xmlns:gml="<A href="http://www.opengis.net/gml">http://www.opengis.net/gml</A>"
xmlns:wfs=http://www.opengis.net/wfs xmlns:ogc="<A
href="http://www.opengis.net/ogc">http://www.opengis.net/ogc</A>" xmlns:xsi="<A
href="http://www.w3.org/2001/XMLSchema-instance">http://www.w3.org/2001/XMLSchema-instance</A>"
xsi:schemaLocation="<A
href="http://mapserver.gis.umn.edu/mapserver">http://mapserver.gis.umn.edu/mapserver</A>
<A
href="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">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</A>;
subtype=gml/3.1.1 <A
href="http://www.opengis.net/wfs">http://www.opengis.net/wfs</A> <A
href="http://schemas.opengis.net/wfs/1.1.0/wfs.xsd">http://schemas.opengis.net/wfs/1.1.0/wfs.xsd</A>"
numberOfFeatures="4"></DIV>
<DIV> </DIV>
<DIV><gml:boundedBy></DIV>
<DIV> </DIV>
<DIV><gml:Envelope srsName="EPSG:25832"></DIV>
<DIV> </DIV>
<DIV>
<gml:lowerCorner>-1.000000 -1.000000</gml:lowerCorner> </DIV>
<DIV> </DIV>
<DIV>
<gml:upperCorner>-1.000000 -1.000000</gml:upperCorner> </DIV>
<DIV> </DIV>
<DIV>
</gml:Envelope></DIV>
<DIV> </DIV>
<DIV> </gml:boundedBy></DIV>
<DIV> </DIV>
<DIV></wfs:FeatureCollection></DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>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.</DIV>
<DIV> </DIV>
<DIV><BR>For more information you can take a look at my MapFile and a part of
the capabilities document returned from the WFS below:</DIV>
<DIV> </DIV>
<DIV><BR>MAP</DIV>
<DIV> </DIV>
<DIV> NAME "ku_testwfs"</DIV>
<DIV> </DIV>
<DIV> STATUS ON</DIV>
<DIV> </DIV>
<DIV> SIZE 400 520</DIV>
<DIV> </DIV>
<DIV> EXTENT 389965 5693582 420177
5732815</DIV>
<DIV> </DIV>
<DIV> UNITS METERS</DIV>
<DIV> </DIV>
<DIV> PROJECTION</DIV>
<DIV> </DIV>
<DIV>
"init=epsg:25832"</DIV>
<DIV> </DIV>
<DIV> END</DIV>
<DIV> </DIV>
<DIV> SYMBOLSET
"/mapserver/symbols/symbols_alk.sym"</DIV>
<DIV> </DIV>
<DIV> FONTSET
"/mapserver/fonts/fonts.fnt"</DIV>
<DIV> </DIV>
<DIV> IMAGECOLOR 255 255 255</DIV>
<DIV> </DIV>
<DIV> WEB</DIV>
<DIV> </DIV>
<DIV>
IMAGEPATH "/mapbender/mb262/http/tmp/"</DIV>
<DIV> </DIV>
<DIV>
IMAGEURL "<A
href="http://myserver/mapbender/tmp/">http://myserver/mapbender/tmp/</A>"</DIV>
<DIV> </DIV>
<DIV>
METADATA</DIV>
<DIV> </DIV>
<DIV>
"ows_onlineresource" "<A
href="http://myserver/cgi-bin/mapserv?map=/mapserver/mapfiles/u218768/ku_testwfs.map">http://myserver/cgi-bin/mapserv?map=/mapserver/mapfiles/u218768/ku_testwfs.map</A>"</DIV>
<DIV> </DIV>
<DIV>
"ows_title" "Liegenschaftskarte, Kreis Unna"</DIV>
<DIV> </DIV>
<DIV>
"ows_accessconstraints" "Nutzung nur für den Dienstgebrauch."</DIV>
<DIV> </DIV>
<DIV>
"ows_abstract" "Flurstücksfolie der Liegenschaftskarte."</DIV>
<DIV> </DIV>
<DIV>
"ows_contactperson" "Andreas Fischer"</DIV>
<DIV> </DIV>
<DIV>
"ows_contactorganization" "Kreis Unna"</DIV>
<DIV> </DIV>
<DIV>
"ows_contactposition" "Zentrale Datenverarbeitung, Geodatenmanagement"</DIV>
<DIV> </DIV>
<DIV>
"wms_srs" "EPSG:25832 EPSG:31462 EPSG:31463 EPSG:31466 EPSG:31467
EPSG:4326"</DIV>
<DIV> </DIV>
<DIV>
"wms_feature_info_mime_type" "text/html"</DIV>
<DIV> </DIV>
<DIV>
"wfs_srs" "EPSG:25832"</DIV>
<DIV> </DIV>
<DIV>
END #METADATA </DIV>
<DIV> </DIV>
<DIV> END #WEB</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> LAYER</DIV>
<DIV> </DIV>
<DIV>
NAME "folie001"</DIV>
<DIV> </DIV>
<DIV>
STATUS ON</DIV>
<DIV> </DIV>
<DIV>
TYPE POLYGON</DIV>
<DIV> </DIV>
<DIV>
DUMP TRUE</DIV>
<DIV> </DIV>
<DIV>
CONNECTIONTYPE postgis</DIV>
<DIV> </DIV>
<DIV>
CONNECTION "user=dbuser password=dbpassword dbname=dbname host=dbhost
port=dbport"</DIV>
<DIV> </DIV>
<DIV>
DATA "the_geom from ku_view_folie001 USING UNIQUE objnr USING SRID=25832"</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>
METADATA</DIV>
<DIV> </DIV>
<DIV>
"ows_title" "Flurstücke" </DIV>
<DIV> </DIV>
<DIV>
"wms_srs" "EPSG:25832 EPSG:31462 EPSG:31463 EPSG:31466 EPSG:31467
EPSG:4326" </DIV>
<DIV> </DIV>
<DIV>
"wms_feature_info_mime_type" "text/html"</DIV>
<DIV> </DIV>
<DIV>
"wfs_srs" "EPSG:25832"</DIV>
<DIV> </DIV>
<DIV>
"wfs_extent" "389965 5693582 420177 5732815" </DIV>
<DIV> </DIV>
<DIV>
"gml_include_items" "all"</DIV>
<DIV> </DIV>
<DIV>
"gml_featureid" "objnr"</DIV>
<DIV> </DIV>
<DIV>
END #METADATA</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>
CLASS</DIV>
<DIV> </DIV>
<DIV>
NAME "Flurstücke"</DIV>
<DIV> </DIV>
<DIV>
STYLE</DIV>
<DIV> </DIV>
<DIV>
OUTLINECOLOR 0 0 0</DIV>
<DIV> </DIV>
<DIV>
WIDTH 1</DIV>
<DIV> </DIV>
<DIV>
END # STYLE</DIV>
<DIV> </DIV>
<DIV>
END # CLASS</DIV>
<DIV> </DIV>
<DIV> END #LAYER</DIV>
<DIV> </DIV>
<DIV>END #MAPFILE</DIV>
<DIV> </DIV>
<DIV>[…]</DIV>
<DIV> </DIV>
<DIV>- < FeatureTypeList></DIV>
<DIV> </DIV>
<DIV>- < Operations></DIV>
<DIV> </DIV>
<DIV> <Query /> </DIV>
<DIV> </DIV>
<DIV> </Operations></DIV>
<DIV> </DIV>
<DIV>- <FeatureType></DIV>
<DIV> </DIV>
<DIV> <Name>folie001</Name> </DIV>
<DIV> </DIV>
<DIV> <Title>Flurstücke</Title> </DIV>
<DIV> </DIV>
<DIV> <SRS>EPSG:25832</SRS> </DIV>
<DIV> </DIV>
<DIV> <LatLongBoundingBox minx="389965" miny="5.69358e+06"
maxx="420177" maxy="5.73282e+06" /> </DIV>
<DIV> </DIV>
<DIV> </FeatureType></DIV>
<DIV> </DIV>
<DIV> </FeatureTypeList></DIV>
<DIV> </DIV>
<DIV>- <ogc:Filter_Capabilities></DIV>
<DIV> </DIV>
<DIV>- <ogc:Spatial_Capabilities></DIV>
<DIV> </DIV>
<DIV>- <ogc:Spatial_Operators></DIV>
<DIV> </DIV>
<DIV> <ogc:Equals /> </DIV>
<DIV> </DIV>
<DIV> <ogc:Disjoint /> </DIV>
<DIV> </DIV>
<DIV> <ogc:Touches /> </DIV>
<DIV> </DIV>
<DIV> <ogc:Within /> </DIV>
<DIV> </DIV>
<DIV> <ogc:Overlaps /> </DIV>
<DIV> </DIV>
<DIV> <ogc:Crosses /> </DIV>
<DIV> </DIV>
<DIV> <ogc:Intersect /> </DIV>
<DIV> </DIV>
<DIV> <ogc:Contains /> </DIV>
<DIV> </DIV>
<DIV> <ogc:DWithin /> </DIV>
<DIV> </DIV>
<DIV> <ogc:BBOX /> </DIV>
<DIV> </DIV>
<DIV> </ogc:Spatial_Operators></DIV>
<DIV> </DIV>
<DIV> </ogc:Spatial_Capabilities></DIV>
<DIV> </DIV>
<DIV>- <ogc:Scalar_Capabilities></DIV>
<DIV> </DIV>
<DIV> <ogc:Logical_Operators /> </DIV>
<DIV> </DIV>
<DIV>- <ogc:Comparison_Operators></DIV>
<DIV> </DIV>
<DIV> <ogc:Simple_Comparisons /> </DIV>
<DIV> </DIV>
<DIV> <ogc:Like /> </DIV>
<DIV> </DIV>
<DIV> <ogc:Between /> </DIV>
<DIV> </DIV>
<DIV> </ogc:Comparison_Operators></DIV>
<DIV> </DIV>
<DIV> </ogc:Scalar_Capabilities></DIV>
<DIV> </DIV>
<DIV> </ogc:Filter_Capabilities></DIV>
<DIV> </DIV>
<DIV> </WFS_Capabilities></DIV>
<DIV> </DIV>
<DIV><BR>(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.)</DIV>
<DIV> </DIV>
<DIV>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.</DIV>
<DIV> </DIV>
<DIV>Therefore I would be glad to hear from you!</DIV>
<DIV> </DIV>
<DIV><BR>Thanks so far and best regards!</DIV>
<DIV> </DIV>
<DIV>Andreas</DIV>
<DIV> </DIV>
<DIV><BR>Mit freundlichen Grüßen</DIV>
<DIV> </DIV>
<DIV>Im Auftrag</DIV>
<DIV> </DIV>
<DIV>Andreas Fischer</DIV>
<DIV> </DIV>
<DIV>Kreis Unna - Der Landrat</DIV>
<DIV> </DIV>
<DIV>Zentrale Datenverarbeitung</DIV>
<DIV> </DIV>
<DIV>Friedrich-Ebert-Straße 17</DIV>
<DIV> </DIV>
<DIV>59425 Unna</DIV>
<DIV> </DIV>
<DIV>Fon 02 3 03 27-44 16</DIV>
<DIV> </DIV>
<DIV>Fax 0 23 03 27-28 96</DIV>
<DIV> </DIV>
<DIV><A
href="mailto:andreas.fischer@kreis-unna.de">andreas.fischer@kreis-unna.de</A></DIV>
<DIV> </DIV>
<DIV><A href="http://www.kreis-unna.de">www.kreis-unna.de</A></DIV>
<DIV> </DIV>
<DIV><BR>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.<BR></FONT></DIV></BODY></HTML>