Add ol.geom.MultiLineString#getLineString

This commit is contained in:
Tom Payne
2014-03-10 16:13:06 +01:00
parent 669f21ca29
commit 7ee4fb8a2e
3 changed files with 28 additions and 0 deletions

View File

@@ -2,6 +2,7 @@
@exportProperty ol.geom.MultiLineString.prototype.clone
@exportProperty ol.geom.MultiLineString.prototype.getCoordinateAtM
@exportProperty ol.geom.MultiLineString.prototype.getCoordinates
@exportProperty ol.geom.MultiLineString.prototype.getLineString
@exportProperty ol.geom.MultiLineString.prototype.getLineStrings
@exportProperty ol.geom.MultiLineString.prototype.getType
@exportProperty ol.geom.MultiLineString.prototype.setCoordinates

View File

@@ -131,6 +131,22 @@ ol.geom.MultiLineString.prototype.getEnds = function() {
};
/**
* @param {number} index Index.
* @return {ol.geom.LineString} LineString.
*/
ol.geom.MultiLineString.prototype.getLineString = function(index) {
goog.asserts.assert(0 <= index && index < this.ends_.length);
if (index < 0 || this.ends_.length <= index) {
return null;
}
var lineString = new ol.geom.LineString(null);
lineString.setFlatCoordinates(this.layout, this.flatCoordinates.slice(
index === 0 ? 0 : this.ends_[index - 1], this.ends_[index]));
return lineString;
};
/**
* @return {Array.<ol.geom.LineString>} LineStrings.
* @todo stability experimental