[mapserver-users] RE How to use filter encoding in MapServer in a WFS query?

Steve.Toutant at inspq.qc.ca Steve.Toutant at inspq.qc.ca
Wed May 13 05:38:34 PDT 2015


Add  matchCase="false" for the 2 operators ogc:PropertyIsEqualTo
This will work
http://wms.pcn.minambiente.it/ogc?map=/ms_ogc/wfs/Numeri_Civici_2012.map&VERSION=1.1.0&service=wfs&request=GetFeature&TYPENAME=IN.NUMERICIVICI.2012&Filter=
<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc
"><AND><ogc:PropertyIsEqualTo 
matchCase="false"><ogc:PropertyName>comune</ogc:PropertyName><ogc:Literal>Carignano</ogc:Literal></ogc:PropertyIsEqualTo><ogc:PropertyIsEqualTo 
matchCase="false"><ogc:PropertyName>nome</ogc:PropertyName><ogc:Literal>Via 
Monte Grappa</ogc:Literal></ogc:PropertyIsEqualTo><ogc:PropertyIsLike 
matchCase="false" wildCard="*" singleChar="." 
escapeChar="!"><ogc:PropertyName>civico</ogc:PropertyName><ogc:Literal>*24*</ogc:Literal></ogc:PropertyIsLike></AND></ogc:Filter> 
 

And for civico</ogc:PropertyName><ogc:Literal>*24*, this might return 
several values such as 124, 241, .....I think, I didn't try though



cesare gerbino <cesaregerbino at gmail.com> 
2015-05-13 08:05

A
Steve.Toutant at inspq.qc.ca
cc
mapserver-users at lists.osgeo.org, mapserver-users-bounces at lists.osgeo.org
Objet
Re: RE [mapserver-users] How to use filter encoding in MapServer in a WFS 
query?








Hi again ... My query now it's working .... I've upgrated it using AND 
logical operator ...Here you're my new query ...

http://wms.pcn.minambiente.it/ogc?map=/ms_ogc/wfs/Numeri_Civici_2012.map&VERSION=1.1.0&service=wfs&request=GetFeature&TYPENAME=IN.NUMERICIVICI.2012&Filter=
<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc
"><AND><ogc:PropertyIsLike matchCase="false" wildCard="*" singleChar="." 
escapeChar="!"><ogc:PropertyName>comune</ogc:PropertyName><ogc:Literal>*Carignano*</ogc:Literal></ogc:PropertyIsLike><ogc:PropertyIsLike 
matchCase="false" wildCard="*" singleChar="." 
escapeChar="!"><ogc:PropertyName>nome</ogc:PropertyName><ogc:Literal>*Via 
Monte Grappa*</ogc:Literal></ogc:PropertyIsLike><ogc:PropertyIsLike 
matchCase="false" wildCard="*" singleChar="." 
escapeChar="!"><ogc:PropertyName>civico</ogc:PropertyName><ogc:Literal>*24*</ogc:Literal></ogc:PropertyIsLike></AND></ogc:Filter>

The result is 

<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://wms.pcn.minambiente.it/ogc?map=/ms_ogc/wfs/Numeri_Civici_2012.map&SERVICE=WFS&VERSION=1.1.0&REQUEST=DescribeFeatureType&TYPENAME=IN.NUMERICIVICI.2012&OUTPUTFORMAT=text/xml;%20subtype=gml/3.1.1 
http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd">
<gml:boundedBy>
<gml:Envelope srsName="EPSG:4326">
<gml:lowerCorner>44.912717 7.672281</gml:lowerCorner>
<gml:upperCorner>44.912717 7.672281</gml:upperCorner>
</gml:Envelope>
</gml:boundedBy>
<gml:featureMember>
<ms:IN.NUMERICIVICI.2012 gml:id="IN.NUMERICIVICI.2012.11979231">
<gml:boundedBy>
<gml:Envelope srsName="EPSG:4326">
<gml:lowerCorner>44.912717 7.672281</gml:lowerCorner>
<gml:upperCorner>44.912717 7.672281</gml:upperCorner>
</gml:Envelope>
</gml:boundedBy>
<ms:boundary>
<gml:Point srsName="EPSG:4326">
<gml:pos>44.912717 7.672281</gml:pos>
</gml:Point>
</ms:boundary>
<ms:id>13800000050414</ms:id>
<ms:nome>Via Monte Grappa</ms:nome>
<ms:civico>24</ms:civico>
<ms:istat>01001058</ms:istat>
<ms:cap>10041</ms:cap>
<ms:comune>CARIGNANO</ms:comune>
<ms:nome_ted></ms:nome_ted>
<ms:provincia>TORINO</ms:provincia>
<ms:regione>PIEMONTE</ms:regione>
</ms:IN.NUMERICIVICI.2012>
</gml:featureMember>
</wfs:FeatureCollection>

so it seems to be right.

To refine the query I've tried to use the PropertyIsEqualTo operator 
instead of the PropertyIsLike only for those fields that are not numeric, 
so the fields "comune" and "nome" .... the new query is

http://wms.pcn.minambiente.it/ogc?map=/ms_ogc/wfs/Numeri_Civici_2012.map&VERSION=1.1.0&service=wfs&request=GetFeature&TYPENAME=IN.NUMERICIVICI.2012&Filter=
<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc
"><AND><ogc:PropertyIsEqualTo><ogc:PropertyName>comune</ogc:PropertyName><ogc:Literal>Carignano</ogc:Literal></ogc:PropertyIsEqualTo><ogc:PropertyIsEqualTo><ogc:PropertyName>nome</ogc:PropertyName><ogc:Literal>Via 
Monte Grappa</ogc:Literal></ogc:PropertyIsEqualTo><ogc:PropertyIsLike 
matchCase="false" wildCard="*" singleChar="." 
escapeChar="!"><ogc:PropertyName>civico</ogc:PropertyName><ogc:Literal>*24*</ogc:Literal></ogc:PropertyIsLike></AND></ogc:Filter> 
 

but the result is 

<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://wms.pcn.minambiente.it/ogc?map=/ms_ogc/wfs/Numeri_Civici_2012.map&SERVICE=WFS&VERSION=1.1.0&REQUEST=DescribeFeatureType&TYPENAME=IN.NUMERICIVICI.2012&OUTPUTFORMAT=text/xml;%20subtype=gml/3.1.1 
http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd">
<gml:boundedBy>
<gml:Null>missing</gml:Null>
</gml:boundedBy>
</wfs:FeatureCollection>

Is there something wrong somewhere or it's better continue to use the 
PropertyIsLike everywhere?

Thank you in advance ...

Cesare


Cesare Gerbino

http://cesaregerbino.wordpress.com/
http://www.facebook.com/cesare.gerbino
http://www.facebook.com/pages/Cesare-Gerbino-GIS-Blog/246234455498174?ref=hl

https://twitter.com/CesareGerbino
http://www.linkedin.com/pub/cesare-gerbino/56/494/77b

Questo è un account di posta personale di Cesare Gerbino: tutte le 
opinioni espresse sono personali e non riflettono necessariamente quelle 
del mio datore di lavoro

This is Cesare Gerbino mail account. Text is written by Cesare Gerbino: 
 the views expressed  are mine and not necessarily those of my employer.
.


2015-05-12 22:36 GMT+02:00 cesare gerbino <cesaregerbino at gmail.com>:
may be ... I've tried the same request from my wife's IPad from Safari and 
it's working ...... Thank you Steve!


Cesare Gerbino

http://cesaregerbino.wordpress.com/
http://www.facebook.com/cesare.gerbino
http://www.facebook.com/pages/Cesare-Gerbino-GIS-Blog/246234455498174?ref=hl

https://twitter.com/CesareGerbino
http://www.linkedin.com/pub/cesare-gerbino/56/494/77b

Questo è un account di posta personale di Cesare Gerbino: tutte le 
opinioni espresse sono personali e non riflettono necessariamente quelle 
del mio datore di lavoro

This is Cesare Gerbino mail account. Text is written by Cesare Gerbino: 
 the views expressed  are mine and not necessarily those of my employer.
.


2015-05-12 22:25 GMT+02:00 <Steve.Toutant at inspq.qc.ca>:
maybe there is a parameter in your browser that abort request when it is 
too long to get an answer. 




cesare gerbino <cesaregerbino at gmail.com> 
2015-05-12 16:18 


A
Steve.Toutant at inspq.qc.ca 
cc
mapserver-users at lists.osgeo.org, mapserver-users-bounces at lists.osgeo.org 
Objet
Re: RE [mapserver-users] How to use filter encoding in MapServer in a WFS 
query?










My Firebug console, in the "Net" tab, "All"  says ...."Aborted" .... tha 
same in Chrome  .....  

Cesare Gerbino

http://cesaregerbino.wordpress.com/
http://www.facebook.com/cesare.gerbino
http://www.facebook.com/pages/Cesare-Gerbino-GIS-Blog/246234455498174?ref=hl

https://twitter.com/CesareGerbino
http://www.linkedin.com/pub/cesare-gerbino/56/494/77b 

Questo è un account di posta personale di Cesare Gerbino: tutte le 
opinioni espresse sono personali e non riflettono necessariamente quelle 
del mio datore di lavoro 

This is Cesare Gerbino mail account. Text is written by Cesare Gerbino: 
 the views expressed  are mine and not necessarily those of my employer. 
.


2015-05-12 22:07 GMT+02:00 <Steve.Toutant at inspq.qc.ca>: 
The link you provided works...I received 15 features 
I don't know what to say, what firebug or chrome say? 


cesare gerbino <cesaregerbino at gmail.com> 
2015-05-12 15:58 


A
Steve.Toutant at inspq.qc.ca 
cc
mapserver-users at lists.osgeo.org, mapserver-users-bounces at lists.osgeo.org 
Objet
Re: RE [mapserver-users] How to use filter encoding in MapServer in a WFS 
query?












Hi Steve, 

thank you for the quckly response!! 

I've just tried to change my request using you suggestion ... this is the 
new request now .. 

http://wms.pcn.minambiente.it/ogc?map=/ms_ogc/wfs/Numeri_Civici_2012.map&VERSION=1.1.0&service=wfs&request=GetFeature&TYPENAME=IN.NUMERICIVICI.2012&Filter=
<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc"><ogc:PropertyIsLike 
matchCase="false" wildCard="*" singleChar="." 
escapeChar="!"><ogc:PropertyName>id</ogc:PropertyName><ogc:Literal>*13800000050414*</ogc:Literal></ogc:PropertyIsLike></ogc:Filter>  


or better how it's used in my browser 

http://wms.pcn.minambiente.it/ogc?map=/ms_ogc/wfs/Numeri_Civici_2012.map&VERSION=1.1.0&service=wfs&request=GetFeature&TYPENAME=IN.NUMERICIVICI.2012&Filter=%3Cogc:Filter%20xmlns:ogc=%22http://www.opengis.net/ogc%22%3E%3Cogc:PropertyIsLike%20matchCase=%22false%22%20wildCard=%22*%22%20singleChar=%22.%22%20escapeChar=%22!%22%3E%3Cogc:PropertyName%3Eid%3C/ogc:PropertyName%3E%3Cogc:Literal%3E*13800073301968*%3C/ogc:Literal%3E%3C/ogc:PropertyIsLike%3E%3C/ogc:Filter%3E 


Unfortunately still doesn't work .... No data received is the response 
....  

Cesare 

Cesare Gerbino

http://cesaregerbino.wordpress.com/
http://www.facebook.com/cesare.gerbino
http://www.facebook.com/pages/Cesare-Gerbino-GIS-Blog/246234455498174?ref=hl

https://twitter.com/CesareGerbino
http://www.linkedin.com/pub/cesare-gerbino/56/494/77b 

Questo è un account di posta personale di Cesare Gerbino: tutte le 
opinioni espresse sono personali e non riflettono necessariamente quelle 
del mio datore di lavoro 

This is Cesare Gerbino mail account. Text is written by Cesare Gerbino: 
 the views expressed  are mine and not necessarily those of my employer. 
.


2015-05-12 21:48 GMT+02:00 <Steve.Toutant at inspq.qc.ca>: 
Your syntax are good. This is an old problem with int considered as string 

Using ogc:PropertyIsLike works though, here is a request 

<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc"><ogc:PropertyIsLike 
matchCase="false" wildCard="*" singleChar="." 
escapeChar="!"><ogc:PropertyName>id</ogc:PropertyName><ogc:Literal>*13800073301968*</ogc:Literal></ogc:PropertyIsLike></ogc:Filter> 


Also this wfs support version= 1.1.0, you should do your request by 
specifying this version 


cesare gerbino <cesaregerbino at gmail.com>@lists.osgeo.org 
Envoyé par : mapserver-users-bounces at lists.osgeo.org 
2015-05-12 15:33 


A
mapserver-users at lists.osgeo.org 
cc

Objet
[mapserver-users] How to use filter encoding in MapServer in a WFS       
 query?














Hi all! 

I need to query this WFS public service  

http://wms.pcn.minambiente.it/ogc?map=/ms_ogc/wfs/Numeri_Civici_2012.map&service=wfs&request=getCapabilities 


The layer I need to query is this one 

http://wms.pcn.minambiente.it/ogc?map=/ms_ogc/wfs/Numeri_Civici_2012.map&service=wfs&version=1.0.0&request=DescribeFeatureType 


It's a layer with a very big number of point features. 

The OGC service is done using MapServer but I don't know the version. 

I need to query this layer in a no spatial way: the simplest query I need 
to do is something like this one 

    
http://wms.pcn.minambiente.it/ogc?map=/ms_ogc/wfs/Numeri_Civici_2012.map&VERSION=1.0.0&service=wfs&request=GetFeature&TYPENAME=IN.NUMERICIVICI.2012&Filter=
<Filter><PropertyIsEqualTo><PropertyName>id</PropertyName><Literal>13800000050414</Literal></PropertyIsEqualTo></Filter> 


My final query would like to combine several clauses using the AND logical 
operator. 

Unfortunately at the moment the simplest query above doesn't work: if you 
try it in the response ther will be something like  

HINT: No operator matches the given name and argument type(s). You might 
need to add explicit type casts 

I've done several attempts to change it and I've tried other queries: for 
example 

1) this one ... 

http://wms.pcn.minambiente.it/ogc?map=/ms_ogc/wfs/Numeri_Civici_2012.map&VERSION=1.0.0&service=wfs&request=GetFeature&TYPENAME=IN.NUMERICIVICI.2012&Filter=%3Cogc:Filter%3E%3Cogc:PropertyIsEqualTo%3E%3Cogc:PropertyName%3Eid%3C/ogc:PropertyName%3E%3Cogc:Literal%3E%2713800000050414%27%3C/ogc:Literal%3E%3C/ogc:PropertyIsEqualTo%3E%3C/ogc:Filter%3E 



returns  

    <gml:boundedBy><gml:null>missing</gml:null></gml:boundedBy> 

so I think that in this case the sintax could be right but I'm not sure 
and I don0't understand because the response is null  

2) trying to do a spatial query like this one ... 

    
http://wms.pcn.minambiente.it/ogc?map=/ms_ogc/wfs/Numeri_Civici_2012.map&VERSION=1.0.0&service=wfs&request=GetFeature&TYPENAME=IN.NUMERICIVICI.2012&Filter=%3CFilter%3E%3CBBOX%3E%3CPropertyName%3EName%3ENAME%3C/PropertyName%3E%3CBox%20srsName=%27EPSG:4326%27%3E%3Ccoordinates%3E7.626630,45.029061%207.673107,45.052713%3C/coordinates%3E%3C/Box%3E%3C/BBOX%3E%3C/Filter%3E 


returns a right response. 

I've found on the web that probably there is a workaround ... 

http://osgeo-org.1560.x6.nabble.com/WFS-filter-creates-a-query-using-a-number-instead-of-text-td5130361.html#a5190402 


that suggest to use the PropertyIsLike operator instead of the 
PropertyIsEqual. I've tried to use it but it doesn't work in my case ...  

http://wms.pcn.minambiente.it/ogc?map=/ms_ogc/wfs/Numeri_Civici_2012.map&VERSION=1.0.0&service=wfs&request=GetFeature&TYPENAME=IN.NUMERICIVICI.2012&Filter=%3Cogc:Filter%3E%3Cogc:PropertyIsLike%3E%3Cogc:PropertyName%3Eid%3C/ogc:PropertyName%3E%3Cogc:Literal%3E%2713800000050414%27%3C/ogc:Literal%3E%3C/ogc:PropertyIsLike%3E%3C/ogc:Filter%3E 


in this case after a long time it seems that the service goes in time out 
and no data is returned ....  

Now I am completely blocked .... :-( 

Any suggestions / workaround?  

Thank you very much in advance ... 

Cesare 

Cesare Gerbino

http://cesaregerbino.wordpress.com/
http://www.facebook.com/cesare.gerbino
http://www.facebook.com/pages/Cesare-Gerbino-GIS-Blog/246234455498174?ref=hl

https://twitter.com/CesareGerbino
http://www.linkedin.com/pub/cesare-gerbino/56/494/77b 

Questo è un account di posta personale di Cesare Gerbino: tutte le 
opinioni espresse sono personali e non riflettono necessariamente quelle 
del mio datore di lavoro 

This is Cesare Gerbino mail account. Text is written by Cesare Gerbino: 
 the views expressed  are mine and not necessarily those of my employer. 
.
_______________________________________________
mapserver-users mailing list
mapserver-users at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapserver-users 









-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20150513/a0ebd24f/attachment-0001.html>


More information about the mapserver-users mailing list