[mapserver-users] WFS Intersect with gml:box
Joaquín Rodriguez-Guerra Urcelay
jrguerra at gmv.com
Tue Apr 12 06:49:35 PDT 2011
I have found out that composed BBOX queries using AND return unexpected results too (when using mysql data source, they work correctly using postgres):
Test Queries.
1.AND and 2 BBOX: Returns only the first feature (-10,-10) and that feature is out of the boundinx boxes
http://localhost:8080/cgi-bin/mywfs?SERVICE=WFS&VERSION=1.0.0&request=getfeature&typename=PositionReal&Filter= <Filter>
<And>
<BBOX>
<PropertyName?>msGeometry</PropertyName> <Box>
<coordinates decimal="." cs="," ts=" ">-7.874614621788295,14.799588929907502 15.519013391777994,28.776978474820144</coordinates>
</Box>
</BBOX> <BBOX>
<PropertyName?>msGeometry</PropertyName> <Box>
<coordinates decimal="." cs="," ts=" ">-100.82219958499486,-57.14285725714286 100.82219958499486,57.14285725714286</coordinates>
</Box>
</BBOX>
</And>
</Filter>
2. AND, but only the first BBOX. Returns the 3 features, but feature 1 (-10,-10) is out of the bounding box
http://localhost:8080/cgi-bin/mywfs?SERVICE=WFS&VERSION=1.0.0&request=getfeature&typename=PositionReal&Filter= <Filter>
<And>
<BBOX>
<PropertyName?>msGeometry</PropertyName> <Box>
<coordinates decimal="." cs="," ts=" ">-7.874614621788295,14.799588929907502 15.519013391777994,28.776978474820144</coordinates>
</Box>
</BBOX>
</And>
</Filter>
3. The First BBOX, without AND. This one works :)
http://localhost:8080/cgi-bin/mywfs?SERVICE=WFS&VERSION=1.0.0&request=getfeature&typename=PositionReal&Filter= <Filter>
<BBOX>
<PropertyName?>msGeometry</PropertyName> <Box>
<coordinates decimal="." cs="," ts=" ">-7.874614621788295,14.799588929907502 15.519013391777994,28.776978474820144</coordinates>
</Box>
</BBOX>
</Filter>
-----Mensaje original-----
De: mapserver-users-bounces at lists.osgeo.org [mailto:mapserver-users-bounces at lists.osgeo.org] En nombre de Joaquín Rodriguez-Guerra Urcelay
Enviado el: viernes, 01 de abril de 2011 21:09
Para: mapserver-users at lists.osgeo.org
CC: Óscar Luengo Herrero
Asunto: RE: [mapserver-users] WFS Intersect with gml:box
Hello,
Today I had time to try this test in 3 different systems, and I couldn make it work in any of them, so I think this is a bug, should I create a new ticket in http://trac.osgeo.org/mapserver/.
I write the steps below to reproduce the problem
PROBLEM:
In wfs layer where the data is retrieved from a mysql table, the intersect filter only returns a result list when the first feature(the first inserted record in the table) is part of the result set. If the filter shall return results, but the first feature is not among them, then we get not list of features:
<?xml version='1.0' encoding="ISO-8859-1" ?>
<wfs:FeatureCollection...>
<gml:boundedBy>
<gml:Box srsName="EPSG:4326">
<gml:coordinates>-1.000000,-1.000000 -1.000000,-1.000000</gml:coordinates>
</gml:Box>
</gml:boundedBy>
</wfs:FeatureCollection>
Which is diffrent to when a query shall not return any resultst:
<?xml version='1.0' encoding="ISO-8859-1" ?>
<wfs:FeatureCollection...">
<gml:boundedBy>
<gml:null>missing</gml:null>
</gml:boundedBy>
</wfs:FeatureCollection>
TEST:
1. Create Spatial Data
CREATE DATABASE mmi_spatial_db;
USE mmi_spatial_db;
CREATE TABLE positionReal (oid LONG, point POINT);
INSERT INTO positionReal(oid, point) VALUES (3, GeomFromText('POINT(-10 -10)',4326));
INSERT INTO positionReal(oid, point) VALUES (2, GeomFromText('POINT(10 10)',4326));
INSERT INTO positionReal(oid, point) VALUES (1, GeomFromText('POINT(0 20)',4326));
2. Map file:
MAP
NAME MMI_WFS
UNITS METERS
TRANSPARENT ON
IMAGECOLOR 0 0 0
IMAGETYPE PNG
SHAPEPATH "."
SYMBOLSET "../symbols.sym"
STATUS ON
WEB
IMAGEPATH "/opt/fsg/tmp/"
IMAGEURL "/opt/fsg/"
METADATA
"wfs_title" "WFS MMI Server for MapServer" ## REQUIRED
"wfs_onlineresource" "http://localhost:8080/cgi-bin/mywfs?" ## Recommended
"wfs_srs" "EPSG:4326"## Recommended
"wfs_abstract" "This text describes my WFS service." ## Recommended
"wfs_schemas_location" "http://schemas.opengeospatial.net"
END
END
PROJECTION
"init=epsg:4326"
END
LAYER
NAME "PositionReal"
STATUS ON
TYPE POINT
CONNECTIONTYPE OGR
CONNECTION "MySQL:mmi_spatial_db,user=mmi,password=*****,host=127.0.0.1,port=3306"
DATA "SELECT point from positionReal"
#CONNECTIONTYPE POSTGIS
#CONNECTION "host=127.0.0.1 port=5432 dbname=mmi_db user=postgres password=postgres"
#DATA "point from positionreal"
DUMP TRUE ## REQUIRED
#TOLERANCE 200
#TOLERANCEUNITS PIXELS
METADATA
#"wfs_featureid" "oid"
"wfs_srs" "epsg:4326"
"wfs_onlineresource" "http://localhost:8080/cgi-bin/mywfs?" ## Recommended
"wfs_title" "PositionReal"
"gml_include_items" "all" ## Optional (serves all attributes for lay
"gml_surface_occurances" "0,UNBOUNDED"
"wfs_extent" "-180 -90 180 90"
"gml_include_items" "all"
END
END
END # Map File
3. Intersect Filter:
- This one works because point (-10,-10) is part of the resultset.
http://localhost:8080/cgi-bin/mywfs?SERVICE=WFS&VERSION=1.0.0&request=getfeature&typename=PositionReal&Filter=
<Filter xmlns="http://www.opengis.net/ogc" xmlns:gml="http://www.opengis.net/gml"><Intersects><PropertyName>point</PropertyName>
<gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>-180,-90 -180,90 180,90 180,-90 -180,-90</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></Intersects></Filter>
- This one works, point (-10,-10) is part of the resultset
http://localhost:8080/cgi-bin/mywfs?SERVICE=WFS&VERSION=1.0.0&request=getfeature&typename=PositionReal&Filter=
<Filter xmlns="http://www.opengis.net/ogc" xmlns:gml="http://www.opengis.net/gml"><Intersects><PropertyName>point</PropertyName>
<gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>-11,-11 -11,-9 -9,-9 -9,-11 -11,-11</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></Intersects></Filter>
- This query fails, it should return one feature, but we get the weird behavior because point (-10,-10) is not part of the resultset
http://localhost:8080/cgi-bin/mywfs?SERVICE=WFS&VERSION=1.0.0&request=getfeature&typename=PositionReal&Filter=
<Filter xmlns="http://www.opengis.net/ogc" xmlns:gml="http://www.opengis.net/gml"><Intersects><PropertyName>point</PropertyName>
<gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>9,9 9,11 11,11 11,9 9,9</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></Intersects></Filter>
Notice that I use gml:polygon instead of gml:box to be able to test this with mapserver in trunk (which works with gml:box) but also with mapserver 5.6.3 (fgs-installer, which dont work with intersect and gml:box)
The problem does not ocurr if the database in use is postgres
./createdb -U postgres -T template_postgis mmi_db;
CREATE TABLE positionReal (oid int);
SELECT AddGeometryColumn('positionreal', 'point', 4326,'POINT',2);
INSERT INTO positionReal(oid, point) VALUES (3, GeomFromText('POINT(-10 -10)',4326));
INSERT INTO positionReal(oid, point) VALUES (2, GeomFromText('POINT(10 10)',4326));
INSERT INTO positionReal(oid, point) VALUES (1, GeomFromText('POINT(0 20)',4326));
SYSTEMS:
I test this in the following systems:
OpenSuse 11
fgs-mapserver_basic_5.6.3-fgs_9.5-linux-i386.bin and building from the sources (branch 5-6)
mysql Ver 14.12 Distrib 5.0.67, for suse-linux-gnu (i686) using readline 5.2 and mysql 5.5 too
SLES 11
fgs-mapserver_basic_5.6.3-fgs_9.5-linux-i386.bin
mysql Ver 14.14 Distrib 5.1.43, for unknown-linux-gnu (x86_64) using readline 5.1
Ubunut
fgs-mapserver_basic_5.6.3-fgs_9.5-linux-i386.bin
mysql 5.1
Best regards,
Joaquín
________________________________________
De: Joaquín Rodriguez-Guerra Urcelay
Enviado el: jueves, 31 de marzo de 2011 17:25
Para: mapserver-users at lists.osgeo.org
Asunto: RE: [mapserver-users] WFS Intersect with gml:box
Hi,
I have check the same example using Posgres and it works, so it is a problem with mysql
Joaquín Rodríguez-Guerra Urcelay
Unidad de Sistemas de Procesamiento de Ciencia y de Observación de la Tierra / Science and Earth Observing Processing Systems Unit
GMV AEROSPACE AND DEFENCE, S.A.
Isaac Newton, 11
P.T.M. Tres Cantos
E-28760 Madrid
Tel. +34 91 807 21 00 / 7695
Fax +34 91 807 21 99
www.gmv.com
________________________________________
De: mapserver-users-bounces at lists.osgeo.org [mapserver-users-bounces at lists.osgeo.org] En nombre de Joaquín Rodriguez-Guerra Urcelay [jrguerra at gmv.com]
Enviado el: jueves, 31 de marzo de 2011 16:42
Para: mapserver-users at lists.osgeo.org
Asunto: RE: [mapserver-users] WFS Intersect with gml:box
Hello,
Here I am again, this is not over :(
I have been testing this all morning, and I have seen that intersect only returns results when the first feature in the mysql table belongs to the resultset, very weird :(
When I request a filter which should return results, but the first feature is not in the resultset, then I get this:
<?xml version='1.0' encoding="ISO-8859-1" ?>
<wfs:FeatureCollection...>
<gml:boundedBy>
<gml:Box srsName="EPSG:4326">
<gml:coordinates>-1.000000,-1.000000 -1.000000,-1.000000</gml:coordinates>
</gml:Box>
</gml:boundedBy>
</wfs:FeatureCollection>
Which is diffrent to when I make a query which should not return any results, then I get:
<?xml version='1.0' encoding="ISO-8859-1" ?>
<wfs:FeatureCollection...">
<gml:boundedBy>
<gml:null>missing</gml:null>
</gml:boundedBy>
</wfs:FeatureCollection>
So, it detects when there are results, but only show them when the first feature is on the result set. Does this make any sense?
This is my database (mysql 5):
CREATE DATABASE mmi_spatial_db;
USE mmi_spatial_db;
CREATE TABLE positionReal (id INTEGER, point GEOMETRY);
INSERT INTO positionReal(id, point) VALUES (2, GeomFromText('POINT(10 10)',4326));
INSERT INTO positionReal(id, point) VALUES (1, GeomFromText('POINT(0 20)',4326));
INSERT INTO positionReal(id, point) VALUES (3, GeomFromText('POINT(-10 -10)',4326));
The following query returns the expected result
http://localhost:8080/cgi-bin/mywfs?SERVICE=WFS&VERSION=1.0.0&request=getfeature&typename=PositionReal&Filter=
<Filter xmlns="http://www.opengis.net/ogc" xmlns:gml="http://www.opengis.net/gml"><Intersects><PropertyName>point</PropertyName>
<gml:Box srsName="epsg:4326"><gml:coordinates decimal="." cs="," ts=" ">10,10 10,10</gml:coordinates>
</gml:Box>
</Intersects>
</Filter>
result:
<wfs:FeatureCollection...
<gml:boundedBy>
<gml:Box srsName="EPSG:4326">
<gml:coordinates>10.000000,10.000000 10.000000,10.000000</gml:coordinates>
</gml:Box>
</gml:boundedBy>
<gml:featureMember>
<ms:PositionReal fid="PositionReal.2">
<gml:boundedBy>
<gml:Box srsName="EPSG:4326">
<gml:coordinates>10.000000,10.000000 10.000000,10.000000</gml:coordinates>
</gml:Box>
</gml:boundedBy>
<ms:msGeometry>
<gml:Point srsName="EPSG:4326">
<gml:coordinates>10.000000,10.000000</gml:coordinates>
</gml:Point>
</ms:msGeometry>
<ms:id>2</ms:id>
</ms:PositionReal>
</gml:featureMember>
</wfs:FeatureCollection>
And any other query where the point 10,10 is belonging the bounding box, works. If I change the order INSERTS, then this magic point changes for the one I insert first.
This is my map file:
MAP
NAME MMI_WFS
UNITS METERS
TRANSPARENT ON
IMAGECOLOR 0 0 0
IMAGETYPE PNG
SHAPEPATH "."
SYMBOLSET "../symbols.sym"
STATUS ON
WEB
IMAGEPATH "/opt/fsg/tmp/"
IMAGEURL "/opt/fsg/"
METADATA
"wfs_title" "WFS MMI Server for MapServer" ## REQUIRED
"wfs_onlineresource" "http://localhost:8080/cgi-bin/mywfs?" ## Recommended
"wfs_srs" "EPSG:4326"## Recommended
"wfs_abstract" "This text describes my WFS service." ## Recommended
"wfs_schemas_location" "http://schemas.opengeospatial.net"
END
END
PROJECTION
"init=epsg:4326"
END
LAYER
NAME "PositionReal"
STATUS ON
TYPE POINT
CONNECTIONTYPE OGR
CONNECTION "MySQL:mmi_spatial_db,user=mmi,password=adminis,host=127.0.0.1,port=3306"
DATA "SELECT id,point from positionReal"
DUMP TRUE ## REQUIRED
#TOLERANCE 200
#TOLERANCEUNITS PIXELS
METADATA
"wfs_featureid" "id"
"wfs_srs" "epsg:4326"
"wfs_onlineresource" "http://localhost:8080/cgi-bin/mywfs?" ## Recommended
"wfs_title" "PositionReal"
"gml_include_items" "all" ## Optional (serves all attributes for lay
"gml_surface_occurances" "0,UNBOUNDED"
"wfs_extent" "-180 -90 180 90"
"gml_include_items" "all"
END
END
END # Map File
Well, this is weird, but if it sounds familliar or it rings a bell to some one, please help me :)
Thanks!
Joaquín
________________________________________
De: mapserver-users-bounces at lists.osgeo.org [mapserver-users-bounces at lists.osgeo.org] En nombre de Joaquín Rodriguez-Guerra Urcelay [jrguerra at gmv.com]
Enviado el: jueves, 31 de marzo de 2011 11:31
CC: mapserver-users at lists.osgeo.org
Asunto: RE: [mapserver-users] WFS Intersect with gml:box
Hi,
Thank you both for your help, the filter is finally working :D
The bug is fixed, gml:box works now with intersect. I wanted to confirm this in the bug report, but I havent found they way to write anything there (is it because the bug is now closed?)
Yesterday I was not getting the results I expected because I think my connection to the mysql database had some problem. I tried with a shapefile and it was working perfectly, so I then played a bit with the mysql connection and now it is working :)
Joaquín
________________________________________
De: Yewondwossen Assefa [yassefa at dmsolutions.ca]
Enviado el: miércoles, 30 de marzo de 2011 22:48
Para: Rahkonen Jukka
CC: mapserver-users at lists.osgeo.org; Joaquín Rodriguez-Guerra Urcelay
Asunto: Re: [mapserver-users] WFS Intersect with gml:box
On 30/03/2011 4:16 PM, Rahkonen Jukka wrote:
> Hi,
>
> "Intersect" means the same as "not disjoint", that the two geometries have at least one point in common. Thus WFS Intersects should select the point that is inside the "box" in the query. I made a quick test with OpenJUMP which is using JTS and it really does select such a point with a apatial query Intersects.
>
Geos lib used by MapServer should act the same as JTS I beleive.
Joaquín, you can maybe attach your simple map/data/url to the bug and I
will check it using MapServer trunk.
--
----------------------------------------------------------------
Assefa Yewondwossen
Software Analyst
Email: yassefa at dmsolutions.ca
http://www.dmsolutions.ca/
Phone: (613) 565-5056 (ext 14)
Fax: (613) 565-0925
----------------------------------------------------------------
______________________
This message including any attachments may contain confidential
information, according to our Information Security Management System,
and intended solely for a specific individual to whom they are addressed.
Any unauthorised copy, disclosure or distribution of this message
is strictly forbidden. If you have received this transmission in error,
please notify the sender immediately and delete it.
______________________
Este mensaje, y en su caso, cualquier fichero anexo al mismo,
puede contener informacion clasificada por su emisor como confidencial
en el marco de su Sistema de Gestion de Seguridad de la
Informacion siendo para uso exclusivo del destinatario, quedando
prohibida su divulgacion copia o distribucion a terceros sin la
autorizacion expresa del remitente. Si Vd. ha recibido este mensaje
erroneamente, se ruega lo notifique al remitente y proceda a su borrado.
Gracias por su colaboracion.
______________________
_______________________________________________
mapserver-users mailing list
mapserver-users at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapserver-users
______________________
This message including any attachments may contain confidential
information, according to our Information Security Management System,
and intended solely for a specific individual to whom they are addressed.
Any unauthorised copy, disclosure or distribution of this message
is strictly forbidden. If you have received this transmission in error,
please notify the sender immediately and delete it.
______________________
Este mensaje, y en su caso, cualquier fichero anexo al mismo,
puede contener informacion clasificada por su emisor como confidencial
en el marco de su Sistema de Gestion de Seguridad de la
Informacion siendo para uso exclusivo del destinatario, quedando
prohibida su divulgacion copia o distribucion a terceros sin la
autorizacion expresa del remitente. Si Vd. ha recibido este mensaje
erroneamente, se ruega lo notifique al remitente y proceda a su borrado.
Gracias por su colaboracion.
______________________
_______________________________________________
mapserver-users mailing list
mapserver-users at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapserver-users
______________________
This message including any attachments may contain confidential
information, according to our Information Security Management System,
and intended solely for a specific individual to whom they are addressed.
Any unauthorised copy, disclosure or distribution of this message
is strictly forbidden. If you have received this transmission in error,
please notify the sender immediately and delete it.
______________________
Este mensaje, y en su caso, cualquier fichero anexo al mismo,
puede contener informacion clasificada por su emisor como confidencial
en el marco de su Sistema de Gestion de Seguridad de la
Informacion siendo para uso exclusivo del destinatario, quedando
prohibida su divulgacion copia o distribucion a terceros sin la
autorizacion expresa del remitente. Si Vd. ha recibido este mensaje
erroneamente, se ruega lo notifique al remitente y proceda a su borrado.
Gracias por su colaboracion.
______________________
_______________________________________________
mapserver-users mailing list
mapserver-users at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapserver-users
______________________
This message including any attachments may contain confidential
information, according to our Information Security Management System,
and intended solely for a specific individual to whom they are addressed.
Any unauthorised copy, disclosure or distribution of this message
is strictly forbidden. If you have received this transmission in error,
please notify the sender immediately and delete it.
______________________
Este mensaje, y en su caso, cualquier fichero anexo al mismo,
puede contener informacion clasificada por su emisor como confidencial
en el marco de su Sistema de Gestion de Seguridad de la
Informacion siendo para uso exclusivo del destinatario, quedando
prohibida su divulgacion copia o distribucion a terceros sin la
autorizacion expresa del remitente. Si Vd. ha recibido este mensaje
erroneamente, se ruega lo notifique al remitente y proceda a su borrado.
Gracias por su colaboracion.
______________________
More information about the MapServer-users
mailing list