index.d.ts 1.5 KB

1234567891011121314151617181920212223242526272829303132333435
  1. import { Feature, Polygon, MultiPolygon, Properties } from "@turf/helpers";
  2. /**
  3. * Takes two {@link (Multi)Polygon(s)} and returns a combined polygon. If the input polygons are not contiguous, this function returns a {@link MultiPolygon} feature.
  4. *
  5. * @name union
  6. * @param {Feature<Polygon|MultiPolygon>} polygon1 input Polygon feature
  7. * @param {Feature<Polygon|MultiPolygon>} polygon2 Polygon feature to difference from polygon1
  8. * @param {Object} [options={}] Optional Parameters
  9. * @param {Object} [options.properties={}] Translate Properties to output Feature
  10. * @returns {Feature<(Polygon|MultiPolygon)>} a combined {@link Polygon} or {@link MultiPolygon} feature, or null if the inputs are empty
  11. * @example
  12. * var poly1 = turf.polygon([[
  13. * [-82.574787, 35.594087],
  14. * [-82.574787, 35.615581],
  15. * [-82.545261, 35.615581],
  16. * [-82.545261, 35.594087],
  17. * [-82.574787, 35.594087]
  18. * ]], {"fill": "#0f0"});
  19. * var poly2 = turf.polygon([[
  20. * [-82.560024, 35.585153],
  21. * [-82.560024, 35.602602],
  22. * [-82.52964, 35.602602],
  23. * [-82.52964, 35.585153],
  24. * [-82.560024, 35.585153]
  25. * ]], {"fill": "#00f"});
  26. *
  27. * var union = turf.union(poly1, poly2);
  28. *
  29. * //addToMap
  30. * var addToMap = [poly1, poly2, union];
  31. */
  32. declare function union<P = Properties>(poly1: Feature<Polygon | MultiPolygon> | Polygon | MultiPolygon, poly2: Feature<Polygon | MultiPolygon> | Polygon | MultiPolygon, options?: {
  33. properties?: P;
  34. }): Feature<Polygon | MultiPolygon, P> | null;
  35. export default union;