Several years ago, I wrote some Python code to roughly georeference air photos. 
 As part of that, I needed to come up with the best approximation of the 
heading of the airplane.

What worked pretty well was to do a really simple line fitting based on the 
points.  My samples were points from an airplane that was attempting to fly in 
a straight line, with vertices generated by a camera taking pictures at regular 
intervals, so that helped.

I simply split the vertices of the line into three groups by dividing the total 
number of points by 3.  I averaged the x and y values in each group and then 
created a line from the average coord from group1 to the average coord from 
group3.

Street data will likely be more variable (curved), but you may want to explore 
something like this.  Of course, you would likely want to calculate these label 
angles using pre-processing to speed up rendering time.

David.



From: mapserver-users-boun...@lists.osgeo.org 
[mailto:mapserver-users-boun...@lists.osgeo.org] On Behalf Of Jan Hartmann
Sent: Tuesday, February 21, 2012 11:18 AM
To: Fawcett, David (MPCA)
Cc: mapserver-users@lists.osgeo.org
Subject: Re: [mapserver-users] Aligning labels within a polygon

Going a step further:

st_longestline(st_collect(the_geom),st_collect(the_geom))

gives the longest line segment that can be drawn within the cluster of street 
address points. Works for non-curved streets. I'm still looking for a more 
intelligent way to thin out a polygon to a (multi)line.

Jan

On 02/21/2012 05:27 PM, Fawcett, David (MPCA) wrote:
If you are storing the data in PostGIS, you could possibly take advantage of 
ST_Azimuth().  http://www.postgis.org/docs/ST_Azimuth.html

It takes two point objects as the args, but you could potentially use the start 
and end points of your linestring.

David.

From: 
mapserver-users-boun...@lists.osgeo.org<mailto:mapserver-users-boun...@lists.osgeo.org>
 [mailto:mapserver-users-boun...@lists.osgeo.org] On Behalf Of Jan Hartmann
Sent: Tuesday, February 21, 2012 10:23 AM
To: mapserver-users@lists.osgeo.org<mailto:mapserver-users@lists.osgeo.org>
Subject: [mapserver-users] Aligning labels within a polygon

Hi,

I'm inputting lots of street address points in PostGIS, and try to generate 
labels for the streets. The convex hull of the points of a street approximate 
the course of the street, and I would like to position the streetname in the 
middle of the convex hull polygon, aligned to its dominant angle (the polygons 
are generally quite narrow). Is there a way of doing this with MapServer? 
Perhaps by thinning out the polygon to a line, for then I can use "angle 
follow".

Jan
_______________________________________________
mapserver-users mailing list
mapserver-users@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapserver-users

Reply via email to