index.d.cts 1.5 KB

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