[OpenLayers-Users] Vector Feature Label and Geometry.getCentroid()

B. Heath Robinson heath at midnighthour.org
Thu Jun 23 18:16:47 EDT 2011


I am using a vector layer with text features on Polygon geometries.  Relatively often the text label is drawn pretty far off the center of the polygon.  My polygon is basically a rectangle with a rounded corner.  Below is the WKT of it.  When I do a getCentroid in OpenLayers it is different than if I do it in PostGIS.  I think if the label was drawn at the PostGIS centroid it would be right.  My site allows measurement, so I also tried getting the centroid of a geometry I traced with the rubberband tool.  It also returned a Centroid more like I expected.  

Many of the labels also appear to be correct.  Am I missing something?  Does it have to do with the geometry being Multipolygon?  Any insight would be appreciated.

Geometry
MULTIPOLYGON(((-10842755.069337 3645931.096789,-10842790.775979 3645953.496622,-10842772.182218 3645984.113569,-10842743.492303 3645965.972283,-10842742.28656 3645964.787145,-10842741.293463 3645963.414273,-10842740.538336 3645961.898144,-10842740.044376 3645960.275967,-10842739.827709 3645958.592826,-10842739.889943 3645956.896071,-10842740.232706 3645955.23634,-10842740.843507 3645953.655201,-10842755.069337 3645931.096789)))

OpenLayers Centroid:
id: "OpenLayers.Geometry.Point_492"
x: -10842792.853788493
y: 3645967.2444699085

PostGIS Centroid
"POINT(-10842763.8558177 3645957.49366021)"


Rubberband Tool Geometry:
POLYGON((-10842772.247212 3645983.9949693,-10842790.759305 3645953.5395909,-10842754.929448 3645931.1459303,-10842740.597505 3645955.0325016,-10842739.701759 3645957.7197409,-10842739.701759 3645961.3027266,-10842740.298923 3645962.7956373,-10842743.284744 3645965.7814587,-10842745.374819 3645967.2743694,-10842772.247212 3645983.9949693))

Rubberband Tool Centroid:
id: "OpenLayers.Geometry.Point_689"
x: -10842779.12432854
y: 3645962.747894722

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20110623/56375eaa/attachment.html


More information about the Users mailing list