working with filters and expressions

Paul Spencer pspencer at DMSOLUTIONS.CA
Wed May 4 06:55:04 EDT 2005


use CLASSITEM "TYPE" in your LAYER object and use EXPRESSION "Unpaved"
in your class.  MapServer will only draw features that match a class.
You can add multiple classes to draw the features you want and any
unmatched features will be ignored (unless you add a class to draw them).

Also, mapserver processes classes on a first come-first serve basis so
if a feature could fit into more than one class, it will always be drawn
in the first class (reading top to bottom in your map file) that it matches.

Cheers

Paul

James Anderson wrote:
>
> Hi all,
>
> I have a great problem.
> I have a shape file layer of some roads.  All the different road types
> are in the same shape file, and Attibute data is used to specify the
> road type.  I have a attribute/column named TYPE.  The data here ... eg
> road types are Paved,Unpaved, Dirt Road, etc
>
> Now what I want is to filter out the road types I dont want.  For this I
> was assuming the FILTER paramenter under the layer could work.
> I have now tried numerous things but nothing much works.  I see lots of
> others having problems with this.  Reading posts here I see lots of
> conflicting info.  Some also say you can do the same with the EXPRESSION
> parameter under your class.
> Now I am totally confused.  I have tired things like
>
> FILTER "([TYPE]='Paved' or [TYPE]='Unpaved')"
> FILTER "([TYPE] eq 'Paved' or [TYPE] eq 'Unpaved')"
>
> To try and show only paved and unpaved roads.
> I get nothing .. not a single thing shows up.  Yet if I remove the
> filter parameter, all the roads types show.
> So I also tried
>
> FILTER "([TYPE]='Paved')"
> FILTER "([TYPE] eq 'Paved')"
> FILTER ([TYPE]='Paved')
> FILTER ([TYPE] eq 'Paved')
>
> I get same result .. nothing shows when the filter is present.
> However, I have managed to get one thing working:
>
> FILTERITEM "TYPE"
> FILTER "Paved"
>
> This works in that it shows only paved roads.  Yet the moment I try and
> get it to work on more than one roadtype, it freaks out and shows
> nothing.  I tried doing similar things with the Expression parameter but
> also with no results.
>
> My Layer looks like this:
>
>
> LAYER
>         NAME "tr_ro_final"
>         TYPE line
>         CONNECTIONTYPE OGR
>         CONNECTION "/maps/tr_ro_final.shp"
>         STATUS DEFAULT
>         #FILTER "[TYPE] eq 'Unpaved'"
>         #FILTERITEM "TYPE"
>
>         #FILTER '!"Dirt Road"'
>         #MINSCALE  3.01
>         #MAXSCALE 99.01
>         CLASS
>                 #Expression ([TYPE] eq "Unpaved")
>                 #COLOR 151 75 0
>                 COLOR 255 0 0
>                 SYMBOL "circle"
>                 SIZE 3
>         END
> END
> As you can see I have still left in some of the things I was playing
> with.  Still .. I have not got far.  I have not been able to find any
> proper documentation of using mapserver regex or using the filter
> parameter properly.
>
> My mapserver version:
>
> MapServer version 4.4.0 OUTPUT=PNG OUTPUT=JPEG OUTPUT=WBMP SUPPORTS=PROJ
> SUPPORTS=FREETYPE SUPPORTS=WMS_SERVER INPUT=EPPL7 INPUT=OGR INPUT=GDAL
> INPUT=SHAPEFILE
> Can anyone help me ?  I am desperate to finally figure this out once and
> for all.
>
> Thanks,
>
> James Anderson.
>
>
>
>
>
>

--
+-----------------------------------------------------------------+
|Paul Spencer                           pspencer at dmsolutions.ca   |
+-----------------------------------------------------------------+
|Applications & Software Development                              |
|DM Solutions Group Inc                 http://www.dmsolutions.ca/|
+-----------------------------------------------------------------+



More information about the mapserver-users mailing list