index.d.ts 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import { Polygon, MultiPolygon, GeoJsonProperties, Feature, Point, MultiPoint, FeatureCollection } from 'geojson';
  2. /**
  3. * Finds {@link Points} or {@link MultiPoint} coordinate positions that fall within {@link (Multi)Polygon(s)}.
  4. *
  5. * @function
  6. * @param {Feature|FeatureCollection<Point|MultiPoint>} points Point(s) or MultiPoint(s) as input search
  7. * @param {FeatureCollection|Geometry|Feature<Polygon|MultiPolygon>} polygons (Multi)Polygon(s) to check if points are within
  8. * @returns {FeatureCollection<Point|MultiPoint>} Point(s) or MultiPoint(s) with positions that land within at least one polygon. The geometry type will match what was passsed in
  9. * @example
  10. * var points = turf.points([
  11. * [-46.6318, -23.5523],
  12. * [-46.6246, -23.5325],
  13. * [-46.6062, -23.5513],
  14. * [-46.663, -23.554],
  15. * [-46.643, -23.557]
  16. * ]);
  17. *
  18. * var searchWithin = turf.polygon([[
  19. * [-46.653,-23.543],
  20. * [-46.634,-23.5346],
  21. * [-46.613,-23.543],
  22. * [-46.614,-23.559],
  23. * [-46.631,-23.567],
  24. * [-46.653,-23.560],
  25. * [-46.653,-23.543]
  26. * ]]);
  27. *
  28. * var ptsWithin = turf.pointsWithinPolygon(points, searchWithin);
  29. *
  30. * //addToMap
  31. * var addToMap = [points, searchWithin, ptsWithin]
  32. * turf.featureEach(ptsWithin, function (currentFeature) {
  33. * currentFeature.properties['marker-size'] = 'large';
  34. * currentFeature.properties['marker-color'] = '#000';
  35. * });
  36. */
  37. declare function pointsWithinPolygon<G extends Polygon | MultiPolygon, P extends GeoJsonProperties>(points: Feature<Point | MultiPoint, P> | FeatureCollection<Point | MultiPoint, P>, polygons: Feature<G> | FeatureCollection<G> | G): FeatureCollection<Point | MultiPoint, P>;
  38. export { pointsWithinPolygon as default, pointsWithinPolygon };