index.js 862 B

123456789101112131415161718192021222324252627282930313233
  1. // index.ts
  2. import { distance } from "@turf/distance";
  3. function square(bbox) {
  4. var west = bbox[0];
  5. var south = bbox[1];
  6. var east = bbox[2];
  7. var north = bbox[3];
  8. var horizontalDistance = distance(bbox.slice(0, 2), [east, south]);
  9. var verticalDistance = distance(bbox.slice(0, 2), [west, north]);
  10. if (horizontalDistance >= verticalDistance) {
  11. var verticalMidpoint = (south + north) / 2;
  12. return [
  13. west,
  14. verticalMidpoint - (east - west) / 2,
  15. east,
  16. verticalMidpoint + (east - west) / 2
  17. ];
  18. } else {
  19. var horizontalMidpoint = (west + east) / 2;
  20. return [
  21. horizontalMidpoint - (north - south) / 2,
  22. south,
  23. horizontalMidpoint + (north - south) / 2,
  24. north
  25. ];
  26. }
  27. }
  28. var turf_square_default = square;
  29. export {
  30. turf_square_default as default,
  31. square
  32. };
  33. //# sourceMappingURL=index.js.map