[mapserver-users] WFS GetFeature with PostGIS database : the PostGIS request is not well formated (with string fields that contains only numbers)

"SAEZ Laurent - CETE Méditerr./DI/ETER" Laurent.Saez at developpement-durable.gouv.fr
Thu Jul 24 07:18:44 PDT 2008


Hi List,

I have a PostGIS database.
I have a point table representing plots.
I have to select a plot using several fields :

    * num_dep (string) : departement code,
    * nom_com (string) : city name,
    * section (string) : section number,
    * numero (string) : plot number.

I use MapServer 4.99 and Postgersql 8.1.

All my fields are strings.
Result of DescribeFeatureType request :
<complexType name="bdparcellaire_numeroType">
  <complexContent>
    <extension base="gml:AbstractFeatureType">
      <sequence>
        <element name="geometry" type="gml:PointPropertyType" 
minOccurs="0" maxOccurs="1"/>
        <element name="code_dep" type="string"/>
        <element name="nom_com" type="string"/>
        <element name="section" type="string"/>
        <element name="numero" type="string"/>
        <element name="gid" type="string"/>
        <element name="oid" type="string"/>
      </sequence>
    </extension>
  </complexContent>
</complexType>

When I do a WFS GetFeature request, mapserver doesn't format correctly 
strings fields that contains only numbers.
Example : (to select the plot where num_dep='66' and nom_com='Baixas' 
and section='0A' and numero='2651')
http://mapserver_i2.cete-mediterranee.i2/maps/mapserv?map=%2Fdata%2Fcarto%2Fref%2Fbdparcellaire%2Fbdparcellaire_2007_iso.map&=&SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&TYPENAME=bdparcellaire_numero&FILTER=%28%3CFilter%3E%3CAnd%3E%3CPropertyIsEqualTo%3E%3CPropertyName%3Ecode_dep%3C%2FPropertyName%3E%3CLiteral%3E66%3C%2FLiteral%3E%3C%2FPropertyIsEqualTo%3E%3CPropertyIsEqualTo%3E%3CPropertyName%3Enom_com%3C%2FPropertyName%3E%3CLiteral%3EBaixas%3C%2FLiteral%3E%3C%2FPropertyIsEqualTo%3E%3CPropertyIsEqualTo%3E%3CPropertyName%3Esection%3C%2FPropertyName%3E%3CLiteral%3E0A%3C%2FLiteral%3E%3C%2FPropertyIsEqualTo%3E%3CPropertyIsEqualTo%3E%3CPropertyName%3Enumero%3C%2FPropertyName%3E%3CLiteral%3E2651%3C%2FLiteral%3E%3C%2FPropertyIsEqualTo%3E%3C%2FAnd%3E%3C%2FFilter%3E%29

For human people :
map=/data/carto/ref/bdparcellaire/bdparcellaire_2007_iso.map&=
&SERVICE=WFS
&VERSION=1.0.0
&REQUEST=GetFeature
&TYPENAME=bdparcellaire_numero
&FILTER=(
<Filter>
  <And>
    <PropertyIsEqualTo>
      <PropertyName>code_dep</PropertyName>
      <Literal>66</Literal>
    </PropertyIsEqualTo>
    <PropertyIsEqualTo>
      <PropertyName>nom_com</PropertyName>
      <Literal>Baixas</Literal>
    </PropertyIsEqualTo>
    <PropertyIsEqualTo>
      <PropertyName>section</PropertyName>
      <Literal>0A</Literal>
    </PropertyIsEqualTo>
    <PropertyIsEqualTo>
      <PropertyName>numero</PropertyName>
      <Literal>2651</Literal>
    </PropertyIsEqualTo>
  </And>
</Filter>)

MapServer sends this instruction to PostGIS :
LOG:  instruction : DECLARE mycursor BINARY CURSOR FOR SELECT 
asbinary(force_collection(force_2d(the_geom)),'NDR'),oid::text from 
(select code_dep, nom_com, section, numero, gid, the_geom, oid FROM 
localisant) as foo WHERE ( (code_dep= 66)  And  ( (nom_com= 'Baixas')  
And  ( (section= '0A')  And  (numero= 2651) ) ) ) and (the_geom && 
setSRID( 'BOX3D(47650 1620400,1197850 2677450)'::BOX3D,27582) )

We can see that code_dep and numero are not quoted. It's not a problem 
in this example, but when I search the plot with the numero=0256, search 
returned no results. The plot exists ! The right request in PostGIS 
returns the plot.
It seems that not '0256' is search but 256.
Is it a bug ? I think so !
For me it's very very very very disturbing.
I can't use mapserver as a WFS server to select plot !
I hope someone could help me !

Regards

Laurent
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20080724/8046a0dd/attachment.htm>


More information about the MapServer-users mailing list