From 73e07df54407d7ed2781f7aa2a909a47be038aaf Mon Sep 17 00:00:00 2001 From: Marc Jansen Date: Fri, 22 Jun 2012 16:24:01 +0200 Subject: [PATCH] Give geometrues a centroid method. --- src/api/geom/collection.js | 2 +- src/api/geom/geometry.js | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/api/geom/collection.js b/src/api/geom/collection.js index e8269676a9..9a93ead0c4 100644 --- a/src/api/geom/collection.js +++ b/src/api/geom/collection.js @@ -128,6 +128,6 @@ ol.geom.Collection.prototype.remove = function(components){ this.removeComponent(c); return true; }, this); - + return this; }; diff --git a/src/api/geom/geometry.js b/src/api/geom/geometry.js index 3e12f9f0e7..5d8b9d09b9 100644 --- a/src/api/geom/geometry.js +++ b/src/api/geom/geometry.js @@ -24,3 +24,12 @@ ol.geom.Geometry.prototype.bounds = function(opt_arg) { return this.getBounds(); } }; + +/** + * Returns the centroid of the geometry. + * + * @returns {ol.geom.Point} The centroid of the geometry. + */ +ol.geom.Geometry.prototype.centroid = function() { + return this.getCentroid(); +}; \ No newline at end of file