[Mapserver-users] Re: polygon label placement

Simon Greener Simon.Greener at forestrytas.com.au
Wed Mar 31 21:21:10 PST 2004


Blaise and other MapServer users,

We have some code written in Java, PL/SQL and even VBScript (within the
Manifold GIS)
that implements a centroid algorithm that generates a point that is
guaranteed
to fall within ANY polygon (even one with multiple parts and multiple
holes).

If anyone wants it, let me know which of the above languages and I will
send it to you.
We placed two versions of the algorithm onto Georeference.org, which is
the home of the 
Manifold System Users Group at:

http://www.georeference.org/Forums/boxx/download.asp?Cat=6

You do need Manifold to be able to read these versions.  We can provide
the VBScript as a text
file if you want.

This algorithm has been downloaded and used by lots of people in its
variety of languages and forms, so I don't 
see any issues in it being used within MapServer, however, while all we
(FT) would require is simple acknowledgement 
of the source of the algorithm as defined in the documentation header. 
I would need to talk to Geometry Pty 
Ltd (the originator of the algorithm) about releasing their rights
through an appropriate approved OSI license.  

regards
Simon

GIS - A Great Profession, and a lifelong Passion!
---------------------------------------------------------------------------------
Simon Greener           email: simon.greener at forestrytas.com.au
GIS Manager                 Ph: +61 3 6233 8143
Forestry Tasmania        Fax: +61 3 6233 8252 
79 Melville Street, Hobart, Tasmania,  7000,  Australia

>>> blaise <bpicinbono at worldonline.fr> Wednesday, 31 March, 2004
7:03:39 pm >>>
Dean Gadoury wrote :
-----
Every now and then I need to label polygons in MapServer and I'm often
unsatisfied with the resulting placement. Labeling is fine for points
and lines, but when it comes to polygons it can be unpredictable....
If I'm not mistaken the POSITION parameter will only place the label
relative to the point at which MapServer decides the label will go.
Depending on the label's POSITION its quite possible to have labels
that
fall completely outside a polygon. Is there a way to force labels to
be
within a polygon? Is there anything else I'm missing?
-----

I have seen some discussions some times ago in the list about having
the 
polygon labels inside the polygons.
First try the different label position parameters (vertical : up, 
center, down; horizontal : left, center, right). (i.e. : CC)
If you can do some mapserver scripting, you can put the labels wherever

you want (acoording you know where they have to go) :
-- have a separate label (or point) layer where you will draw the
labels 
for the polygons,
-- for each polygon, compute the X/Y coordinates of each vertex to find

the best point place for the label to be,
-- insert a label (or a labeled point) at this computed location on
your 
label layer.

For the computation, you can use the simple :
X = middle of Xmin - Xmax
Y = middle of Ymin - Ymax
But this won't give you good results if you deal with "inside-curved" 
polygons.
I think you can find a lot of doc for the computation of the "center"
of 
polygons.
You can have a look at a demo where you can precisly set the polygon 
labels with the simple computation above and by the means of two 
X-offset and Y-offset parameters :
http://webmaps.ouvaton.org    link: java-tools demo
(switch to html with the green java switch left to the scale bar (all 
editing and updating tools have not yet been developped in java), put 
the purple polygon layer in update mode and digitize new polygons or 
update the X/Y-offset of the existing ones, or update the vertex.)

'hope it'll help
Blaise
_______________________________________________
Mapserver-users mailing list
Mapserver-users at lists.gis.umn.edu 
http://lists.gis.umn.edu/mailman/listinfo/mapserver-users
This transmission is intended solely for the person
or organisation to whom it is addressed.
It is confidential and may contain legally privileged information.
If you have received this transmission in error, 
you may not use, copy or distribute it.
Please advise us by return e-mail or by phoning 61 3 62338203 
and immediately delete the transmission in its entirety.
We will meet your reasonable expenses of notifying us.
Despite our use of anti-virus software, Forestry Tasmania cannot guarantee 
that this transmission is virus-free.




More information about the MapServer-users mailing list