diff --git a/src/ol/geom/multilinestring.exports b/src/ol/geom/multilinestring.exports index 23b3e5987e..aa3eb024a0 100644 --- a/src/ol/geom/multilinestring.exports +++ b/src/ol/geom/multilinestring.exports @@ -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 diff --git a/src/ol/geom/multilinestring.js b/src/ol/geom/multilinestring.js index ee773a1c51..4c825db9a3 100644 --- a/src/ol/geom/multilinestring.js +++ b/src/ol/geom/multilinestring.js @@ -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.