index.js 678 B

1234567891011121314151617181920212223242526272829
  1. // index.ts
  2. import { coordEach } from "@turf/meta";
  3. function bbox(geojson, options = {}) {
  4. if (geojson.bbox != null && true !== options.recompute) {
  5. return geojson.bbox;
  6. }
  7. const result = [Infinity, Infinity, -Infinity, -Infinity];
  8. coordEach(geojson, (coord) => {
  9. if (result[0] > coord[0]) {
  10. result[0] = coord[0];
  11. }
  12. if (result[1] > coord[1]) {
  13. result[1] = coord[1];
  14. }
  15. if (result[2] < coord[0]) {
  16. result[2] = coord[0];
  17. }
  18. if (result[3] < coord[1]) {
  19. result[3] = coord[1];
  20. }
  21. });
  22. return result;
  23. }
  24. var turf_bbox_default = bbox;
  25. export {
  26. bbox,
  27. turf_bbox_default as default
  28. };
  29. //# sourceMappingURL=index.js.map