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

Stephen Woodbridge woodbri at swoodbridge.com
Fri Feb 3 11:22:15 EST 2012


Hi Jukka,

The labelcache could be extended to handle this, we already create and 
entry for each label, by name and by priority, if we priority was set to 
-1 or 02 for largest or smallest, and a size slot was added to the cache 
then all the rendering code would need to do isi compute the rendered 
(ie clipped) size in pixels or whatever. Database queries don't work if 
you are using shapefiles or other datasources. While postgres 
connections do support a !BOX! as Steve L mentioned not all databases 
have this coded. Size could be trivially computed as the number of 
pixels drawn for the polygon when it is rendered, although this might 
not be easily accessible given some of the newer rendering engines we 
support now.

-Steve

On 2/3/2012 10:03 AM, Rahkonen Jukka wrote:
> Hi,
>
> But still in this certain case the final select should sort by
> clipped size AND group by state name AND select the biggest feature
> from each group. Doesn't it feel easier to do with a database query
> and addional label layer? But how to pass the WMS BBOX for the
> database so it could do polygon intersections for getting the areas?
> And attributes should be transferred too so that clipped areas could
> be sorted by state name.
>
> -Jukka Rahkonen-
>
>> -----Alkuperäinen viesti----- Lähettäjä:
>> mapserver-users-bounces at lists.osgeo.org
>> [mailto:mapserver-users-bounces at lists.osgeo.org] Puolesta Stephen
>> Woodbridge Lähetetty: 3. helmikuuta 2012 16:44 Vastaanottaja:
>> mapserver-users at lists.osgeo.org Aihe: Re: [mapserver-users] RE: How
>> to label only largest displayed areas?
>>
>> Phil,
>>
>> In theory, it might be possible to do this by extending the
>> labelcache code to save the clipped area size of each polygon or a
>> clipped length of a line and then sort the labelcache items by size
>> and label them. MINDISTANCE could be applied to limit the number of
>> labels using the existing code. This behavior would need to be
>> triggered by a new LABEL keyword maybe like PRIORITY
>> [LARGEST|SMALLEST]
>>
>> If you want to write an enhancement ticket for this in the bug
>> tracker you can add my comment above, but I suspect that you would
>> have to fund the development of this or provide a patch.
>>
>> Best regards, -Steve W
>>
>> On 2/3/2012 8:59 AM, Anzel, Phil - NRCS, Fort Collins, CO wrote:
>>> Hi, Jukka and Steve,
>>>
>>> Thanks for your replies. Jukka is correct, I do not believe it
>>> is simple. Steve, your approach sorts all areas and then filters
>>> by those visible in the layer's extent. I'm looking for ranking
>>> by the clipped area. For example, if the current map and layer's
>>> extent shows the a small sliver of the mainland of California and
>>> a larger visible part of an island that is part of California,
>>> only
>> the island
>>> would be labeled, as its visible area is larger than that of the
>>> sliver.
>>>
>>> - Phil
>>>
>>> -----Original Message----- From: Rahkonen Jukka
>>> [mailto:Jukka.Rahkonen at mmmtike.fi] Sent: Thursday, February 02,
>>> 2012 4:01 PM To: Lime, Steve D (DNR); Anzel, Phil - NRCS, Fort
>>> Collins, CO; mapserver-users at lists.osgeo.org Subject: Re: How to
>>> label only largest displayed areas?
>>>
>>> Hi,
>>>
>>> I understood that meaning was to put exactly one label per
>>> state. Each state, even tiny ones, should be labeled. But one
>>> state should get only one label even if the map window is
>>> splitting the state polygon into two or more intersections. Those
>>> intersections may be bigger than the tiny state. Not extremely
>>> simple.
>>>
>>> -Jukka-
>>>
>>> ________________________________________ L Lime, Steve D (DNR)
>>> wrote:
>>>
>>>> I'd do this by sorting features based on area (ascending
>>>> order). This would draw the smallest polygons first, but would
>>>> put the labels for the shapes with the largest area into the
>>>> label cache last (where they would be placed and drawn first).
>>>> I've done this with labeling lakes and it works fine.
>>>
>>> Steve
>>>
>>> -----Original Message----- From:
>>> mapserver-users-bounces at lists.osgeo.org
>>> [mailto:mapserver-users-bounces at lists.osgeo.org] On Behalf Of
>>> Anzel, Phil - NRCS, Fort Collins, CO Sent: Thursday, February 02,
>>> 2012 1:43 PM To: mapserver-users at lists.osgeo.org Cc: Anzel, Phil
>>> - NRCS, Fort Collins, CO Subject: [mapserver-users] How to label
>>> only largest displayed areas?
>>>
>>> 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.
>>>
>>> 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
>>>
>>>
>>> _______________________________________________ mapserver-users
>>> mailing list mapserver-users at lists.osgeo.org
>>> http://lists.osgeo.org/mailman/listinfo/mapserver-users
>>>
>>>
>>> _______________________________________________ mapserver-users
>>> mailing list mapserver-users at lists.osgeo.org
>>> http://lists.osgeo.org/mailman/listinfo/mapserver-users
>>
>> _______________________________________________ mapserver-users
>> mailing list mapserver-users at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/mapserver-users
>> _______________________________________________
> 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