lineEach
Description
Iterate over line or ring coordinates in LineString, Polygon, MultiLineString, MultiPolygon Features or Geometries, similar to Array.forEach.
Parameters
Name | Type | Description |
---|---|---|
geojson | FeatureCollection<Lines> | Feature<Lines> | Lines | Feature<GeometryCollection> | GeometryCollection | object |
callback | lineEachCallback | a method that takes (currentLine, featureIndex, multiFeatureIndex, geometryIndex) |
Returns
void
Examples
var multiLine = turf.multiLineString([
[
[26, 37],
[35, 45],
],
[
[36, 53],
[38, 50],
[41, 55],
],
]);
turf.lineEach(
multiLine,
function (currentLine, featureIndex, multiFeatureIndex, geometryIndex) {
//=currentLine
//=featureIndex
//=multiFeatureIndex
//=geometryIndex
},
);
Installation
$ npm install @turf/meta
import { lineEach } from "@turf/meta";
const result = lineEach(...);
$ npm install @turf/turf
import * as turf from "@turf/turf";
const result = turf.lineEach(...);