MapServer LAYER>CLASS Object

Allows classifications against datasets.  Every Layer object MUST have a CLASS object.  For full details of the MapServer LAYER>CLASS Object please see the MapServer MAP Documentation.

If you are using MapInfo TAB files you have a STYLEITEM “auto” option in the Layer object.  In this case you have a simple empty CLASS END item.

Element

Description

Example

NAME

OPTIONAL – used when showing Legends as title.

“More than 30”

EXPRESSION

Expressions are very powerful.  You can use Regular Expressions, SQL Like expressions or simply an attribute value.

See following for more info:

http://www.mapserver.org/mapfile/expressions.html

EXPRESSION ([Total] < 6)

EXPRESSION /^(REAR OF|ACCESS)/

EXPRESSION "2005"

STYLE

MapServer allows you to define styles for features.  These can be stacked on top of each other.

 

LABEL

The Label class can allow for multiple columns to form an Expression for the label.

 

 

Complex class against a single layer.  Defining which features should be labeled and which shouldn’t.

CLASS Object
CLASS
   NAME "NoStreetLabels"
   EXPRESSION /^(REAR OF|ACCESS)/ #words WITH attribute defined by LAYER -> CLASSITEM
   STYLE
      COLOR 192 192 192
      SYMBOL 'continue' 
      SIZE 5
      ANTIALIAS TRUE
   END
   STYLE
      COLOR 255 255 255 
      SYMBOL 'continue' 
      SIZE 3
      ANTIALIAS TRUE
   END 
   END
CLASS
   NAME "StreetLabels"
   STYLE
      COLOR 192 192 192
      SYMBOL 'continue' 
      SIZE 5
      ANTIALIAS TRUE
   END
   STYLE
      COLOR 255 255 255 
      SYMBOL 'continue' 
      SIZE 3
      ANTIALIAS TRUE
   END 
   LABEL
      FONT "arial"
      TYPE TRUETYPE
      ANTIALIAS TRUE
      COLOR 40 40 40
      OUTLINECOLOR 255 255 255
      SIZE 7
      POSITION AUTO
      PARTIALS FALSE
      #MINDISTANCE 800
      BUFFER 4
      ANGLE AUTO
   END
END