Hi Akos,

Before all attention goes towards the other thread you started, I would like to 
address this question separately though suggestions have already been provided 
in the other thread. When others come to the mailing list archives at a future 
time, they then don't have to search too far for pointers either, hopefully.

What you are experiencing is that for polygons, the anchor point used for 
labelling is the centroid of the visible portion of the polygon.
So for each small tile image that covers your polygon, a new anchor point is 
computed and the label is drawn.



One course of action to work around this has already been suggested by Al Vigil:



> One way to get around this duplication problem when labeling polygons is to 

> create a point file of polygon center points and style the points so they

> are transparent, but are labeled with the name of the polygon.

Thus, there's only one spot where your area label will be drawn instead of 
having it drawn on each tile that covers the geographic area. The downside of 
this approach can be, that the very spot you defined has already been taken by 
another label that has higher priority, for example by a country name or region 
name. You could then use a desktop GIS to load your PostGIS layer and manually 
reposition these points.

The other course of action has already been suggested by David Winslow:

> GeoWebCache can help by generating oversized tiles and splitting them up into 
> 256px square tiles for actual serving.

Sticking with your current SLD, GeoWebCache requests are larger image from 
GeoServer, so there will most likely be less images that cover the geographic 
area. Thus, the label with have less repetition anyway. Also, as the anchor 
point used for labelling is the centroid of the visible portion of the polygon 
in the larger image there is a slight irregularity introduced in the anchor 
point calculation. Since tile borders hardly ever coincide with geographic 
borders, there is less chance your label anchor points from different layers 
(town layer, region layer, country layer) will overlap.

All in all, I suggest to use a tile rendering engine (GeoWebCache, MapProxy, 
TileCache) anyway, instead of requesting small image from GeoServer and have 
the tile rendering engine do the tile slicing afterwards. You will have send 
fewer requests to GeoServer (1 large image instead of multiple small images), 
so this speeds up the overall tile cache creation time. In a second stage you 
have to try for your self whether you do a precomputation of the label anchor 
points or have GeoServer compute the anchor point at the centroid of the 
visible portion of the polygon on the fly. Also this trade-off can vary across 
zoom levels.

Kind regards,

Edward

> Date: Tue, 14 Aug 2012 20:49:06 +0200
> From: [email protected]
> To: [email protected]
> Subject: [Geoserver-users] polygon label repeated for each tile
> 
> Hi,
> 
> I'm trying to use polygon labeling with SLD to label cities using an OSM
> PostGIS database. I tried to use the 'name' attribute of admin_level = 8
> administrative boundaries from the OSM database.
> 
> this seems to work fine, but there is a problem. as geoserver generates
> the various tiles for serving via WMS, the label is generated for each
> tile that the polygon is shown on. for cities that span multiple tiles
> on a certain zoom level, this means that the name of the city is
> repeated as many times as there are tiles spanning the polygon.
> 
> is there a way to prevent this from happening?
> 
> best regards,
> 
> 
> Akos
> 
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and 
> threat landscape has changed and how IT managers can respond. Discussions 
> will include endpoint security, mobile security and the latest in malware 
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> Geoserver-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/geoserver-users
                                          
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Geoserver-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Reply via email to