diff --git a/turf/turf-test.ts b/turf/turf-test.ts index e8aaec7083..d46bf2e81d 100644 --- a/turf/turf-test.ts +++ b/turf/turf-test.ts @@ -421,6 +421,15 @@ var triangleGrid = turf.triangleGrid(extent, cellWidth, units); // Tests Joins ////////////////////////////////////////////////////////////////////////// +// -- Test inside -- +var isInside1 = turf.inside(point1, polygon); + +// -- Test tag -- +var tagged = turf.tag(points, triangleGrid, 'fill', 'marker-color'); + +// -- Test within -- +var ptsWithin = turf.within(points, polygons); + ////////////////////////////////////////////////////////////////////////// // Tests Classification ////////////////////////////////////////////////////////////////////////// diff --git a/turf/turf.d.ts b/turf/turf.d.ts index b74681a89a..f90668b4f0 100644 --- a/turf/turf.d.ts +++ b/turf/turf.d.ts @@ -406,6 +406,32 @@ declare module turf { // Joins ////////////////////////////////////////////////////// + /** + * Takes a Point and a Polygon or MultiPolygon and determines if the point resides inside the polygon. The polygon can be convex or concave. The function accounts for holes. + * @param point Input point + * @param polygon Input polygon or multipolygon + * @returns true if the Point is inside the Polygon; false if the Point is not inside the Polygon + */ + function inside(point: GeoJSON.Feature, polygon: GeoJSON.Feature): boolean; + + /** + * Takes a set of points and a set of polygons and performs a spatial join. + * @param points Input points + * @param polygons Input polygons + * @param polyId Property in polygons to add to joined Point features + * @param containingPolyId Property in points in which to store joined property from polygons + * @returns Points with containingPolyId property containing values from polyId + */ + function tag(points: GeoJSON.FeatureCollection, polygons: GeoJSON.FeatureCollection, polyId: string, containingPolyId: string): GeoJSON.FeatureCollection; + + /** + * Takes a set of points and a set of polygons and returns the points that fall within the polygons. + * @param points Input points + * @param polygons Input polygons + * @returns Points that land within at least one polygon + */ + function within(points: GeoJSON.FeatureCollection, polygons: GeoJSON.FeatureCollection): GeoJSON.FeatureCollection; + ////////////////////////////////////////////////////// // Classification //////////////////////////////////////////////////////