Skip to content

KBE3D / KBCore / turf / lineReduce

函数: lineReduce()

lineReduce<Reducer, P>(geojson: GeometryCollection<Geometry> | Lines | FeatureCollection<Lines, P> | Feature<Lines, P> | Feature<GeometryCollection<Geometry>, P>, callback: (previousValue?: Reducer, currentLine?: Feature<LineString, P>, featureIndex?: number, multiFeatureIndex?: number, geometryIndex?: number) => Reducer, initialValue?: Reducer): Reducer

Function

Reduce features in any GeoJSON object, similar to Array.reduce().

类型参数

Reducer

Reducer

P

P extends GeoJsonProperties = GeoJsonProperties

参数

geojson

object

GeometryCollection<Geometry> | Lines | FeatureCollection<Lines, P> | Feature<Lines, P> | Feature<GeometryCollection<Geometry>, P>

callback

(previousValue?: Reducer, currentLine?: Feature<LineString, P>, featureIndex?: number, multiFeatureIndex?: number, geometryIndex?: number) => Reducer

a method that takes (previousValue, currentLine, featureIndex, multiFeatureIndex, geometryIndex)

initialValue?

Reducer

Value to use as the first argument to the first call of the callback.

返回

Reducer

The value that results from the reduction.

示例

ts
var multiPoly = turf.multiPolygon([
  turf.polygon([[[12,48],[2,41],[24,38],[12,48]], [[9,44],[13,41],[13,45],[9,44]]]),
  turf.polygon([[[5, 5], [0, 0], [2, 2], [4, 4], [5, 5]]])
]);

turf.lineReduce(multiPoly, function (previousValue, currentLine, featureIndex, multiFeatureIndex, geometryIndex) {
  //=previousValue
  //=currentLine
  //=featureIndex
  //=multiFeatureIndex
  //=geometryIndex
  return currentLine
});

KBE3D @3.0.0 Copyright © 2024-present KBE3D