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

Lime, Steve D (MNIT) Steve.Lime at state.mn.us
Fri Apr 12 09:47:31 PDT 2013


Regardless of how the computation is done you shouldn't get everything in the same spot. That tells me the conversion from map to image coordinates isn't working right. You can only use the "image" projection if enough parameters about the extent and size of the corresponding map/image are known. What do your queries look like?

Steve

-----Original Message-----
From: Kent Richards [mailto:info at kentrichards.net] 
Sent: Friday, April 12, 2013 11:24 AM
To: mapserver-users at lists.osgeo.org; Lime, Steve D (MNIT)
Subject: Re: [mapserver-users] Need help with shpxy centriod in template file

Forgot to cc the list...

Thanks Steve,

The most visible problem is that the centroid values I'm getting are the same for all shapes in the output.  It's a United States map, and for all states in the result set, the "centroid" comes out to the same point, somewhere around Wyoming.

The rest of the output is expected:  a set of vertices for each shape that correctly renders the imagemap.

But, since the centroid is supposed to be a simple center of the bounding box, it probably won't do what I need anyway.

Thanks,

Kent


On Apr 12, 2013, at 8:40 AM, Lime, Steve D (MNIT) wrote:

> 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: mapserver-users-bounces at lists.osgeo.org [mailto:mapserver-users-bounces at lists.osgeo.org] On Behalf Of Kent Richards
> Sent: Sunday, March 31, 2013 1:13 AM
> To: mapserver-users at lists.osgeo.org
> 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
> mapserver-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapserver-users
> 
> 





More information about the mapserver-users mailing list