[Geoserver-users] Problem with filter encoding/decoding in WFS between POST/GET

As part of a larger query one of my students is having a problem with BBOX filters in WFS
When we do the equivalent of

<wfs:GetFeature service=“WFS” version=“1.1.0”
xmlns:topp=“http://www.openplans.org/topp
xmlns:wfs=“http://www.opengis.net/wfs
xmlns:ogc=“http://www.opengis.net/ogc
xmlns:gml=“http://www.opengis.net/gml
xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance
xsi:schemaLocation=“http://www.opengis.net/wfs
http://schemas.opengis.net/wfs/1.1.0/wfs.xsd”>
<wfs:Query typeName=“topp:states”>
wfs:PropertyNametopp:STATE_NAME</wfs:PropertyName>
wfs:PropertyNametopp:PERSONS</wfs:PropertyName>
ogc:Filter
ogc:BBOX
ogc:PropertyNamethe_geom</ogc:PropertyName>
<gml:Envelope srsName=“http://www.opengis.net/gml/srs/epsg.xml#4326”>
gml:lowerCorner-75.102613 40.212597</gml:lowerCorner>
gml:upperCorner-72.361859 41.512517</gml:upperCorner>
</gml:Envelope>
</ogc:BBOX>
</ogc:Filter>
</wfs:Query>
</wfs:GetFeature>

as a GET request it fails - I’ve tried setting the filter as both (suitably encoded of course)
<ogc:Filter xmlns:ogc=“http://www.opengis.net/ogc” xmlns:gml=“http://www.opengis.net/gml”>ogc:BBOXogc:PropertyNamethe_geom</ogc:PropertyName><gml:Envelope srsName=“http://www.opengis.net/gml/srs/epsg.xml#4326”>gml:lowerCorner-75.102613 40.212597</gml:lowerCorner> gml:upperCorner-72.361859 41.512517</gml:upperCorner> </gml:Envelope></ogc:BBOX></ogc:Filter>
the_geom<gml:Envelope srsName=“http://www.opengis.net/gml/srs/epsg.xml#4326”>gml:lowerCorner-75.102613 40.212597</gml:lowerCorner> gml:upperCorner-72.361859 41.512517</gml:upperCorner> </gml:Envelope>

The first fails with xml must start and end with the same entity (?) and the second barfs at gml:Envelope saying its not a recognized element. Finally leaving out all the namespaces gives XML document structures must start and end within the same entity again.

This is occurring with both 1.7.2 and 1.7.3 - am I missing something obvious or should I file a bug?

Ian

Ian Turton
http://www.geotools.org
http://pennspace.blogspot.com/

Ian Turton ha scritto:

As part of a larger query one of my students is having a problem with BBOX filters in WFS
When we do the equivalent of

<wfs:GetFeature service="WFS" version="1.1.0"
  xmlns:topp="http://www.openplans.org/topp&quot;
  xmlns:wfs="http://www.opengis.net/wfs&quot;
  xmlns:ogc="http://www.opengis.net/ogc&quot;
  xmlns:gml="http://www.opengis.net/gml&quot;
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance&quot;
  xsi:schemaLocation="http://www.opengis.net/wfs
                      http://schemas.opengis.net/wfs/1.1.0/wfs.xsd&quot;&gt;
  <wfs:Query typeName="topp:states">
    <wfs:PropertyName>topp:STATE_NAME</wfs:PropertyName>
    <wfs:PropertyName>topp:PERSONS</wfs:PropertyName>
    <ogc:Filter>
      <ogc:BBOX>
        <ogc:PropertyName>the_geom</ogc:PropertyName>
        <gml:Envelope srsName="http://www.opengis.net/gml/srs/epsg.xml#4326&quot;&gt;
           <gml:lowerCorner>-75.102613 40.212597</gml:lowerCorner>
           <gml:upperCorner>-72.361859 41.512517</gml:upperCorner>
        </gml:Envelope>
      </ogc:BBOX>
   </ogc:Filter>
  </wfs:Query>
</wfs:GetFeature>

as a GET request it fails - I've tried setting the filter as both (suitably encoded of course)
<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc&quot; xmlns:gml="http://www.opengis.net/gml&quot;&gt;&lt;ogc:BBOX&gt;&lt;ogc:PropertyName&gt;the\_geom&lt;/ogc:PropertyName&gt;&lt;gml:Envelope srsName="http://www.opengis.net/gml/srs/epsg\.xml\#4326&quot;&gt;&lt;gml:lowerCorner&gt;\-75\.102613 40.212597</gml:lowerCorner> <gml:upperCorner>-72.361859 41.512517</gml:upperCorner> </gml:Envelope></ogc:BBOX></ogc:Filter>
    <Filter xmlns:gml="http://www.opengis.net/gml&quot;&gt;&lt;BBOX&gt;&lt;PropertyName&gt;the\_geom&lt;/PropertyName&gt;&lt;gml:Envelope srsName="http://www.opengis.net/gml/srs/epsg\.xml\#4326&quot;&gt;&lt;gml:lowerCorner&gt;\-75\.102613 40.212597</gml:lowerCorner> <gml:upperCorner>-72.361859 41.512517</gml:upperCorner> </gml:Envelope></BBOX></Filter>

The first fails with xml must start and end with the same entity (?) and the second barfs at gml:Envelope saying its not a recognized element. Finally leaving out all the namespaces gives XML document structures must start and end within the same entity again.

This is occurring with both 1.7.2 and 1.7.3 - am I missing something obvious or should I file a bug?

You are probably stumbling into this:
http://jira.codehaus.org/browse/GEOS-2028

Cheers
Andrea

--
Andrea Aime
OpenGeo - http://opengeo.org
Expert service straight from the developers.

Andrea Aime ha scritto:

Ian Turton ha scritto:

As part of a larger query one of my students is having a problem with BBOX filters in WFS
When we do the equivalent of

<wfs:GetFeature service="WFS" version="1.1.0"
  xmlns:topp="http://www.openplans.org/topp&quot;
  xmlns:wfs="http://www.opengis.net/wfs&quot;
  xmlns:ogc="http://www.opengis.net/ogc&quot;
  xmlns:gml="http://www.opengis.net/gml&quot;
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance&quot;
  xsi:schemaLocation="http://www.opengis.net/wfs
                      http://schemas.opengis.net/wfs/1.1.0/wfs.xsd&quot;&gt;
  <wfs:Query typeName="topp:states">
    <wfs:PropertyName>topp:STATE_NAME</wfs:PropertyName>
    <wfs:PropertyName>topp:PERSONS</wfs:PropertyName>
    <ogc:Filter>
      <ogc:BBOX>
        <ogc:PropertyName>the_geom</ogc:PropertyName>
        <gml:Envelope srsName="http://www.opengis.net/gml/srs/epsg.xml#4326&quot;&gt;
           <gml:lowerCorner>-75.102613 40.212597</gml:lowerCorner>
           <gml:upperCorner>-72.361859 41.512517</gml:upperCorner>
        </gml:Envelope>
      </ogc:BBOX>
   </ogc:Filter>
  </wfs:Query>
</wfs:GetFeature>

as a GET request it fails - I've tried setting the filter as both (suitably encoded of course)
<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc&quot; xmlns:gml="http://www.opengis.net/gml&quot;&gt;&lt;ogc:BBOX&gt;&lt;ogc:PropertyName&gt;the\_geom&lt;/ogc:PropertyName&gt;&lt;gml:Envelope srsName="http://www.opengis.net/gml/srs/epsg\.xml\#4326&quot;&gt;&lt;gml:lowerCorner&gt;\-75\.102613 40.212597</gml:lowerCorner> <gml:upperCorner>-72.361859 41.512517</gml:upperCorner> </gml:Envelope></ogc:BBOX></ogc:Filter>
    <Filter xmlns:gml="http://www.opengis.net/gml&quot;&gt;&lt;BBOX&gt;&lt;PropertyName&gt;the\_geom&lt;/PropertyName&gt;&lt;gml:Envelope srsName="http://www.opengis.net/gml/srs/epsg\.xml\#4326&quot;&gt;&lt;gml:lowerCorner&gt;\-75\.102613 40.212597</gml:lowerCorner> <gml:upperCorner>-72.361859 41.512517</gml:upperCorner> </gml:Envelope></BBOX></Filter>

The first fails with xml must start and end with the same entity (?) and the second barfs at gml:Envelope saying its not a recognized element. Finally leaving out all the namespaces gives XML document structures must start and end within the same entity again.

This is occurring with both 1.7.2 and 1.7.3 - am I missing something obvious or should I file a bug?

You are probably stumbling into this:
http://jira.codehaus.org/browse/GEOS-2028

Oh, as a workaround, for just a bbox filter use
&bbox=xmin,ymin,xmax,ymax[,srs]
and if you need more filtering abilities, you can use our
custom
&CQL_FILTER=bbox(the_geom,xmin,ymin,xmax,ymax) AND att1 = 'blah' AND att2 < att3 + att4 AND ...
(you get the idea)

Cheers
Andrea

--
Andrea Aime
OpenGeo - http://opengeo.org
Expert service straight from the developers.

On Fri, Apr 24, 2009 at 4:15 AM, Andrea Aime <aaime@anonymised.com1…> wrote:

Andrea Aime ha scritto:

Ian Turton ha scritto:

As part of a larger query one of my students is having a problem with BBOX filters in WFS
When we do the equivalent of

<wfs:GetFeature service=“WFS” version=“1.1.0”
xmlns:topp=“http://www.openplans.org/topp
xmlns:wfs=“http://www.opengis.net/wfs
xmlns:ogc=“http://www.opengis.net/ogc
xmlns:gml=“http://www.opengis.net/gml
xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance
xsi:schemaLocation=“http://www.opengis.net/wfs
http://schemas.opengis.net/wfs/1.1.0/wfs.xsd”>
<wfs:Query typeName=“topp:states”>
wfs:PropertyNametopp:STATE_NAME</wfs:PropertyName>
wfs:PropertyNametopp:PERSONS</wfs:PropertyName>
ogc:Filter
ogc:BBOX
ogc:PropertyNamethe_geom</ogc:PropertyName>
<gml:Envelope srsName=“http://www.opengis.net/gml/srs/epsg.xml#4326”>
gml:lowerCorner-75.102613 40.212597</gml:lowerCorner>
gml:upperCorner-72.361859 41.512517</gml:upperCorner>
</gml:Envelope>
</ogc:BBOX>
</ogc:Filter>
</wfs:Query>
</wfs:GetFeature>

as a GET request it fails - I’ve tried setting the filter as both (suitably encoded of course)
<ogc:Filter xmlns:ogc=“http://www.opengis.net/ogc” xmlns:gml=“http://www.opengis.net/gml”>ogc:BBOXogc:PropertyNamethe_geom</ogc:PropertyName><gml:Envelope srsName=“http://www.opengis.net/gml/srs/epsg.xml#4326”>gml:lowerCorner-75.102613 40.212597</gml:lowerCorner> gml:upperCorner-72.361859 41.512517</gml:upperCorner> </gml:Envelope></ogc:BBOX></ogc:Filter>
the_geom<gml:Envelope srsName=“http://www.opengis.net/gml/srs/epsg.xml#4326”>gml:lowerCorner-75.102613 40.212597</gml:lowerCorner> gml:upperCorner-72.361859 41.512517</gml:upperCorner> </gml:Envelope>

The first fails with xml must start and end with the same entity (?) and the second barfs at gml:Envelope saying its not a recognized element. Finally leaving out all the namespaces gives XML document structures must start and end within the same entity again.

This is occurring with both 1.7.2 and 1.7.3 - am I missing something obvious or should I file a bug?

You are probably stumbling into this:
http://jira.codehaus.org/browse/GEOS-2028

Oh, as a workaround, for just a bbox filter use
&bbox=xmin,ymin,xmax,ymax[,srs]
and if you need more filtering abilities, you can use our
custom
&CQL_FILTER=bbox(the_geom,xmin,ymin,xmax,ymax) AND att1 = ‘blah’ AND att2 < att3 + att4 AND …
(you get the idea)

Thanks that will work for now, but it would be nice if this worked (or gave a better error message).

Ian