Saturday, September 26, 2009

Tweaking OpenLayers WFS requests to work with featureid

OpenLayers (at least as of 2.8) WFS requests always include the bbox, but that doesn't work if you specify a featureid (the two are defined as mutually exclusive).  Here's a quick work-around for this problem using apache's mod_rewrite.

I'm using apache as an AJP proxy in front of geoserver, but there's no reason this wouldn't work with other WFS servers like mapserver, etc. Put this in the appropriate config file:

RewriteEngine On

RewriteCond %{QUERY_STRING} featureid=[^&]+ [NC]
RewriteCond %{QUERY_STRING} (.*)bbox=[^&]+(.*) [NC]
RewriteRule (.*)  $1?%1%2 [P,L]

ProxyPass /geoserver/ ajp://localhost:8009/geoserver/

No comments:

Post a Comment