index.d.ts 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import { FeatureCollection, Polygon, MultiPolygon, Feature } from 'geojson';
  2. /**
  3. * Finds the difference between multiple {@link Polygon|polygons} by clipping the subsequent polygon from the first.
  4. *
  5. * @function
  6. * @param {FeatureCollection<Polygon|MultiPolygon>} features input Polygon features
  7. * @returns {Feature<Polygon|MultiPolygon>|null} a Polygon or MultiPolygon feature showing the area of `polygon1` excluding the area of `polygon2` (if empty returns `null`)
  8. * @example
  9. * var polygon1 = turf.polygon([[
  10. * [128, -26],
  11. * [141, -26],
  12. * [141, -21],
  13. * [128, -21],
  14. * [128, -26]
  15. * ]], {
  16. * "fill": "#F00",
  17. * "fill-opacity": 0.1
  18. * });
  19. * var polygon2 = turf.polygon([[
  20. * [126, -28],
  21. * [140, -28],
  22. * [140, -20],
  23. * [126, -20],
  24. * [126, -28]
  25. * ]], {
  26. * "fill": "#00F",
  27. * "fill-opacity": 0.1
  28. * });
  29. *
  30. * var difference = turf.difference(turf.featureCollection([polygon1, polygon2]));
  31. *
  32. * //addToMap
  33. * var addToMap = [polygon1, polygon2, difference];
  34. */
  35. declare function difference(features: FeatureCollection<Polygon | MultiPolygon>): Feature<Polygon | MultiPolygon> | null;
  36. export { difference as default, difference };