Skip to content

KBE3D / KBCore / turf / coordReduce

函数: coordReduce()

coordReduce<Reducer>(geojson: AllGeoJSON, callback: (previousValue: Reducer, currentCoord: number[], coordIndex: number, featureIndex: number, multiFeatureIndex: number, geometryIndex: number) => Reducer, initialValue?: Reducer, excludeWrapCoord?: boolean): Reducer

Function

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

类型参数

Reducer

Reducer

参数

geojson

AllGeoJSON

any GeoJSON object

callback

(previousValue: Reducer, currentCoord: number[], coordIndex: number, featureIndex: number, multiFeatureIndex: number, geometryIndex: number) => Reducer

a method that takes (previousValue, currentCoord, coordIndex)

initialValue?

Reducer

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

excludeWrapCoord?

boolean

whether or not to include the final coordinate of LinearRings that wraps the ring in its iteration.

返回

Reducer

The value that results from the reduction.

示例

ts
var features = turf.featureCollection([
  turf.point([26, 37], {"foo": "bar"}),
  turf.point([36, 53], {"hello": "world"})
]);

turf.coordReduce(features, function (previousValue, currentCoord, coordIndex, featureIndex, multiFeatureIndex, geometryIndex) {
  //=previousValue
  //=currentCoord
  //=coordIndex
  //=featureIndex
  //=multiFeatureIndex
  //=geometryIndex
  return currentCoord;
});

KBE3D @3.0.0 Copyright © 2024-present KBE3D