Appearance
KBE3D / KBCore / turf / featureReduce
函数: featureReduce()
featureReduce<
Reducer,G,P>(geojson:Feature<G,P> |FeatureCollection<G,P> |Feature<GeometryCollection<Geometry>,P>,callback: (previousValue:Reducer,currentFeature:Feature<G,P>,featureIndex:number) =>Reducer,initialValue?:Reducer):Reducer
Function
Reduce features in any GeoJSON object, similar to Array.reduce().
类型参数
Reducer
Reducer
G
G extends Geometry
P
P extends GeoJsonProperties = GeoJsonProperties
参数
geojson
any GeoJSON object
Feature<G, P> | FeatureCollection<G, P> | Feature<GeometryCollection<Geometry>, P>
callback
(previousValue: Reducer, currentFeature: Feature<G, P>, featureIndex: number) => Reducer
a method that takes (previousValue, currentFeature, featureIndex)
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 features = turf.featureCollection([
turf.point([26, 37], {"foo": "bar"}),
turf.point([36, 53], {"hello": "world"})
]);
turf.featureReduce(features, function (previousValue, currentFeature, featureIndex) {
//=previousValue
//=currentFeature
//=featureIndex
return currentFeature
});