Server Spatial Filtering
Does anyone know if there is a way to set a spatial filter in the map file for use with regular queries, not just WMS or WFS? I need this spatial filter like any polygon, not just rectangles, because these filters in our system are dynamic: users are allowed to draw polygons or select them from polygon layers. This is a system where users are using a legacy desktop app without any map capabilities, only asks Mapserver for images, so I have to do this filtering on the Mapserver side
Simply put, here's an example: users have layers with data such as street names (tagged points) and districts (polygons). One of them might only want to see streets that fall in area two, so I want Mapserver to generate images that hide the rest of the streets. Of course, at street level there is no information about which area the street is in.
Some questions to help you ask this question:
- Requests are cgi, not WMS, but I can change this if it helps
- I am not using Mapscript or any client like OpenLayers or uDig
- Layers do not and will not have an attribute relationship
- I know the FILTER parameter in the LAYER section, but only for filtering attributes
- I read about "filter encoding" (included in SLD) but can't get it to work and it seems to be only for WFS
- I have seen CQL, but it is not supported directly in Mapserver, only via SLD
How do you perform spatial filtering to generate images in Mapserver?
thank
Generally there are two ways to make a spatial / non-spatial query as far as I know. The filter coding is used first, for example using a parameter in the wms url. for example http: //.../mapserv? map = .. & param = value
Another way to do this is to use a filter in the request body. Suppose you can send a request to the server, you can use a filter for complex spatial / non-partisan queries in one filter. For more information, see Map Server Filter Page. There are many spatial filter operations such as presence, intersection, etc.
The filter inside the map file is slightly different, it is a predefined filter for the data source. This works when you have logic to filter data even before a client request comes in. (See more information on the OGC and CQL search filter for GeoServer currently)
And SLD works at render time to filter data. It also works with both spatial and spatial filter. But it only reflects the getmap operation.
source to share
You can use WMS queries to return functions to a bounding box.
See http://mapserver.org/ogc/wms_server.html
BBOX = minx, miny, maxx, maxy: bounded corners of the window (bottom left, top right) in SRS units
The request will be similar to:
Alternatively, you can create queries in a spatial database (if you are using one) and also pass in object IDs and filter them.
source to share