Add new ol.geom.LineString#forEachSegment function
This commit is contained in:
@@ -11,6 +11,7 @@ goog.require('ol.geom.flat.inflate');
|
|||||||
goog.require('ol.geom.flat.interpolate');
|
goog.require('ol.geom.flat.interpolate');
|
||||||
goog.require('ol.geom.flat.intersectsextent');
|
goog.require('ol.geom.flat.intersectsextent');
|
||||||
goog.require('ol.geom.flat.length');
|
goog.require('ol.geom.flat.length');
|
||||||
|
goog.require('ol.geom.flat.segments');
|
||||||
goog.require('ol.geom.flat.simplify');
|
goog.require('ol.geom.flat.simplify');
|
||||||
|
|
||||||
|
|
||||||
@@ -107,6 +108,23 @@ ol.geom.LineString.prototype.closestPointXY =
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Iterate over each segment, calling the provided callback.
|
||||||
|
* If the callback returns a truthy value the function returns that
|
||||||
|
* value immediately. Otherwise the function returns `false`.
|
||||||
|
*
|
||||||
|
* @param {function(ol.Coordinate, ol.Coordinate): T} callback Function
|
||||||
|
* called for each segment.
|
||||||
|
* @return {T|boolean} Value.
|
||||||
|
* @template T
|
||||||
|
* @api
|
||||||
|
*/
|
||||||
|
ol.geom.LineString.prototype.forEachSegment = function(callback) {
|
||||||
|
return ol.geom.flat.segments.forEach(this.flatCoordinates, 0,
|
||||||
|
this.flatCoordinates.length, this.stride, callback);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the coordinate at `m` using linear interpolation, or `null` if no
|
* Returns the coordinate at `m` using linear interpolation, or `null` if no
|
||||||
* such coordinate exists.
|
* such coordinate exists.
|
||||||
|
|||||||
Reference in New Issue
Block a user