[Mapserver-dev] Labels that follow streets with bends

woodbri at swoodbridge.com woodbri at swoodbridge.com
Sun Feb 9 11:56:59 EST 2003


Hi all,

There has been some some discussion of have street labels follow 
bends in the streets in the past. I have decided to take a pass at 
implementing a routine to do this.

Here are my initial thoughts on this. I am looking for comments and 
feedback.

My plan is to implement a function like this:

bchar *TextPath(
    gdImagePtr im,
    int *brect,
    int fg,
    char *fontname,
    double ptsize,
    int npts,
    int *X,
    int *Y,
    char *string,
    int flags);

most of these args are identical to the gdImageStingFT() call and 
this function would work similarly to it if you pass it NULL for im. 
The polyline would be passed in using the npts, X, Y args; and flags 
I envision would be used to control the behavior of the function with 
respect to
NO_PARTIAL  - fail is polyline is too short to render the whole 
string
TRUNCATE  - trucate the string if it is too long
EXTEND - virtually extend the last segment to write the whole string
REVERSE - the direction of the polyline
AUTO - figure out the best placement of the text so it is most 
readable
ABOVE|BELOW|CENTER the text on the polyline

My first pass at this will be straight forward if not brute force. I 
will take each char in the string and see if I have enough room to 
place it on the segment, if not place it on the next segment until I 
run out of chars or segments. I will also probably ignore most of the 
flags and implement it as flags = EXTEND|AUTO; I plan to write the 
function to just call gdImageStringFTEx() to do the work, a later 
optimization might be to clone the gdImageStringFTEx() source so I 
can make some optimization.

This implementation has the advantage for me that I can dev and test 
in a simplified GD only environment. On the down side real 
performance will not be as easily tested until it is integrated into 
mapserver.

If I implement as described above will it be easy to integrate into 
mapserver? Issues? concerns?

-Steve W.





More information about the mapserver-dev mailing list