1. Advanced Cartography
with MapServer 6.2
17 / 10 / 2012 Thomas Bonfort (Terriscope)
Rencontres OSGEO
2. 6.2 Rendering Highlights
• SVG Symbols
• Vector Fields
• Complex Symbols
• Offset Labels
• Layer Masking
• Multiple Fonts for International Text
3. SVG Symbols
• Existing symbology limited for some use cases
• Scalable, multiple colors
SYMBOL STYLE
NAME "svgsymbol" SYMBOL "svgsymbol"
TYPE SVG SIZE 10
IMAGE "/path/to/symbol.svg" ANGLE 45
END END
4. MultiLanguage Font Support
• LABEL->FONT now
takes comma
separated list of fonts
to try
• Each font will be tried
in turn if glyph not
found
5. Mask Layers
• Clip rendered data across given features
layer
status on
name ”naturalearth”
mask “countries”
type raster
layer
name "countries”
status off
class
expression (“[FIPS]” = “EZ”)
style
color 0 0 0
6. Precise symbol placement
• Default is to center symbol on feature point
• Typically useful for arrow type symbols
• SYMBOL
– ANCHORPOINT x y
• STYLE
– POLAROFFSET [distance] [bearing]
8. Complex symbols
• Collision avoidance: implemented along with
the labelcache.
• “All or nothing” approach: in case of collision,
whole symbol is discarded.
• Each sub-symbol is positioned relatively to the
anchor point, and defined as a LABEL block.
• Collision detection between sub-symbols is
optional.
• Addresses meteo symbol generation, other use
cases in future versions
9. Complex symbols
LAYER
CLASS
LABEL
OFFSET -15 -10
FORCE GROUP
TEXT “[temp]”
END
LABEL
EXPRESSION ([wind_speed]<=5)
STYLE
GEOMTRANSFORM “labelpnt”
SYMBOL “v5”
SIZE 30
ANGLE [wind_angle]
FORCE GROUP
END
END
LABEL
EXPRESSION ([wind_speed]<=10)
STYLE
SYMBOL “v10”
…
END
END
….
11. Vector Fields
• u,v components stored in raster bands
• Mapped to vector points in resulting map
• Additional bindings used for styling:
– [uv_angle]
– [uv_length]
• Decoupling size of arrow body and head
12. Vector Fields
SYMBOL LAYER
NAME "arrowbody" TYPE POINT
TYPE VECTOR CONNECTIONTYPE uvraster
POINTS DATA “wind.tif”
00 CLASS
10 STYLE
END # points SYMBOL "arrowbody"
END ANGLE [uv_angle]
SIZE [uv_length]
SYMBOL COLOR 0 127 20
NAME "arrowhead" END
TYPE vector
FILLED true STYLE
ANCHORPOINT 1 0.5 SYMBOL "arrowhead"
POINTS ANGLE [uv_angle]
02 SIZE 10
41 COLOR 255 0 0
00 POLAROFFSET [uv_length_2] [uv_angle]
END END
END END
END
13. Label Leader Offsetting
• Displace label if collision occurs on initial
position
• NP-hard problem!
– Test offsetted positions on a regular grid
– O(nlabels * image_size)
• Leader line can be styled
• Offsets whole label group, future work on
offsetting each sub-label
14. Label Leader Offsetting
LAYER
CLASS
LEADER
MAXDISTANCE 100
GRIDSTEP 10
STYLE
COLOR 0 0 0
WIDTH 1
#PATTERN 2 2 END
END
END
LABEL
…
END
END
END