diff --git a/turf/turf-test.ts b/turf/turf-test.ts index 296542868..4d89f140e 100644 --- a/turf/turf-test.ts +++ b/turf/turf-test.ts @@ -347,6 +347,11 @@ var polygon = turf.polygon([[ // Tests Data ////////////////////////////////////////////////////////////////////////// +// -- Test filter -- +var key = "species"; +var value = "oak"; +var filtered = turf.filter(features, key, value); + ////////////////////////////////////////////////////////////////////////// // Tests Interpolation //////////////////////////////////////////////////////////////////////////; diff --git a/turf/turf.d.ts b/turf/turf.d.ts index 0f6868630..85d7b25f9 100644 --- a/turf/turf.d.ts +++ b/turf/turf.d.ts @@ -296,6 +296,15 @@ declare module turf { // Data ////////////////////////////////////////////////////// + /** + * Takes a FeatureCollection and filters it by a given property and value. + * @param features Input features + * @param key The property on which to filter + * @param value The value of that property on which to filter + * @returns A filtered collection with only features that match input key and value + */ + function filter(features: GeoJSON.FeatureCollection, key: string, value: string): GeoJSON.FeatureCollection; + ////////////////////////////////////////////////////// // Interpolation //////////////////////////////////////////////////////