Appearance
KBE3D / KBCore / turf / geomReduce
函数: geomReduce()
geomReduce<
Reducer,G,P>(geojson:GeometryCollection<Geometry> |G|Feature<G,P> |FeatureCollection<G,P> |Feature<GeometryCollection<Geometry>,P>,callback: (previousValue:Reducer,currentGeometry:G,featureIndex:number,featureProperties:P,featureBBox:BBox,featureId:Id) =>Reducer,initialValue?:Reducer):Reducer
Function
Reduce geometry in any GeoJSON object, similar to Array.reduce().
类型参数
Reducer
Reducer
G
G extends Geometry
P
P extends GeoJsonProperties = GeoJsonProperties
参数
geojson
any GeoJSON object
GeometryCollection<Geometry> | G | Feature<G, P> | FeatureCollection<G, P> | Feature<GeometryCollection<Geometry>, P>
callback
(previousValue: Reducer, currentGeometry: G, featureIndex: number, featureProperties: P, featureBBox: BBox, featureId: Id) => Reducer
a method that takes (previousValue, currentGeometry, featureIndex, featureProperties, featureBBox, featureId)
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.geomReduce(features, function (previousValue, currentGeometry, featureIndex, featureProperties, featureBBox, featureId) {
//=previousValue
//=currentGeometry
//=featureIndex
//=featureProperties
//=featureBBox
//=featureId
return currentGeometry
});