index.js 762 B

12345678910111213141516171819202122232425262728
  1. // index.ts
  2. import { polygon } from "@turf/helpers";
  3. function bboxPolygon(bbox, options = {}) {
  4. const west = Number(bbox[0]);
  5. const south = Number(bbox[1]);
  6. const east = Number(bbox[2]);
  7. const north = Number(bbox[3]);
  8. if (bbox.length === 6) {
  9. throw new Error(
  10. "@turf/bbox-polygon does not support BBox with 6 positions"
  11. );
  12. }
  13. const lowLeft = [west, south];
  14. const topLeft = [west, north];
  15. const topRight = [east, north];
  16. const lowRight = [east, south];
  17. return polygon(
  18. [[lowLeft, lowRight, topRight, topLeft, lowLeft]],
  19. options.properties,
  20. { bbox, id: options.id }
  21. );
  22. }
  23. var turf_bbox_polygon_default = bboxPolygon;
  24. export {
  25. bboxPolygon,
  26. turf_bbox_polygon_default as default
  27. };
  28. //# sourceMappingURL=index.js.map