Style Object

This object holds parameters for symbolization. Multiple styles may be applied within a class. This object is new in 4.0 and is intended to seperate logic from looks. The final intent is to have named styles (Not yet supported) that will be re-usable through the mapfile. This is the new, preferred way of defining the appearance of an object, notably a class.

ANTIALIAS [true|false]

Should TrueType fonts and Cartoline symbols be antialiased.

BACKGROUNDCOLOR [r] [g] [b]

Color to use for non-transparent symbols.

........................................................


Symbology Reference

This section explains how to work with and define symbology in MapServer.

Notes

  • Symbol definitions can be included within the main MapFile or, more commonly, in a separate file. Symbol definitions in a separate file are designated using the SYMBOLSET keyword, as part of the Map Object. This recommended setup is ideal for re-using symbol definitions across multiple MapServer applications.

  • There are 3 main types of symbols in MapServer: Markers, Shadesets, and Lines.

  • Symbol 0 is always the degenerate case for a particular class of symbol. For points, symbol 0 is a single pixel, for shading (i.e. filled polygons) symbol 0 is a solid fill, and for lines, symbol 0 is a single pixel wide line.

  • Symbol definitions contain no color information, colors are set within CLASS objects.

  • There is a maximum of 64 symbols per file. This can be changed by editing mapsymbol.h and changing the value of MS_MAXSYMBOLS at the top of the file.

Syntax

ANTIALIAS [true|false]

Should TrueType fonts be antialiased.

CHARACTER [char]

Character used to reference a particular TrueType font character. You'll need to figure out the mapping from the keyboard character to font character.

FILLED [true|false]

Sets the symbol to be filled with a user defined color (See the CLASS object). For marker symbols, if OUTLINECOLOR was specified then the symbol is outlined with it.

FONT [string]

Name of TrueType font to use as defined in the FONTSET.

GAP [int]

Given in pixels. This defines a distance between symbols for TrueType lines.

IMAGE [string]

Image (GIF or PNG) to use as a marker or brush for type PIXMAP symbols.

NAME [string]

Alias for this font to be used in CLASS objects

LINECAP [butt|round|square|triangle]

Sets the line cap type for the cartoline symbol. Default is butt. Works with the CARTOLINE symbol only!

LINEJOIN [round|miter|bevel]

Sets the line join type for the cartoline symbol. Default is "none" - lines will not be joined . Works with the CARTOLINE symbol only!

LINEJOINMAXSIZE [num]

Sets the max length of the miter line join type. The value represents a coefficient which multitplies a current symbol size. Default is 3. Works with the CARTOLINE symbol only!

POINTS [x y] [x y] ... END

Signifies the start of the definition of points that make up a vector symbol or that define the x and y radius of an ellipse symbol. The end of this section is signified with the keyword END. Coordinates are given in pixels and define the default size of the symbol before any scaling. You can create non-contiguous paths by inserting negative coordinates at the appropriate place. For ellipse symbols you provide a single point that defines the x and y radius of an ellipse. Circles are created when x and y are equal.

STYLE [num on] [num off] [num on] ... END

Defines a dash style or pattern.

TRANSPARENT [color index]

Sets a transparent color for the input GIF image for pixmap symbols, or determines whether all shade symbols should have a transparent background. For shade symbols it may be desirable to have background features "show through" a transparent hatching pattern, creating a more complex map. By default a symbol's background is the same as the parent image (i.e. color 0). This is user configurable.

TYPE [vector|ellipse|pixmap|truetype|simple|cartoline]

  • vector: a simple drawing is used to define the shape of the symbol.

  • ellipse: radius values in the x and y directions define an ellipse.

  • pixmap: a user supplied GIF image will be used as the symbol.

  • truetype: TrueType font to use as defined in the FONTSET.

Examples

Here are some examples illustrating the various ways to create symbols in MapServer:

Example 3. Dashed Line

SYMBOL
NAME 'dashed1'
TYPE ELLIPSE
POINTS 1 1 END
FILLED true
STYLE 10 5 5 10 END
END

This creates a dashed line with 10 pixels on, 5 off, 5 on, 10 off ...

Example 4. TrueType font marker symbol

SYMBOL
NAME "natcap"
TYPE TRUETYPE
FONT geo
FILLED true
ANTIALIAS true
CHARACTER "r"
END

This symbol is a star, used to represent the national capital, hence the name. The font name in defined in the FONTSET file. The code number "114" varies, you can use MS Windows' character map to figure it out, or guestimate.

Example 5. Vector triangle marker symbol

SYMBOL
NAME "triangle"
TYPE vector
POINTS
0 4
2 0
4 4
0 4
END
END

This is fairly straight forward. Note that to have 3 sides you need 4 points, hence the first and last points are identical.

Example 6. Non-contiguous vector marker symbol (Cross)

SYMBOL
NAME "cross"
TYPE vector
POINTS
2 0
2 4
-99 -99
0 2
4 2
END
END

This example draws a cross, that is 2 lines (vectors) that are not connected end-to-end (Like the triangle in the previous example). The negative values separate the two.

Example 7. Circle vector symbol

SYMBOL
NAME "circle"
TYPE ellipse
FILLED true
POINTS
1 1
END
END

A simple filled circle. Using non-equal values for the point will give you an actual ellipse.

Example 8. Downward diagonal fill

SYMBOL   
NAME "downwarddiagonalfill"
TYPE vector
TRANSPARENT 0
POINTS
0 1
1 0
END
END

Example 9. Dashed Cartoline symbol

SYMBOL   
NAME "cartoline"
TYPE cartoline
LINECAP butt
LINEJOIN miter
LINEJOINMAXSIZE 1
STYLE 10 5
END

This creates a dashed line with 10 pixels on, 5 off,... The line will have butt caps and short miter joins. For layers with a scaled symbol (SYMBOLSCALE, MINSIZE, MAXSIZE, ...) will be the STYLE  resized to maintain symbol ratios.

Add a Comment