You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
964 B
32 lines
964 B
/**
|
|
* @module ol/geom/flat/segments
|
|
*/
|
|
|
|
/**
|
|
* This function calls `callback` for each segment of the flat coordinates
|
|
* array. If the callback returns a truthy value the function returns that
|
|
* value immediately. Otherwise the function returns `false`.
|
|
* @param {Array<number>} flatCoordinates Flat coordinates.
|
|
* @param {number} offset Offset.
|
|
* @param {number} end End.
|
|
* @param {number} stride Stride.
|
|
* @param {function(import("../../coordinate.js").Coordinate, import("../../coordinate.js").Coordinate): T} callback Function
|
|
* called for each segment.
|
|
* @return {T|boolean} Value.
|
|
* @template T
|
|
*/
|
|
export function forEach(flatCoordinates, offset, end, stride, callback) {
|
|
let ret;
|
|
offset += stride;
|
|
for (; offset < end; offset += stride) {
|
|
ret = callback(
|
|
flatCoordinates.slice(offset - stride, offset),
|
|
flatCoordinates.slice(offset, offset + stride)
|
|
);
|
|
if (ret) {
|
|
return ret;
|
|
}
|
|
}
|
|
return false;
|
|
}
|