[mapserver-users] How to label only largest displayed areas?

Stephen Woodbridge woodbri at swoodbridge.com
Thu Feb 2 15:19:19 EST 2012


On 2/2/2012 2:43 PM, Anzel, Phil - NRCS, Fort Collins, CO wrote:
> Hi, All,
>
> How can I label only the largest displayed areas within an extent?
> For example, if I'm labeling states of the United States and my
> extent covers a small region around the Maine, New Hampshire and
> Massachusetts junction, I only want a single label for each state,
> chosen by the largest displayed area (within the current map extent)
> in each state.

Hi Phil,

I'm not sure I understand what you need here. Mapserver currently 
displays one label per polygon based on the visible extents of that 
polygon. If your state is represented by a single record with a 
multipolygon like the state and its coastal islands, then I suspect that 
it will label the first polygon in the multipolygon object. In the cases 
where you have multiple records in your dataset one for the state and 
additional polygons for the islands, then all of these are added to the 
labelcache and the last one in the labelcache is labeled first if the 
label does not collide. So in this case you could sort your data by 
state and area increasing in size so you largest is loaded last and 
labeled first.

You can also control the number of labels using MINDISTANCE <dist> so 
the same label in a layer is not presented within <dist> units of 
another with the same name.

Do you need more than this?
Are you trying to place the label in the biggest open space? (this we 
can not do because there is no easy algorithm for this).

-Steve W

> I'm using spatial data stored in Microsoft's SQL Server 2008.
>
> I've created an enhancement request ticket (#4173: Define a current
> layer extent's WKT string for use in Data statement) as one possible
> approach, but this approach requires a change to MapServer.
>
> Is there a better way?
>
> Thanks.
>
> - Phil Anzel Vistronix Inc for USDA/NRCS/ITC
>
> This electronic message contains information generated by the USDA
> solely for the intended recipients.  Any unauthorized interception of
> this message or the use or disclosure of the information it contains
> may violate the law and subject the violator to civil or criminal
> penalties.  If you believe you have received this message in error,
> please notify the sender and delete the email immediately.
>
>
> _______________________________________________ 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