[OpenLayers-Users] Re: getCentroid method influenced by floating-point math

Andreas Hocevar ahocevar at opengeo.org
Mon May 16 03:49:41 EDT 2011


Hi,

if you create a ticket with a patch implementing your solution, one of
the OL developers can review it and decide whether this approach is
reasonable or not.

An alternative solution to your problem would be to use
getCenterLonLat() on the bounding box of the feature's geometry go get
an appropriate anchor location.

Thanks for your efforts!
Andreas.

On Mon, May 16, 2011 at 2:22 AM, srweal <srweal at gmail.com> wrote:
> My only idea for improving this calculation was to find the minX  and minY
> for the bounding box of the geometry, then shift the entire geometry back to
> an origin of 0,0.
>
> This would lead to much smaller values and this resolve some of the
> calculation issues. Once the centroid is calculated, I can then just add
> back the bounding box corner coordinate to get the final centroid.
>
> Does this sound reasonable to people?
>
> Also, if any of the awesome OL developers are reading, is this issue of
> concern to you guys and will you be doing anything about it?
>
> Steve
>
> --
> View this message in context: http://osgeo-org.1803224.n2.nabble.com/getCentroid-method-influenced-by-floating-point-math-tp6346365p6366982.html
> Sent from the OpenLayers Users mailing list archive at Nabble.com.
> _______________________________________________
> Users mailing list
> Users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-users
>



-- 
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.


More information about the Users mailing list