index.js 637 B

12345678910111213141516171819202122232425
  1. // index.ts
  2. import { polygon } from "@turf/helpers";
  3. import { coordEach } from "@turf/meta";
  4. import concaveman from "concaveman";
  5. function convex(geojson, options = {}) {
  6. options.concavity = options.concavity || Infinity;
  7. const points = [];
  8. coordEach(geojson, (coord) => {
  9. points.push([coord[0], coord[1]]);
  10. });
  11. if (!points.length) {
  12. return null;
  13. }
  14. const convexHull = concaveman(points, options.concavity);
  15. if (convexHull.length > 3) {
  16. return polygon([convexHull]);
  17. }
  18. return null;
  19. }
  20. var turf_convex_default = convex;
  21. export {
  22. convex,
  23. turf_convex_default as default
  24. };
  25. //# sourceMappingURL=index.js.map