[mapserver-users] Still impossible to force labels inside their polygons?
Brent Fraser
bfraser at geoanalytic.com
Wed Dec 12 10:49:00 PST 2012
Mark,
Sounds ok (it took me a while to realize you meant the BBOX of the
polygons, not the label!).
My world of sophisticated labeling would include some way of having
the mapfile specify the order of applying the rules, but currently there
is no way to do procedural things in a mapfile, just set parameters. On
second thought, I guess the CLASS list evaluates things in a particular
order; perhaps the same technique could be used in label placement:
LABEL
CHECKLABELFIT true # Check BBOX of label against polygon outline
(not just BBOX of polygon)
LOCATION# --- first label attempt (Case A,B) ---
POSITION cc,ul,uc,ur
END
LOCATION# --- next label attempt (Case C) ---
ANGLE auto
END
LOCATION# --- next label attempt (Case D) ---
LEADER
:
END
END
END
And I'd like to factor in preferring labeling in areas of no other
linework, but that may take some thought...
Best Regards,
Brent Fraser
On 12/12/2012 10:40 AM, Mark Volz wrote:
> Brent,
>
> In the long run when servers get faster, more layers get cached, and users expect better cartography, I think that it would be worthwhile to implement a way of trying multiple positions. The CHECKLABELFIT keyword is mostly to verify that a label falls inside the actual polygon as opposed to the BBOX, which would help avoid ambiguity on labels. I don't think CHECKLABELFIT would be mutually exclusive to any method of trying to find different label positions.
>
> In your comments you have the term "If it doesn't fit." CHECKLABELFIT could be used to specify if we consider if the label fits according to the BBOX or the polygon. For example:
>
> A: Calculate the default location of the label in the polygon. If CHECKLABELFIT is on: only place the label if it falls inside the polygon. If CHECKLABELFIT is off: only place the label if it fits in the BBOX
>
> If the label could not be placed, and TRYALTERNATELABELS is on:
> B: Try different positions in the polygon UL,UC,UR, etc. If CHECKLABELFIT is on: only place the label if it falls inside the polygon. If CHECKLABELFIT is off: only place the label if it fits in the BBOX
>
> If a label still could not be placed:
> C: Rotate the label. If CHECKLABELFIT is on: only place the label if it falls inside the polygon. If CHECKLABELFIT is off: only place the label if it fits in the BBOX.
>
> If a label could not be placed after rotating the label
> D. Try using a leader line. / Place Polygon annotation outside polygon.
>
>
> Use situations:
> CHECKLABELFIT=FALSE, TRYALTERNATELABELS=FALSE: label the map as fast as possible.
> CHECKLABELFIT=TRUE, TRYALTERNATELABELS=FALSE: make sure labels fit in their polygons, but don't worry about labeling everything.
> CHECKLABELFIT=FALSE, TRYALTERNATELABELS=TRUE: try to label as many items as possible, use the BBOX as label ambiguity is okay.
> CHECKLABELFIT=TRUE, TRYALTERNATELABELS=TRUE: try to label as many items as possible, and make sure that the labels fit inside their polygons. (slowest)
>
> Thanks
>
>
> Mark Volz
> GIS Specialist
>
>
>> -----Original Message-----
>> From: Brent Fraser [mailto:bfraser at geoanalytic.com]
>> Sent: Wednesday, December 12, 2012 10:01 AM
>> To: Mark Volz
>> Cc: mapserver-users at lists.osgeo.org
>> Subject: Re: [mapserver-users] Still impossible to force labels inside their
>> polygons?
>>
>> Mark,
>>
>> A simple solution sounds good as long as it can fit into a strategic plan (I
>> don't really have a plan for improving the polygon labeling, just a desire!).
>>
>> On major releases of Mapserver I try to push the limits of its cartography
>> by comparing its output to hand-composed pdfs of Canadian Topo maps [1]
>> (not fair I know). One of the stumbling blocks I've run into is the labeling of
>> polygons and I've speculated on the use of "rules-based" labeling. Here's my
>> list of rules from a comment on RFC
>> 77 [2].
>>
>> "Allow for alternate label positions. While this is likely beyond the scope of
>> RFC 77, perhaps it could be taken into account in design and implementation
>> for later addition. Basically I'd like more flexibility (rule-based?) in labeling
>> polygons:
>>
>> A. Try to place label in polygon. If it doesn't fit:
>> B. Rotate label to fit inside a polygon. If it doesn't fit:
>> C. Place polygon annotation outside polygon"
>>
>> I wonder if adding keywords like CHECKLABELFIT (and other new ones) is the
>> way to go or use PROCESSING directives instead?
>>
>> [1]
>> http://geogratis.cgdi.gc.ca/geogratis/en/product/search.do?id=A6291EF5-
>> F3FC-A29F-3162-DE4DB194FD38
>> [2] http://lists.osgeo.org/pipermail/mapserver-dev/2011-
>> December/011773.html
>>
>> Best Regards,
>> Brent Fraser
>>
>> On 12/11/2012 7:33 AM, Mark Volz wrote:
>>> Hello,
>>>
>>> Earlier in the year I had asked about forcing labels in their polygons. And
>> another person mentioned the issue in September. At the time Steve W was
>> concerned about complexity and performance in placing labels. I was
>> thinking lately that maybe this topic could be revisited. However, this time
>> around instead of dealing with "optimal" label placement within a polygon,
>> maybe something much simpler would be better. For example:
>>> keyword : CHECKLABELFIT
>>> -FALSE: Use the BBOX for labeling. This is the current behavior, which is
>> fast and should remain as the default.
>>> -TRUE: Once the label is placed using the current label placement engine,
>> check to make sure the BBOX of label falls within the actual boundary of the
>> polygon, if it does not then skip the label.
>>> This keyword should not be confused with any algorithm that places labels
>> in an optimal position within the polygon such as one that tries to place a
>> label horizontally, then strait if it doesn't fit. Last, since check label fit is
>> optional, this keyword should only impact performance on layers that a user
>> wants to verify that the label is correctly placed. It would never be needed
>> for a layer where the polygons are rectangular such as sections, or
>> townships. However it may be critical on soil layers.
>>
>>> Just some thoughts
>>>
>>> Thanks
>>>
>>> Reference
>>> http://osgeo-org.1560.n6.nabble.com/force-labels-to-fit-in-polygons-td
>>> 4549296.html
>>> http://comments.gmane.org/gmane.comp.gis.mapserver.user/49333
>>>
>>>
>>> Mark Volz
>>> GIS Specialist
>>>
>>>
>>> _______________________________________________
>>> mapserver-users mailing list
>>> mapserver-users at lists.osgeo.org
>>> http://lists.osgeo.org/mailman/listinfo/mapserver-users
>>>
>
More information about the MapServer-users
mailing list