Add ol.geom.MultiLineString#getCoordinateAtM

This commit is contained in:
Tom Payne
2014-03-02 12:11:43 +01:00
parent 296c83fa36
commit 8125b4a847
3 changed files with 140 additions and 0 deletions

View File

@@ -1,5 +1,6 @@
@exportSymbol ol.geom.MultiLineString
@exportProperty ol.geom.MultiLineString.prototype.clone
@exportProperty ol.geom.MultiLineString.prototype.getCoordinateAtM
@exportProperty ol.geom.MultiLineString.prototype.getCoordinates
@exportProperty ol.geom.MultiLineString.prototype.getLineStrings
@exportProperty ol.geom.MultiLineString.prototype.getType

View File

@@ -78,6 +78,41 @@ ol.geom.MultiLineString.prototype.closestPointXY =
};
/**
* Returns the coordinate at `m` using linear interpolation, or `null` if no
* such coordinate exists.
*
* `opt_extrapolate` controls extrapolation beyond the range of Ms in the
* MultiLineString. If `opt_extrapolate` is `true` then Ms less than the first
* M will return the first coordinate and Ms greater than the last M will
* return the last coordinate.
*
* `opt_interpolate` controls interpolation between consecutive LineStrings
* within the MultiLineString. If `opt_interpolate` is `true` the coordinates
* will be linearly interpolated between the last coordinate of one LineString
* and the first coordinate of the next LineString. If `opt_interpolate` is
* `false` then the function will return `null` for Ms falling between
* LineStrings.
*
* @param {number} m M.
* @param {boolean=} opt_extrapolate Extrapolate.
* @param {boolean=} opt_interpolate Interpolate.
* @return {ol.Coordinate} Coordinate.
*/
ol.geom.MultiLineString.prototype.getCoordinateAtM =
function(m, opt_extrapolate, opt_interpolate) {
if ((this.layout != ol.geom.GeometryLayout.XYM &&
this.layout != ol.geom.GeometryLayout.XYZM) ||
this.flatCoordinates.length === 0) {
return null;
}
var extrapolate = goog.isDef(opt_extrapolate) ? opt_extrapolate : false;
var interpolate = goog.isDef(opt_interpolate) ? opt_interpolate : false;
return ol.geom.flat.lineStringsCoordinateAtM(this.flatCoordinates, 0,
this.ends_, this.stride, m, extrapolate, interpolate);
};
/**
* @return {ol.geom.RawMultiLineString} Coordinates.
* @todo stability experimental