Add ol.geom.Polygon#getLinearRing

This commit is contained in:
Tom Payne
2014-03-10 15:40:05 +01:00
parent 03911e6c6b
commit c2d4ffaba1
3 changed files with 22 additions and 0 deletions

View File

@@ -178,6 +178,22 @@ ol.geom.Polygon.prototype.getInteriorPoint = function() {
};
/**
* @param {number} index Index.
* @return {ol.geom.LinearRing} Linear ring.
*/
ol.geom.Polygon.prototype.getLinearRing = function(index) {
goog.asserts.assert(0 <= index && index < this.ends_.length);
if (index < 0 || this.ends_.length <= index) {
return null;
}
var linearRing = new ol.geom.LinearRing(null);
linearRing.setFlatCoordinates(this.layout, this.flatCoordinates.slice(
index === 0 ? 0 : this.ends_[index - 1], this.ends_[index]));
return linearRing;
};
/**
* @return {Array.<ol.geom.LinearRing>} Linear rings.
* @todo stability experimental