[mapserver-users] Need help with shpxy centriod in template file

Kent Richards info at kentrichards.net
Sat Mar 30 23:12:53 PDT 2013


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


More information about the mapserver-users mailing list