index.d.cts 1.2 KB

1234567891011121314151617181920212223
  1. import { Feature, Point, Position, Polygon, MultiPolygon } from 'geojson';
  2. import { Units } from '@turf/helpers';
  3. /**
  4. * Calculates the distance from a point to the edges of a polygon or multi-polygon.
  5. * Returns negative values for points inside the polygon.
  6. * Handles polygons with holes and multi-polygons.
  7. * A hole is treated as the exterior of the polygon.
  8. *
  9. * @param {Feature<Point> | Point | Position} point Input point
  10. * @param {Feature<Polygon | MultiPolygon> | Polygon | MultiPolygon} polygonOrMultiPolygon Input polygon or multipolygon
  11. * @param {Object} options Optional parameters
  12. * @param {Units} options.units Units of the result e.g. "kilometers", "miles", "meters"
  13. * @param {"geodesic" | "planar"} options.method Method of the result
  14. * @returns {number} Distance in meters (negative values for points inside the polygon)
  15. * @throws {Error} If input geometries are invalid
  16. */
  17. declare function pointToPolygonDistance(point: Feature<Point> | Point | Position, polygonOrMultiPolygon: Feature<Polygon | MultiPolygon> | Polygon | MultiPolygon, options?: {
  18. units?: Units;
  19. method?: "geodesic" | "planar";
  20. }): number;
  21. export { pointToPolygonDistance as default, pointToPolygonDistance };