index.cjs 994 B

123456789101112131415161718192021222324252627282930313233
  1. "use strict";Object.defineProperty(exports, "__esModule", {value: true});// index.ts
  2. var _distance = require('@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.distance.call(void 0, bbox.slice(0, 2), [east, south]);
  9. var verticalDistance = _distance.distance.call(void 0, 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. exports.default = turf_square_default; exports.square = square;
  30. //# sourceMappingURL=index.cjs.map