Anyone knows if there is a way to set a spatial filter in a mapfile to use with normal requests, not only WMS or WFS? I need this spatial filter to be any kind of polygon, not just rectangles, because these filters on our system are dynamic: users are allowed to draw polygons or select them from the polygon layers. It's a system where users use a legacy desktop application with no map capabilities, only requests Mapserver for images, so I have to do these filtering on the Mapserver side
To put it simply, here goes an example: users have layers with data like street names (labeled points) and districts (polygons). One of them may want to see only those streets that fall within district number two, so I want Mapserver to generate images hiding the rest of the streets. Of course, in the streets layer there is no information about in which district is located the street
Some things to help you ask this question:
- Requests are cgi, not WMS but I could change that if it helps
- I'm not using Mapscript nor any client like OpenLayers or uDig
- Layers don't have and won't have attribute relations
- I know about FILTER parameter in LAYER section but it's only for attribute filtering
- I read about "Filter encoding" (included in SLD) but can't make it work, and it seems only for WFS
- I've seen CQL but it's not supported in Mapserver directly, only through SLD
How do you do spatial filtering for image generation in Mapserver?
Thanks
You could use WMS requests to return features within a bounding box.
See http://mapserver.org/ogc/wms_server.html
BBOX=minx,miny,maxx,maxy: Bounding box corners (lower left, upper right) in SRS units
A request would be similar to:
http://my.host.com/cgi-bin/mapserv?map=mywms.map&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&LAYERS=prov_bound&STYLES=&SRS=EPSG:4326&BBOX=-173.537,35.8775,-11.9603,83.8009&WIDTH=400&HEIGHT=300&FORMAT=image/png
Alternatively you could create queries in a spatial database (if you are using one), and pass in feature Ids and filter there.