Hi Numenor, ST_PointOnSurface helped a lot. It first killed postgres because I tried using it directly in the SQL for ogcserver. I tried adding a new field "point_on_surface" and updating it. It works flawlessly!
Still, this is not as optimal as a good label placement algorithm, but will work meanwhile... And by the way, the polygon inside polygon ended being an internal polygon sharing limits with the bigger one, but NOT overlapping. So this is "solved" too. Thank you very much for your help! > -----Mensaje original----- > De: numenor [mailto:[email protected]] > Enviado el: viernes, 28 de mayo de 2010 14:55 > Para: Clos Crespo, Manel > CC: [email protected] > Asunto: Re: [Mapnik-users] TextSymbolizer label placement for polygon > > Hi Manel, > > On Fri, 28 May 2010 14:21:08 +0200, <[email protected]> wrote: > > I've two problems with label placement: > > > > 1) When the centroid is outside of the polygon the label > will appear to > be > > labeling just another polygon (confusing). > > Maybe the SQL extension function 'ST_PointOnSurface' can help you (at > least as a workaround), if you use PostGIS as data source. For a given > surface, this function returns a point which is guaranteed to > lie on the > surface. It does not guarantee any more, but with PostGIS, for me for > convex shapes the labels appear similarly placed as when > using ST_Centroid > (or mapnik's algorithm), more or less in the middle. > > > 2) When a polygon is inside a bigger one, and they both > have a similar > > centroid, both labels will end in the smaller polygon (really > confusing), > > and the bigger one will appear to have no label at all > (more confusion). > > Is this problem solvable at all, in general? What if the > outer polygon is > completely covered by smaller polygons? > > If this can happen, maybe a better solution would be to label > the border > of the polygon, as is often done for borders between administrative > entities. > > If you know which smaller polygons lie inside the bigger one, > you could > subtract their area from the bigger one, and then use > ST_PointOnSurface on > the result to get the point for placement of the label. This might of > course be computationally expensive ... > > Hope this helps, > -- > Holger Schöner - [email protected] > _______________________________________________ Mapnik-users mailing list [email protected] https://lists.berlios.de/mailman/listinfo/mapnik-users

