0

I have MapServer setup to display data (both WMS and WFS), however I'm having a problem adding a default filter.

There's is an area on the map that users should not be able to retrieve features from. I have the coordinates of this area so basically, I need to setup a default spatial filter to exclude features that are contained within this area. Removing the data itself isn't an option.

The layers are all OGR layers.

I can construct a client side filter to do this, however this should really be a server-side setting.

How should I go about doing this?

Ignoring the spatial requirement for a second, I'm having problems getting even a basic filter to work. If I append the following to the URL of a WFS request, this filter works as expected:

(Note this filter has no actual relevance, it's just a simple filter so I can check if it's being applied)

&FILTER="<PropertyIsGreaterThan><PropertyName>ID</PropertyName><Literal>916</Literal></PropertyIsGreaterThan>"

However, if in the map file I set the following:

LAYER
 ...
 FILTER "<PropertyIsGreaterThan><PropertyName>ID</PropertyName><Literal>916</Literal></PropertyIsGreaterThan>"
 ...
END

Then I get no results from any query on that layer. Wrapping the filter in <Filter> tags has the same result.

I've also tried similar with the wfs_filter property, which doesn't seem to have any affect at all. (If I understand correctly, this is only used when using MapServer as a WFS Client?)

PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Dec 17, 2013 at 11:58

1 Answer 1

2

The filter you are trying to apply can only be applied from the client side. To apply a filter on the server side, you have to use an EXPRESSION at the CLASS level or a FILTER at the LAYER level. Note that spatial filter/expression may not work in FILTER. Here's an example:

LAYER
 DATA ....shp
 NAME "test"
 ...
 CLASS
 NAME "test"
 EXPRESSION ([shape] disjoint fromText('POLYGON((0 0,0 90,180 90,180 0,0 0))'))
 STYLE
 ...
 END
 END
END

Refer to the EXPRESSION documentation for more details: http://mapserver.org/mapfile/expressions.html

answered Dec 17, 2013 at 15:43

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.