The centroid in the shpxy code is very basic and not a true centroid, it's just 
the mid-point of the bounding box of shape in question. It really wouldn't need 
to be this simple I think. The computation of that value is done on the raw 
shape and converted to image coordinates. I'm guessing it's the way the 
"centroid" is computed that is causing the problem?

Steve

-----Original Message-----
From: [email protected] 
[mailto:[email protected]] On Behalf Of Kent Richards
Sent: Sunday, March 31, 2013 1:13 AM
To: [email protected]
Subject: [mapserver-users] Need help with shpxy centriod in template file

When using the imagemap output in mapscript, I'm trying to get the center of 
the shapes using [shpxy precision=0 proj=image centroid=true].

Perhaps the first most obvious question is: am I misunderstanding what 
"centroid" means in this case?  I thought it meant the geometric center of the 
shape (of each shape, in this case).

I have an imagemap TEMPLATE file with this declaration:

> <!-- MapServer Template -->
> <area class="[shpxy precision=0 proj=image centroid=true xh="x" xf="-" yh="y" 
> sh="center-"]" shape="poly" coords="[shpxy precision=0 proj=image]" 
> href="http://my.url/mypage.cfm?ID=[state]"; title="[state]" alt="[state]">


The [shpxy centroid-true...] part returns "center-x367-y128" *for each shape* 
(the raw coords are 367, 128).

367, 128 is not in the center of the image, nor in the center of most of the 
shapes.

The other shpxy declaration in the template -- for the coords attribute -- 
seems to behave as expected.

Any ideas what I'm doing wrong, or is this a bug?

I know I can rig a convoluted means to return just the polygon points and 
calculate a center of sorts myself, but I'd like to just use the mapserver 
feature if it works.

Thanks,

Kent
_______________________________________________
mapserver-users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/mapserver-users


_______________________________________________
mapserver-users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/mapserver-users

Reply via email to