From 3d35ce75e4e0607caaaf09c48ddf1365a501fba4 Mon Sep 17 00:00:00 2001 From: Tom Payne Date: Sun, 1 Dec 2013 17:48:05 +0100 Subject: [PATCH] Add ol.geom.Polygon#getInteriorPoint --- src/ol/geom/polygon.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/ol/geom/polygon.js b/src/ol/geom/polygon.js index a227b986c4..b361fd7f34 100644 --- a/src/ol/geom/polygon.js +++ b/src/ol/geom/polygon.js @@ -54,6 +54,17 @@ ol.geom.Polygon.prototype.getEnds = function() { }; +/** + * @return {ol.Coordinate} Interior point. + */ +ol.geom.Polygon.prototype.getInteriorPoint = function() { + var extent = this.getExtent(); + var y = (extent[1] + extent[3]) / 2; + return ol.geom.flat.linearRingsGetInteriorPoint( + this.flatCoordinates, 0, this.ends_, this.stride, y); +}; + + /** * @return {Array.} Linear rings. */