A centroid method for LineStrings
This commit is contained in:
@@ -63,3 +63,14 @@ ol.geom.LineString.prototype.addVertex = function(vertex, index) {
|
|||||||
ol.geom.LineString.prototype.removeVertex = function(vertex) {
|
ol.geom.LineString.prototype.removeVertex = function(vertex) {
|
||||||
goog.array.remove(this.vertices_, vertex);
|
goog.array.remove(this.vertices_, vertex);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compute the centroid for this linestring.
|
||||||
|
*
|
||||||
|
* @returns {ol.geom.Point} The centroid of the linestring.
|
||||||
|
*/
|
||||||
|
ol.geom.LineString.prototype.getCentroid = function() {
|
||||||
|
var vertices = this.getVertices(),
|
||||||
|
collection = new ol.geom.Collection(vertices);
|
||||||
|
return collection.getCentroid();
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user