street labeling
Stephen Lime
steve.lime at dnr.state.mn.us
Tue Nov 23 09:01:50 PST 1999
Nathan and all: I'll address symbol scaling and line labeling here.
Symbol scaling requires 3 things:
- map UNITS to be set
- layer SYMBOLSCALE to be set
- a scaleable symbol (only image symbols are not scalable)
UNITS are the units of a projection/coordinate system and are
needed to calculate scale. SYMBOLSCALE is the scale at which
a symbol or font should appear full size (eg. the defined size). Note
that only truetype fonts are scalable. Scaling works fine for shade
and marker symbols, but poorly for line symbols. About the only luck
I've had with scalable lines is using ellipse symbols for drawing stroked
lines (http://www.dnr.state.mn.us/fish_and_wildlife/trout_fishing/se_trout_init.html
is an example that uses scaled lines). Beyond that your best off using
multiple definitions of the layer valid at different scales and creating custom
line symbols for each. If anyone is aware of some good line scaling
algorithms let me know. Currently I'm working with the constraints of
the GD library.
There are two ways to label streets (or any lines for that matter)
using MapServer. I'll describe them using the more advanced control
found in version 3.3.
1) Labeling with text. MapServer can use text from a .dbf attribute to label streets
with names. The label angles can be fixed, pulled from an item or calculated
automatically. Rotated text is only available with truetype fonts. There are
several other parameters that allow you to fine tune label placement. All of these
are properties of a label object.
MINFEATURESIZE - given in pixels. Sets the smallest feature to be labeled. This
can also be set to AUTO which forces labels to be the same size (width) as the
segment they are labeling.
MINDISTANCE - given in pixels. Sets the minimum distance between duplicate pixels.
BUFFER - given in pixels. Reserves space around labels so text isn't so dense.
OFFSET - x and y values given in pixels. Label offset relative to a horizontal feature. Rotation
is taken into account.
In general labeling with text can accompany the defintion of the line drawing. However, you can
also use it as annotation drawn later in the map. Here's an example layer from the contour labeling
example at http://arachnid.dnr.state.mn.us/ms_test:
LAYER
NAME test
TYPE LINE
STATUS DEFAULT
DATA "../../data/contours"
LABELITEM "elev1"
SYMBOLSCALE 10000
LABELMAXSCALE 24000
CLASS
COLOR 255 0 0
LABEL
TYPE TRUETYPE
ANTIALIAS
FONT times
COLOR 0 0 0
BACKGROUNDCOLOR 255 255 230
SIZE 8
MINSIZE 4
MAXSIZE 8
ANGLE AUTO
POSITION CC
MINFEATURESIZE 100
END
END
END
2) Labeling with text and a marker symbol. This is generally used for placing things
like highway symbols and numbers. You must use annotation layers to do this. The
label point is generated from a line shapefile, but only the label point is actually rendered.
The key here is that you get your label size to match your marker size. For the stuff I've
done the markers are GIF images created to match a certain font size. Rotation most
likey is useless here (marker is NOT rotated). Also since the marker is centered on the
label point a label POSITION of CC should be used. The BUFFER, MINDISTANCE and
MINFEATURE size options all apply here. Here's a sample from our recreation compass
(http://www.dnr.state.mn.us/compass):
LAYER
NAME interstate
STATUS DEFAULT
DATA interstate
TYPE annotation
LABELITEM "road_name"
CLASS
COLOR 255 255 255
SYMBOL 1
LABEL
MINFEATURESIZE 50
MINDISTANCE 150
POSITION CC
SIZE TINY
COLOR 255 255 255
END
END
END # interstates
Annotation of this type is always drawn after the highway itself is drawn. I have a very small
collection of highway markers that I'll share if anybody wants them.
Steve
Stephen Lime
Internet Applications Analyst
Minnesota DNR
500 Lafayette Road
St. Paul, MN 55155
651-297-2937
>>> Nathan Carr <ncarr at guideguide.com> 11/23/99 07:49AM >>>
I am presently struggling to display arcs(roads in Lyon,Fr) with vector
symbol scaling
and label orientation. Could somebody describe the definitions that are
needed for this.
For example how can I define a railway or motorway in the line symbol
file and have this
line and label scaled at different levels.
I have tried various combinations of the defs in the map file
Also the MAXSCALE and MINSCALE definitions seem to break the display
Also should I make a layer up of points for displaying as an
'annotation' layer instead of labels.
Stephen Lime wrote:
This is similar to how annotation layers are handles, but the difference
is with annotation the marker
is drawn after any collision avoidance has been done so markers don't
overlap either.
--
Nathan Carr ncarr at guideguide.com
More information about the MapServer-users
mailing list