[mapserver-users] state label placement and priority labelling
Stephen Woodbridge
woodbri at swoodbridge.com
Sun Jan 6 05:21:06 PST 2002
Walt,
Steve probably has a better suggestion, but one way that comes to mind
if you and absolute control of positioning is to create a point shape
file with a record for each state and its name in the dbf record, then
use this as you annotation file. You could probably right a little perl
to calculate the centroid of the extents of each state as a starting
point then tweak the values of you don't like where they fall.
I remember some email discussing the priority of labeling layers so you
might check the archives. Again if you want priority of city labels by
population or some other criteria you probably need to make a shape file
sorted by that criteria and use it for your annotation.
-Steve W.
Walt Lin wrote:
>
> Steve and others-- i'm using this same US states layer
> (nationalatlas.gov). Is there any other way to control the position of
> labels besides the auto|ll|cc... ? None of them produce satisfactory
> results for labelling the states-- funky shaped states screw up the
> label placement, and states like Virginia which have two or more
> disjoint polygons really screw up the placement (I can't get the
> Virginia label even close to the "middle" of the state).
>
> Also, can someone point me to the "correct" way to prioritize labeling
> by some criterion? For example, suppose I want to label the most
> populous cities first, so Boston "wins" over Brookline when they
> conflict, or Massachusetts gets labelled before Rhode Island in a
> conflict because it is bigger?
>
> Thanks.
>
> Walt
>
> On Wed, Oct 03, 2001 at 08:29:44AM -0500, Stephen Lime wrote:
> > I downloaded the layer myself and will take a look. A couple of things
> > off the top of my head. MINDISTANCE is given in pixels and only deals
> > with duplicates. POSITION AUTO uses 8 label points that revolve around
> > the label point. If you want to center directly upon the label point choose
> > CC explictly. I think there may be enough info in the label cache to add
> > CC back into the AUTO placement if no marker is being used, I'll file that
> > as a bug in bugzilla. Finally, polygon label points are generated as follows:
> >
> > - use midpoint of bbox if that point falls in the polygon
> > - compute a centroid based on sampling the feature
> >
> > For odd shaped states (like Mass. or Fla.) the position may not be optimal.
> >
> > Steve
> >
> > John R Frank wrote:
> >
> > > Hi
> > >
> > > I'm trying to display a US state boundaries layer that I downloaded from
> > > nationalatlas.gov. The labels show up many times. Even if I crank up the
> > > label::mindistance and label::buffer it still shows a few and they are
> > > pushed away from the center of the state!
> > >
> > > When I look at this layer in ArcExplorer, it looks _perfect_. The state
> > > labels appear once, centered in each state.
> > >
> > > How can we achieve this with mapserver? (we love mapserver). My states
> > > layer is below.
> > >
> > > John
> > >
> > > LAYER
> > > NAME states
> > > TYPE POLYGON
> > > # TOLERANCE 3
> > > MAXSCALE 100000000
> > > MINSCALE 10000
> > > LABELMAXSCALE 100000000
> > > LABELMINSCALE 500000
> > > LABELITEM "state"
> > > CLASS
> > > # COLOR 190 255 190
> > > BACKGROUNDCOLOR 255 255 255
> > > OUTLINECOLOR 150 150 150
> > > LABEL
> > > # ANGLE AUTO
> > > COLOR 230 0 0
> > > # OUTLINECOLOR 0 0 0
> > > TYPE TRUETYPE
> > > FONT arial
> > > SIZE 9
> > > POSITION AUTO
> > > BUFFER 7
> > > # WRAP " "
> > > MINDISTANCE 300000000000
> > > END
> > > END
> > > END
> > >
> > > ~
> >
> >
> >
More information about the MapServer-users
mailing list