Wednesday, 20 February 2019

MapServer: Symbol (v-line) style that automatically follows line direction


I created this image:


enter image description here



with:


MAP
SIZE 1000 1000
IMAGETYPE png24
EXTENT -30 -10 60 30
UNITS DD

SYMBOL
NAME "v-line-shift"
TYPE vector

POINTS
0 0
5 10
10 0
END # POINTS
ANCHORPOINT 0.5 0
END # SYMBOL

LAYER # Simple line
STATUS DEFAULT

TYPE LINE
FEATURE
POINTS
5 25
25 20
45 20
35 15
END # Points
END # Feature
CLASS

STYLE
COLOR 0 0 0
WIDTH 2.5
END # STYLE
STYLE
SYMBOL "v-line-shift"
COLOR 0 0 0
SIZE 8
INITIALGAP 1
GAP 10

END
END # CLASS
END # LAYER
END # MAP

and I would like to know if these arrows can automatically follow the direction of this changing line (ie. arrow would be aligned with the line, something like e.g., ---->---->---)


I'm using MapServer 6.4.1.




I enclose here an example of the end result.


enter image description here




Answer



I have used an arrow symbol as:


SYMBOL
NAME "arrow"
TYPE vector
FILLED true
POINTS
0 0.4
3 0.4
3 0

5 0.8
3 1.6
3 1.2
0 1.2
0 0.4
END # POINTS
ANCHORPOINT 1 0.5
END # SYMBOL

This style adds an arrowhead to endpoints of lines



STYLE
GEOMTRANSFORM "end"
COLOR 100 200 100
SYMBOL "arrow"
SIZE 7.0
ANGLE AUTO
END # STYLE

In your case it might be enough just to add ANGLE AUTOinto your style. If not, a truetype character symbol may work better:


SYMBOL

NAME "V"
TYPE truetype
FONT "arial"
CHARACTER "V"
END # SYMBOL

Probably character ">" is the one for you but I took "V" because it should at least work if "P" works as in document http://www.mapserver.org/mapfile/symbology/construction.html.


And one more thing to try: GEOMTRANSFORM "vertices", read http://mapserver.org/fr/mapfile/geomtransform.html.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...