index.d.ts 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import { Feature, MultiPolygon, Polygon, Properties } from "@turf/helpers";
  2. /**
  3. * Takes two {@link Polygon|polygon} or {@link MultiPolygon|multi-polygon} geometries and
  4. * finds their polygonal intersection. If they don't intersect, returns null.
  5. *
  6. * @name intersect
  7. * @param {Feature<Polygon | MultiPolygon>} poly1 the first polygon or multipolygon
  8. * @param {Feature<Polygon | MultiPolygon>} poly2 the second polygon or multipolygon
  9. * @param {Object} [options={}] Optional Parameters
  10. * @param {Object} [options.properties={}] Translate GeoJSON Properties to Feature
  11. * @returns {Feature|null} returns a feature representing the area they share (either a {@link Polygon} or
  12. * {@link MultiPolygon}). If they do not share any area, returns `null`.
  13. * @example
  14. * var poly1 = turf.polygon([[
  15. * [-122.801742, 45.48565],
  16. * [-122.801742, 45.60491],
  17. * [-122.584762, 45.60491],
  18. * [-122.584762, 45.48565],
  19. * [-122.801742, 45.48565]
  20. * ]]);
  21. *
  22. * var poly2 = turf.polygon([[
  23. * [-122.520217, 45.535693],
  24. * [-122.64038, 45.553967],
  25. * [-122.720031, 45.526554],
  26. * [-122.669906, 45.507309],
  27. * [-122.723464, 45.446643],
  28. * [-122.532577, 45.408574],
  29. * [-122.487258, 45.477466],
  30. * [-122.520217, 45.535693]
  31. * ]]);
  32. *
  33. * var intersection = turf.intersect(poly1, poly2);
  34. *
  35. * //addToMap
  36. * var addToMap = [poly1, poly2, intersection];
  37. */
  38. export default function intersect<P = Properties>(poly1: Feature<Polygon | MultiPolygon> | Polygon | MultiPolygon, poly2: Feature<Polygon | MultiPolygon> | Polygon | MultiPolygon, options?: {
  39. properties?: P;
  40. }): Feature<Polygon | MultiPolygon, P> | null;