[OpenLayers-Users] CQL queries with WFS

Christopher Schmidt crschmidt at metacarta.com
Wed Jul 1 11:10:01 EDT 2009


On Wed, Jul 01, 2009 at 04:57:15PM +0200, Per Engström wrote:
> Hi!
> 
> I've been looking at an old conversation (Aug 2008) with the same subject as
> this where 'Todd Brenningmeyer' tried to use a cql-filter / filter on a
> OpenLayers.Layer.WFS with no luck.
> 
> var wfsLayer = new OpenLayers.Layer.WFS("My layer",
>     http://localhost:8080/geoserver/wfs,
>     {
>         styleMap: myStyle
>     }
> );
> wfsLayer.mergeNewParams({'CQL_FILTER': 'id=1'});
> 
> He found out that OpenLayers added a BBOX at the end of the request.
> 
> I dug a little bit further and found out that this ALWAYS is added in the
> moveTo function of OpenLayers.Layer.WFS. When a filter or cql filter is used
> in the same request as a bbox to a GeoServer you get the following response:
> 
> <?xml version="1.0" ?>
> <ServiceExceptionReport
>    version="1.2.0"
>    xmlns="http://www.opengis.net/ogc"
>    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>    xsi:schemaLocation="http://www.opengis.net/ogc
> http://schemas.opengis.net/wfs/1.0.0/OGC-exception.xsd">
>    <ServiceException>filter and bbox both specified but are mutually
> exclusive</ServiceException>
> </ServiceExceptionReport>
> 
> What would be the correct way to exclude the bbox parameter from the
> request? I would really not like to use Todd's workaround and use a GML
> layer!

1. Dont' use Layer.WFS. Instead, use a Layer.Vector with a WFS protocol.
2. Use OpenLayers 2.8, which looks for layer.params.filter and doesn't
   add a bbox if it's there, but this is just a hack, and not the
   recommended way to use WFS.

Regards,
-- 
Christopher Schmidt
MetaCarta



More information about the Users mailing list