index.cjs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. "use strict";Object.defineProperty(exports, "__esModule", {value: true});// index.ts
  2. var _bearing = require('@turf/bearing');
  3. var _helpers = require('@turf/helpers');
  4. var _rhumbbearing = require('@turf/rhumb-bearing');
  5. function angle(startPoint, midPoint, endPoint, options = {}) {
  6. if (!_helpers.isObject.call(void 0, options)) {
  7. throw new Error("options is invalid");
  8. }
  9. if (!startPoint) {
  10. throw new Error("startPoint is required");
  11. }
  12. if (!midPoint) {
  13. throw new Error("midPoint is required");
  14. }
  15. if (!endPoint) {
  16. throw new Error("endPoint is required");
  17. }
  18. const A = startPoint;
  19. const O = midPoint;
  20. const B = endPoint;
  21. const azimuthOA = _helpers.bearingToAzimuth.call(void 0,
  22. options.mercator !== true ? _bearing.bearing.call(void 0, O, A) : _rhumbbearing.rhumbBearing.call(void 0, O, A)
  23. );
  24. let azimuthOB = _helpers.bearingToAzimuth.call(void 0,
  25. options.mercator !== true ? _bearing.bearing.call(void 0, O, B) : _rhumbbearing.rhumbBearing.call(void 0, O, B)
  26. );
  27. if (azimuthOB < azimuthOA) {
  28. azimuthOB = azimuthOB + 360;
  29. }
  30. const angleAOB = azimuthOB - azimuthOA;
  31. if (options.explementary === true) {
  32. return 360 - angleAOB;
  33. }
  34. return angleAOB;
  35. }
  36. var turf_angle_default = angle;
  37. exports.angle = angle; exports.default = turf_angle_default;
  38. //# sourceMappingURL=index.cjs.map