[Mapserverdev] Label centroid alog
John Newton
john_mapserver at hotmail.com
Mon May 5 17:06:26 EDT 2003
The labeling centroid algorithm has sometime given me incorrect results and
I believe I see the reason why. The point1 and point2 pointers can
sometimes point to the same object, thereby rendering incorrect length
calculations (namely zero length).
Here is my suggested change to the code. Basically I remove the use of
point1 and point2 for determining length and max_len, and get the length
using the diff in x, not length(), since the y values are equal.
john
 \mapserver\mapserver3.7dev\mapprimitive.c 20030226
12:18:22.000000000 0800
+++ mapprimitive.c 20030505 13:41:44.000000000 0700
@@ 950,16 +923,13 @@
}
}
} while(wrong_order);

+
/* Great, now find longest span */
 point1>y = point2>y = y;
 for(i=0; i < nfound; i += 2) {
 point1>x = xintersect[i];
 point2>x = xintersect[i+1];
 len = length(*point1, *point2);
+ for(i=0; i < nfound; i +=2) {
+ len = fabs(xintersect[i]  xintersect[i+1]);
if(len > max_len) {
max_len = len;
 lp>x = (point1>x + point2>x)/2;
+ lp>x = (xintersect[i] + xintersect[i+1])/2;
lp>y = y;
}
}
More information about the mapserverdev
mailing list