[OpenLayers-Dev] Filter and BBOX in WFS layer

Matt Priour mpriour at kestrelcomputer.com
Wed Mar 12 12:38:43 EDT 2008


I also just struggled with this over the past week and came to the same conclusion as you. OpenLayers WFS layer class just will not work with a FILTER as it is now.
It also uses LoadURL which is hardcoded to use GET, so you can't use anything but fairly simple filters.
I did not need the BBOX information for my requests, although you can include it in the FILTER and in that way use both BBOX & FILTER methods to narrow the features returned.
I ended up just using XHR via OpenLayers.Ajax.Request to get the features I needed since I had to use POST due to the FILTER length.
I then used the GML parser and loaded the features into a vector layer.

Another note about using POST in OpenLayers:
the correct option to use for specifying the body of the POST request directly is "postBody".
This is not documented anywhere that I could find and not as obvious as the other options.

Matt Priour
Kestrel Computer Consulting
www.kestrelcomputer.com
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  Hi list,

  For a project I need to add a Filter to each WFS GetFeature request. In this
  case to filter features for a specific user. Since the Filter isn't big, I'd
  like to use the FILTER parameter of the KVP encoding. The current
  implementation of a WFS layer always uses the BBOX parameter in the moveTo
  function however. If adding the FILTER parameter, the WFS returns an
  exception, because BBOX and FILTER are mutually exclusive.

  People came across this before and a ticket has been created already:
  http://trac.openlayers.org/ticket/1113.

  Another solution is not to use the BBOX parameter at all and provide a
  Filter (that may contain a Bbox constraint, only if you like that ;) ) in
  the params of the layer. For this I made some small adjustments to the WFS
  layer implementation. I've created a ticket with a patch here:
  http://trac.openlayers.org/ticket/1430  With the useBbox option on a WFS
  layer, the use of the BBOX parameter in GetFeature requests can be switched
  off.

  Hope this is useful for others as well.

  Regards,
  Thijs
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-dev/attachments/20080312/a403f09d/attachment.html


More information about the Dev mailing list