@turf/rhumb-destination 7.0.0 → 7.1.0-alpha.70

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -32,7 +32,7 @@ var addToMap = [pt, destination]
32
32
  destination.properties['marker-color'] = '#00F';
33
33
  ```
34
34
 
35
- Returns **[Feature][6]<[Point][7]>** Destination point.
35
+ Returns **[Feature][6]<[Point][1]>** Destination point.
36
36
 
37
37
  [1]: https://tools.ietf.org/html/rfc7946#section-3.1.2
38
38
 
@@ -46,8 +46,6 @@ Returns **[Feature][6]<[Point][7]>** Destination point.
46
46
 
47
47
  [6]: https://tools.ietf.org/html/rfc7946#section-3.2
48
48
 
49
- [7]: https://tools.ietf.org/html/rfc7946#section-3.1.2
50
-
51
49
  <!-- This file is automatically generated. Please don't edit it directly. If you find an error, edit the source file of the module in question (likely index.js or index.ts), and re-run "yarn docs" from the root of the turf project. -->
52
50
 
53
51
  ---
@@ -1,7 +1,4 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
-
4
- // index.ts
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});// index.ts
5
2
 
6
3
 
7
4
 
@@ -27,7 +24,6 @@ function rhumbDestination(origin, distance, bearing, options = {}) {
27
24
  destination[0] += destination[0] - coords[0] > 180 ? -360 : coords[0] - destination[0] > 180 ? 360 : 0;
28
25
  return _helpers.point.call(void 0, destination, options.properties);
29
26
  }
30
- __name(rhumbDestination, "rhumbDestination");
31
27
  function calculateRhumbDestination(origin, distance, bearing, radius) {
32
28
  radius = radius === void 0 ? _helpers.earthRadius : Number(radius);
33
29
  const delta = distance / radius;
@@ -50,7 +46,6 @@ function calculateRhumbDestination(origin, distance, bearing, radius) {
50
46
  phi2 * 180 / Math.PI
51
47
  ];
52
48
  }
53
- __name(calculateRhumbDestination, "calculateRhumbDestination");
54
49
  var turf_rhumb_destination_default = rhumbDestination;
55
50
 
56
51
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../index.ts"],"names":[],"mappings":";;;;AAEA;AAAA,EACE;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AACP,SAAS,gBAAgB;AA0BzB,SAAS,iBACP,QACA,UACA,SACA,UAGI,CAAC,GACc;AACnB,QAAM,sBAAsB,WAAW;AACvC,MAAI,mBAAmB;AAAA,IACrB,KAAK,IAAI,QAAQ;AAAA,IACjB,QAAQ;AAAA,IACR;AAAA,EACF;AACA,MAAI;AAAqB,uBAAmB,CAAC,KAAK,IAAI,gBAAgB;AACtE,QAAM,SAAS,SAAS,MAAM;AAC9B,QAAM,cAAc;AAAA,IAClB;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAIA,cAAY,CAAC,KACX,YAAY,CAAC,IAAI,OAAO,CAAC,IAAI,MACzB,OACA,OAAO,CAAC,IAAI,YAAY,CAAC,IAAI,MAC3B,MACA;AACR,SAAO,MAAM,aAAa,QAAQ,UAAU;AAC9C;AAhCS;AA8CT,SAAS,0BACP,QACA,UACA,SACA,QACA;AAQA,WAAS,WAAW,SAAY,cAAc,OAAO,MAAM;AAE3D,QAAM,QAAQ,WAAW;AACzB,QAAM,UAAW,OAAO,CAAC,IAAI,KAAK,KAAM;AACxC,QAAM,OAAO,iBAAiB,OAAO,CAAC,CAAC;AACvC,QAAM,QAAQ,iBAAiB,OAAO;AAEtC,QAAM,WAAW,QAAQ,KAAK,IAAI,KAAK;AACvC,MAAI,OAAO,OAAO;AAGlB,MAAI,KAAK,IAAI,IAAI,IAAI,KAAK,KAAK,GAAG;AAChC,WAAO,OAAO,IAAI,KAAK,KAAK,OAAO,CAAC,KAAK,KAAK;AAAA,EAChD;AAEA,QAAM,WAAW,KAAK;AAAA,IACpB,KAAK,IAAI,OAAO,IAAI,KAAK,KAAK,CAAC,IAAI,KAAK,IAAI,OAAO,IAAI,KAAK,KAAK,CAAC;AAAA,EACpE;AAEA,QAAM,IAAI,KAAK,IAAI,QAAQ,IAAI,QAAS,WAAW,WAAW,KAAK,IAAI,IAAI;AAE3E,QAAM,cAAe,QAAQ,KAAK,IAAI,KAAK,IAAK;AAChD,QAAM,UAAU,UAAU;AAE1B,SAAO;AAAA,KACF,UAAU,MAAO,KAAK,KAAK,OAAO,MAAO;AAAA,IAC3C,OAAO,MAAO,KAAK;AAAA,EACtB;AACF;AAzCS;AA4CT,IAAO,iCAAQ","sourcesContent":["// https://en.wikipedia.org/wiki/Rhumb_line\nimport { Feature, Point, GeoJsonProperties } from \"geojson\";\nimport {\n convertLength,\n Coord,\n degreesToRadians,\n earthRadius,\n point,\n Units,\n} from \"@turf/helpers\";\nimport { getCoord } from \"@turf/invariant\";\n\n/**\n * Returns the destination {@link Point} having travelled the given distance along a Rhumb line from the\n * origin Point with the (varant) given bearing.\n *\n * @name rhumbDestination\n * @param {Coord} origin starting point\n * @param {number} distance distance from the starting point\n * @param {number} bearing varant bearing angle ranging from -180 to 180 degrees from north\n * @param {Object} [options={}] Optional parameters\n * @param {string} [options.units='kilometers'] can be degrees, radians, miles, or kilometers\n * @param {Object} [options.properties={}] translate properties to destination point\n * @returns {Feature<Point>} Destination point.\n * @example\n * var pt = turf.point([-75.343, 39.984], {\"marker-color\": \"F00\"});\n * var distance = 50;\n * var bearing = 90;\n * var options = {units: 'miles'};\n *\n * var destination = turf.rhumbDestination(pt, distance, bearing, options);\n *\n * //addToMap\n * var addToMap = [pt, destination]\n * destination.properties['marker-color'] = '#00F';\n */\nfunction rhumbDestination<P extends GeoJsonProperties = GeoJsonProperties>(\n origin: Coord,\n distance: number,\n bearing: number,\n options: {\n units?: Units;\n properties?: P;\n } = {}\n): Feature<Point, P> {\n const wasNegativeDistance = distance < 0;\n let distanceInMeters = convertLength(\n Math.abs(distance),\n options.units,\n \"meters\"\n );\n if (wasNegativeDistance) distanceInMeters = -Math.abs(distanceInMeters);\n const coords = getCoord(origin);\n const destination = calculateRhumbDestination(\n coords,\n distanceInMeters,\n bearing\n );\n\n // compensate the crossing of the 180th meridian (https://macwright.org/2016/09/26/the-180th-meridian.html)\n // solution from https://github.com/mapbox/mapbox-gl-js/issues/3250#issuecomment-294887678\n destination[0] +=\n destination[0] - coords[0] > 180\n ? -360\n : coords[0] - destination[0] > 180\n ? 360\n : 0;\n return point(destination, options.properties);\n}\n\n/**\n * Returns the destination point having travelled along a rhumb line from origin point the given\n * distance on the given bearing.\n * Adapted from Geodesy: http://www.movable-type.co.uk/scripts/latlong.html#rhumblines\n *\n * @private\n * @param {Array<number>} origin - point\n * @param {number} distance - Distance travelled, in same units as earth radius (default: metres).\n * @param {number} bearing - Bearing in degrees from north.\n * @param {number} [radius=6371e3] - (Mean) radius of earth (defaults to radius in metres).\n * @returns {Array<number>} Destination point.\n */\nfunction calculateRhumbDestination(\n origin: number[],\n distance: number,\n bearing: number,\n radius?: number\n) {\n // φ => phi\n // λ => lambda\n // ψ => psi\n // Δ => Delta\n // δ => delta\n // θ => theta\n\n radius = radius === undefined ? earthRadius : Number(radius);\n\n const delta = distance / radius; // angular distance in radians\n const lambda1 = (origin[0] * Math.PI) / 180; // to radians, but without normalize to 𝜋\n const phi1 = degreesToRadians(origin[1]);\n const theta = degreesToRadians(bearing);\n\n const DeltaPhi = delta * Math.cos(theta);\n let phi2 = phi1 + DeltaPhi;\n\n // check for some daft bugger going past the pole, normalise latitude if so\n if (Math.abs(phi2) > Math.PI / 2) {\n phi2 = phi2 > 0 ? Math.PI - phi2 : -Math.PI - phi2;\n }\n\n const DeltaPsi = Math.log(\n Math.tan(phi2 / 2 + Math.PI / 4) / Math.tan(phi1 / 2 + Math.PI / 4)\n );\n // E-W course becomes ill-conditioned with 0/0\n const q = Math.abs(DeltaPsi) > 10e-12 ? DeltaPhi / DeltaPsi : Math.cos(phi1);\n\n const DeltaLambda = (delta * Math.sin(theta)) / q;\n const lambda2 = lambda1 + DeltaLambda;\n\n return [\n (((lambda2 * 180) / Math.PI + 540) % 360) - 180,\n (phi2 * 180) / Math.PI,\n ]; // normalise to −180..+180°\n}\n\nexport { rhumbDestination };\nexport default rhumbDestination;\n"]}
1
+ {"version":3,"sources":["../../index.ts"],"names":[],"mappings":";AAEA;AAAA,EACE;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AACP,SAAS,gBAAgB;AA0BzB,SAAS,iBACP,QACA,UACA,SACA,UAGI,CAAC,GACc;AACnB,QAAM,sBAAsB,WAAW;AACvC,MAAI,mBAAmB;AAAA,IACrB,KAAK,IAAI,QAAQ;AAAA,IACjB,QAAQ;AAAA,IACR;AAAA,EACF;AACA,MAAI;AAAqB,uBAAmB,CAAC,KAAK,IAAI,gBAAgB;AACtE,QAAM,SAAS,SAAS,MAAM;AAC9B,QAAM,cAAc;AAAA,IAClB;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAIA,cAAY,CAAC,KACX,YAAY,CAAC,IAAI,OAAO,CAAC,IAAI,MACzB,OACA,OAAO,CAAC,IAAI,YAAY,CAAC,IAAI,MAC3B,MACA;AACR,SAAO,MAAM,aAAa,QAAQ,UAAU;AAC9C;AAcA,SAAS,0BACP,QACA,UACA,SACA,QACA;AAQA,WAAS,WAAW,SAAY,cAAc,OAAO,MAAM;AAE3D,QAAM,QAAQ,WAAW;AACzB,QAAM,UAAW,OAAO,CAAC,IAAI,KAAK,KAAM;AACxC,QAAM,OAAO,iBAAiB,OAAO,CAAC,CAAC;AACvC,QAAM,QAAQ,iBAAiB,OAAO;AAEtC,QAAM,WAAW,QAAQ,KAAK,IAAI,KAAK;AACvC,MAAI,OAAO,OAAO;AAGlB,MAAI,KAAK,IAAI,IAAI,IAAI,KAAK,KAAK,GAAG;AAChC,WAAO,OAAO,IAAI,KAAK,KAAK,OAAO,CAAC,KAAK,KAAK;AAAA,EAChD;AAEA,QAAM,WAAW,KAAK;AAAA,IACpB,KAAK,IAAI,OAAO,IAAI,KAAK,KAAK,CAAC,IAAI,KAAK,IAAI,OAAO,IAAI,KAAK,KAAK,CAAC;AAAA,EACpE;AAEA,QAAM,IAAI,KAAK,IAAI,QAAQ,IAAI,QAAS,WAAW,WAAW,KAAK,IAAI,IAAI;AAE3E,QAAM,cAAe,QAAQ,KAAK,IAAI,KAAK,IAAK;AAChD,QAAM,UAAU,UAAU;AAE1B,SAAO;AAAA,KACF,UAAU,MAAO,KAAK,KAAK,OAAO,MAAO;AAAA,IAC3C,OAAO,MAAO,KAAK;AAAA,EACtB;AACF;AAGA,IAAO,iCAAQ","sourcesContent":["// https://en.wikipedia.org/wiki/Rhumb_line\nimport { Feature, Point, GeoJsonProperties } from \"geojson\";\nimport {\n convertLength,\n Coord,\n degreesToRadians,\n earthRadius,\n point,\n Units,\n} from \"@turf/helpers\";\nimport { getCoord } from \"@turf/invariant\";\n\n/**\n * Returns the destination {@link Point} having travelled the given distance along a Rhumb line from the\n * origin Point with the (varant) given bearing.\n *\n * @name rhumbDestination\n * @param {Coord} origin starting point\n * @param {number} distance distance from the starting point\n * @param {number} bearing varant bearing angle ranging from -180 to 180 degrees from north\n * @param {Object} [options={}] Optional parameters\n * @param {string} [options.units='kilometers'] can be degrees, radians, miles, or kilometers\n * @param {Object} [options.properties={}] translate properties to destination point\n * @returns {Feature<Point>} Destination point.\n * @example\n * var pt = turf.point([-75.343, 39.984], {\"marker-color\": \"F00\"});\n * var distance = 50;\n * var bearing = 90;\n * var options = {units: 'miles'};\n *\n * var destination = turf.rhumbDestination(pt, distance, bearing, options);\n *\n * //addToMap\n * var addToMap = [pt, destination]\n * destination.properties['marker-color'] = '#00F';\n */\nfunction rhumbDestination<P extends GeoJsonProperties = GeoJsonProperties>(\n origin: Coord,\n distance: number,\n bearing: number,\n options: {\n units?: Units;\n properties?: P;\n } = {}\n): Feature<Point, P> {\n const wasNegativeDistance = distance < 0;\n let distanceInMeters = convertLength(\n Math.abs(distance),\n options.units,\n \"meters\"\n );\n if (wasNegativeDistance) distanceInMeters = -Math.abs(distanceInMeters);\n const coords = getCoord(origin);\n const destination = calculateRhumbDestination(\n coords,\n distanceInMeters,\n bearing\n );\n\n // compensate the crossing of the 180th meridian (https://macwright.org/2016/09/26/the-180th-meridian.html)\n // solution from https://github.com/mapbox/mapbox-gl-js/issues/3250#issuecomment-294887678\n destination[0] +=\n destination[0] - coords[0] > 180\n ? -360\n : coords[0] - destination[0] > 180\n ? 360\n : 0;\n return point(destination, options.properties);\n}\n\n/**\n * Returns the destination point having travelled along a rhumb line from origin point the given\n * distance on the given bearing.\n * Adapted from Geodesy: http://www.movable-type.co.uk/scripts/latlong.html#rhumblines\n *\n * @private\n * @param {Array<number>} origin - point\n * @param {number} distance - Distance travelled, in same units as earth radius (default: metres).\n * @param {number} bearing - Bearing in degrees from north.\n * @param {number} [radius=6371e3] - (Mean) radius of earth (defaults to radius in metres).\n * @returns {Array<number>} Destination point.\n */\nfunction calculateRhumbDestination(\n origin: number[],\n distance: number,\n bearing: number,\n radius?: number\n) {\n // φ => phi\n // λ => lambda\n // ψ => psi\n // Δ => Delta\n // δ => delta\n // θ => theta\n\n radius = radius === undefined ? earthRadius : Number(radius);\n\n const delta = distance / radius; // angular distance in radians\n const lambda1 = (origin[0] * Math.PI) / 180; // to radians, but without normalize to 𝜋\n const phi1 = degreesToRadians(origin[1]);\n const theta = degreesToRadians(bearing);\n\n const DeltaPhi = delta * Math.cos(theta);\n let phi2 = phi1 + DeltaPhi;\n\n // check for some daft bugger going past the pole, normalise latitude if so\n if (Math.abs(phi2) > Math.PI / 2) {\n phi2 = phi2 > 0 ? Math.PI - phi2 : -Math.PI - phi2;\n }\n\n const DeltaPsi = Math.log(\n Math.tan(phi2 / 2 + Math.PI / 4) / Math.tan(phi1 / 2 + Math.PI / 4)\n );\n // E-W course becomes ill-conditioned with 0/0\n const q = Math.abs(DeltaPsi) > 10e-12 ? DeltaPhi / DeltaPsi : Math.cos(phi1);\n\n const DeltaLambda = (delta * Math.sin(theta)) / q;\n const lambda2 = lambda1 + DeltaLambda;\n\n return [\n (((lambda2 * 180) / Math.PI + 540) % 360) - 180,\n (phi2 * 180) / Math.PI,\n ]; // normalise to −180..+180°\n}\n\nexport { rhumbDestination };\nexport default rhumbDestination;\n"]}
package/dist/esm/index.js CHANGED
@@ -1,6 +1,3 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
-
4
1
  // index.ts
5
2
  import {
6
3
  convertLength,
@@ -27,7 +24,6 @@ function rhumbDestination(origin, distance, bearing, options = {}) {
27
24
  destination[0] += destination[0] - coords[0] > 180 ? -360 : coords[0] - destination[0] > 180 ? 360 : 0;
28
25
  return point(destination, options.properties);
29
26
  }
30
- __name(rhumbDestination, "rhumbDestination");
31
27
  function calculateRhumbDestination(origin, distance, bearing, radius) {
32
28
  radius = radius === void 0 ? earthRadius : Number(radius);
33
29
  const delta = distance / radius;
@@ -50,7 +46,6 @@ function calculateRhumbDestination(origin, distance, bearing, radius) {
50
46
  phi2 * 180 / Math.PI
51
47
  ];
52
48
  }
53
- __name(calculateRhumbDestination, "calculateRhumbDestination");
54
49
  var turf_rhumb_destination_default = rhumbDestination;
55
50
  export {
56
51
  turf_rhumb_destination_default as default,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../index.ts"],"sourcesContent":["// https://en.wikipedia.org/wiki/Rhumb_line\nimport { Feature, Point, GeoJsonProperties } from \"geojson\";\nimport {\n convertLength,\n Coord,\n degreesToRadians,\n earthRadius,\n point,\n Units,\n} from \"@turf/helpers\";\nimport { getCoord } from \"@turf/invariant\";\n\n/**\n * Returns the destination {@link Point} having travelled the given distance along a Rhumb line from the\n * origin Point with the (varant) given bearing.\n *\n * @name rhumbDestination\n * @param {Coord} origin starting point\n * @param {number} distance distance from the starting point\n * @param {number} bearing varant bearing angle ranging from -180 to 180 degrees from north\n * @param {Object} [options={}] Optional parameters\n * @param {string} [options.units='kilometers'] can be degrees, radians, miles, or kilometers\n * @param {Object} [options.properties={}] translate properties to destination point\n * @returns {Feature<Point>} Destination point.\n * @example\n * var pt = turf.point([-75.343, 39.984], {\"marker-color\": \"F00\"});\n * var distance = 50;\n * var bearing = 90;\n * var options = {units: 'miles'};\n *\n * var destination = turf.rhumbDestination(pt, distance, bearing, options);\n *\n * //addToMap\n * var addToMap = [pt, destination]\n * destination.properties['marker-color'] = '#00F';\n */\nfunction rhumbDestination<P extends GeoJsonProperties = GeoJsonProperties>(\n origin: Coord,\n distance: number,\n bearing: number,\n options: {\n units?: Units;\n properties?: P;\n } = {}\n): Feature<Point, P> {\n const wasNegativeDistance = distance < 0;\n let distanceInMeters = convertLength(\n Math.abs(distance),\n options.units,\n \"meters\"\n );\n if (wasNegativeDistance) distanceInMeters = -Math.abs(distanceInMeters);\n const coords = getCoord(origin);\n const destination = calculateRhumbDestination(\n coords,\n distanceInMeters,\n bearing\n );\n\n // compensate the crossing of the 180th meridian (https://macwright.org/2016/09/26/the-180th-meridian.html)\n // solution from https://github.com/mapbox/mapbox-gl-js/issues/3250#issuecomment-294887678\n destination[0] +=\n destination[0] - coords[0] > 180\n ? -360\n : coords[0] - destination[0] > 180\n ? 360\n : 0;\n return point(destination, options.properties);\n}\n\n/**\n * Returns the destination point having travelled along a rhumb line from origin point the given\n * distance on the given bearing.\n * Adapted from Geodesy: http://www.movable-type.co.uk/scripts/latlong.html#rhumblines\n *\n * @private\n * @param {Array<number>} origin - point\n * @param {number} distance - Distance travelled, in same units as earth radius (default: metres).\n * @param {number} bearing - Bearing in degrees from north.\n * @param {number} [radius=6371e3] - (Mean) radius of earth (defaults to radius in metres).\n * @returns {Array<number>} Destination point.\n */\nfunction calculateRhumbDestination(\n origin: number[],\n distance: number,\n bearing: number,\n radius?: number\n) {\n // φ => phi\n // λ => lambda\n // ψ => psi\n // Δ => Delta\n // δ => delta\n // θ => theta\n\n radius = radius === undefined ? earthRadius : Number(radius);\n\n const delta = distance / radius; // angular distance in radians\n const lambda1 = (origin[0] * Math.PI) / 180; // to radians, but without normalize to 𝜋\n const phi1 = degreesToRadians(origin[1]);\n const theta = degreesToRadians(bearing);\n\n const DeltaPhi = delta * Math.cos(theta);\n let phi2 = phi1 + DeltaPhi;\n\n // check for some daft bugger going past the pole, normalise latitude if so\n if (Math.abs(phi2) > Math.PI / 2) {\n phi2 = phi2 > 0 ? Math.PI - phi2 : -Math.PI - phi2;\n }\n\n const DeltaPsi = Math.log(\n Math.tan(phi2 / 2 + Math.PI / 4) / Math.tan(phi1 / 2 + Math.PI / 4)\n );\n // E-W course becomes ill-conditioned with 0/0\n const q = Math.abs(DeltaPsi) > 10e-12 ? DeltaPhi / DeltaPsi : Math.cos(phi1);\n\n const DeltaLambda = (delta * Math.sin(theta)) / q;\n const lambda2 = lambda1 + DeltaLambda;\n\n return [\n (((lambda2 * 180) / Math.PI + 540) % 360) - 180,\n (phi2 * 180) / Math.PI,\n ]; // normalise to −180..+180°\n}\n\nexport { rhumbDestination };\nexport default rhumbDestination;\n"],"mappings":";;;;AAEA;AAAA,EACE;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AACP,SAAS,gBAAgB;AA0BzB,SAAS,iBACP,QACA,UACA,SACA,UAGI,CAAC,GACc;AACnB,QAAM,sBAAsB,WAAW;AACvC,MAAI,mBAAmB;AAAA,IACrB,KAAK,IAAI,QAAQ;AAAA,IACjB,QAAQ;AAAA,IACR;AAAA,EACF;AACA,MAAI;AAAqB,uBAAmB,CAAC,KAAK,IAAI,gBAAgB;AACtE,QAAM,SAAS,SAAS,MAAM;AAC9B,QAAM,cAAc;AAAA,IAClB;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAIA,cAAY,CAAC,KACX,YAAY,CAAC,IAAI,OAAO,CAAC,IAAI,MACzB,OACA,OAAO,CAAC,IAAI,YAAY,CAAC,IAAI,MAC3B,MACA;AACR,SAAO,MAAM,aAAa,QAAQ,UAAU;AAC9C;AAhCS;AA8CT,SAAS,0BACP,QACA,UACA,SACA,QACA;AAQA,WAAS,WAAW,SAAY,cAAc,OAAO,MAAM;AAE3D,QAAM,QAAQ,WAAW;AACzB,QAAM,UAAW,OAAO,CAAC,IAAI,KAAK,KAAM;AACxC,QAAM,OAAO,iBAAiB,OAAO,CAAC,CAAC;AACvC,QAAM,QAAQ,iBAAiB,OAAO;AAEtC,QAAM,WAAW,QAAQ,KAAK,IAAI,KAAK;AACvC,MAAI,OAAO,OAAO;AAGlB,MAAI,KAAK,IAAI,IAAI,IAAI,KAAK,KAAK,GAAG;AAChC,WAAO,OAAO,IAAI,KAAK,KAAK,OAAO,CAAC,KAAK,KAAK;AAAA,EAChD;AAEA,QAAM,WAAW,KAAK;AAAA,IACpB,KAAK,IAAI,OAAO,IAAI,KAAK,KAAK,CAAC,IAAI,KAAK,IAAI,OAAO,IAAI,KAAK,KAAK,CAAC;AAAA,EACpE;AAEA,QAAM,IAAI,KAAK,IAAI,QAAQ,IAAI,QAAS,WAAW,WAAW,KAAK,IAAI,IAAI;AAE3E,QAAM,cAAe,QAAQ,KAAK,IAAI,KAAK,IAAK;AAChD,QAAM,UAAU,UAAU;AAE1B,SAAO;AAAA,KACF,UAAU,MAAO,KAAK,KAAK,OAAO,MAAO;AAAA,IAC3C,OAAO,MAAO,KAAK;AAAA,EACtB;AACF;AAzCS;AA4CT,IAAO,iCAAQ;","names":[]}
1
+ {"version":3,"sources":["../../index.ts"],"sourcesContent":["// https://en.wikipedia.org/wiki/Rhumb_line\nimport { Feature, Point, GeoJsonProperties } from \"geojson\";\nimport {\n convertLength,\n Coord,\n degreesToRadians,\n earthRadius,\n point,\n Units,\n} from \"@turf/helpers\";\nimport { getCoord } from \"@turf/invariant\";\n\n/**\n * Returns the destination {@link Point} having travelled the given distance along a Rhumb line from the\n * origin Point with the (varant) given bearing.\n *\n * @name rhumbDestination\n * @param {Coord} origin starting point\n * @param {number} distance distance from the starting point\n * @param {number} bearing varant bearing angle ranging from -180 to 180 degrees from north\n * @param {Object} [options={}] Optional parameters\n * @param {string} [options.units='kilometers'] can be degrees, radians, miles, or kilometers\n * @param {Object} [options.properties={}] translate properties to destination point\n * @returns {Feature<Point>} Destination point.\n * @example\n * var pt = turf.point([-75.343, 39.984], {\"marker-color\": \"F00\"});\n * var distance = 50;\n * var bearing = 90;\n * var options = {units: 'miles'};\n *\n * var destination = turf.rhumbDestination(pt, distance, bearing, options);\n *\n * //addToMap\n * var addToMap = [pt, destination]\n * destination.properties['marker-color'] = '#00F';\n */\nfunction rhumbDestination<P extends GeoJsonProperties = GeoJsonProperties>(\n origin: Coord,\n distance: number,\n bearing: number,\n options: {\n units?: Units;\n properties?: P;\n } = {}\n): Feature<Point, P> {\n const wasNegativeDistance = distance < 0;\n let distanceInMeters = convertLength(\n Math.abs(distance),\n options.units,\n \"meters\"\n );\n if (wasNegativeDistance) distanceInMeters = -Math.abs(distanceInMeters);\n const coords = getCoord(origin);\n const destination = calculateRhumbDestination(\n coords,\n distanceInMeters,\n bearing\n );\n\n // compensate the crossing of the 180th meridian (https://macwright.org/2016/09/26/the-180th-meridian.html)\n // solution from https://github.com/mapbox/mapbox-gl-js/issues/3250#issuecomment-294887678\n destination[0] +=\n destination[0] - coords[0] > 180\n ? -360\n : coords[0] - destination[0] > 180\n ? 360\n : 0;\n return point(destination, options.properties);\n}\n\n/**\n * Returns the destination point having travelled along a rhumb line from origin point the given\n * distance on the given bearing.\n * Adapted from Geodesy: http://www.movable-type.co.uk/scripts/latlong.html#rhumblines\n *\n * @private\n * @param {Array<number>} origin - point\n * @param {number} distance - Distance travelled, in same units as earth radius (default: metres).\n * @param {number} bearing - Bearing in degrees from north.\n * @param {number} [radius=6371e3] - (Mean) radius of earth (defaults to radius in metres).\n * @returns {Array<number>} Destination point.\n */\nfunction calculateRhumbDestination(\n origin: number[],\n distance: number,\n bearing: number,\n radius?: number\n) {\n // φ => phi\n // λ => lambda\n // ψ => psi\n // Δ => Delta\n // δ => delta\n // θ => theta\n\n radius = radius === undefined ? earthRadius : Number(radius);\n\n const delta = distance / radius; // angular distance in radians\n const lambda1 = (origin[0] * Math.PI) / 180; // to radians, but without normalize to 𝜋\n const phi1 = degreesToRadians(origin[1]);\n const theta = degreesToRadians(bearing);\n\n const DeltaPhi = delta * Math.cos(theta);\n let phi2 = phi1 + DeltaPhi;\n\n // check for some daft bugger going past the pole, normalise latitude if so\n if (Math.abs(phi2) > Math.PI / 2) {\n phi2 = phi2 > 0 ? Math.PI - phi2 : -Math.PI - phi2;\n }\n\n const DeltaPsi = Math.log(\n Math.tan(phi2 / 2 + Math.PI / 4) / Math.tan(phi1 / 2 + Math.PI / 4)\n );\n // E-W course becomes ill-conditioned with 0/0\n const q = Math.abs(DeltaPsi) > 10e-12 ? DeltaPhi / DeltaPsi : Math.cos(phi1);\n\n const DeltaLambda = (delta * Math.sin(theta)) / q;\n const lambda2 = lambda1 + DeltaLambda;\n\n return [\n (((lambda2 * 180) / Math.PI + 540) % 360) - 180,\n (phi2 * 180) / Math.PI,\n ]; // normalise to −180..+180°\n}\n\nexport { rhumbDestination };\nexport default rhumbDestination;\n"],"mappings":";AAEA;AAAA,EACE;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AACP,SAAS,gBAAgB;AA0BzB,SAAS,iBACP,QACA,UACA,SACA,UAGI,CAAC,GACc;AACnB,QAAM,sBAAsB,WAAW;AACvC,MAAI,mBAAmB;AAAA,IACrB,KAAK,IAAI,QAAQ;AAAA,IACjB,QAAQ;AAAA,IACR;AAAA,EACF;AACA,MAAI;AAAqB,uBAAmB,CAAC,KAAK,IAAI,gBAAgB;AACtE,QAAM,SAAS,SAAS,MAAM;AAC9B,QAAM,cAAc;AAAA,IAClB;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAIA,cAAY,CAAC,KACX,YAAY,CAAC,IAAI,OAAO,CAAC,IAAI,MACzB,OACA,OAAO,CAAC,IAAI,YAAY,CAAC,IAAI,MAC3B,MACA;AACR,SAAO,MAAM,aAAa,QAAQ,UAAU;AAC9C;AAcA,SAAS,0BACP,QACA,UACA,SACA,QACA;AAQA,WAAS,WAAW,SAAY,cAAc,OAAO,MAAM;AAE3D,QAAM,QAAQ,WAAW;AACzB,QAAM,UAAW,OAAO,CAAC,IAAI,KAAK,KAAM;AACxC,QAAM,OAAO,iBAAiB,OAAO,CAAC,CAAC;AACvC,QAAM,QAAQ,iBAAiB,OAAO;AAEtC,QAAM,WAAW,QAAQ,KAAK,IAAI,KAAK;AACvC,MAAI,OAAO,OAAO;AAGlB,MAAI,KAAK,IAAI,IAAI,IAAI,KAAK,KAAK,GAAG;AAChC,WAAO,OAAO,IAAI,KAAK,KAAK,OAAO,CAAC,KAAK,KAAK;AAAA,EAChD;AAEA,QAAM,WAAW,KAAK;AAAA,IACpB,KAAK,IAAI,OAAO,IAAI,KAAK,KAAK,CAAC,IAAI,KAAK,IAAI,OAAO,IAAI,KAAK,KAAK,CAAC;AAAA,EACpE;AAEA,QAAM,IAAI,KAAK,IAAI,QAAQ,IAAI,QAAS,WAAW,WAAW,KAAK,IAAI,IAAI;AAE3E,QAAM,cAAe,QAAQ,KAAK,IAAI,KAAK,IAAK;AAChD,QAAM,UAAU,UAAU;AAE1B,SAAO;AAAA,KACF,UAAU,MAAO,KAAK,KAAK,OAAO,MAAO;AAAA,IAC3C,OAAO,MAAO,KAAK;AAAA,EACtB;AACF;AAGA,IAAO,iCAAQ;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@turf/rhumb-destination",
3
- "version": "7.0.0",
3
+ "version": "7.1.0-alpha.70+948cdafaf",
4
4
  "description": "turf rhumb-destination module",
5
5
  "author": "Turf Authors",
6
6
  "contributors": [
@@ -61,7 +61,7 @@
61
61
  "test:tape": "tsx test.ts"
62
62
  },
63
63
  "devDependencies": {
64
- "@turf/truncate": "^7.0.0",
64
+ "@turf/truncate": "^7.1.0-alpha.70+948cdafaf",
65
65
  "@types/benchmark": "^2.1.5",
66
66
  "@types/tape": "^4.2.32",
67
67
  "benchmark": "^2.1.4",
@@ -74,9 +74,10 @@
74
74
  "write-json-file": "^5.0.0"
75
75
  },
76
76
  "dependencies": {
77
- "@turf/helpers": "^7.0.0",
78
- "@turf/invariant": "^7.0.0",
77
+ "@turf/helpers": "^7.1.0-alpha.70+948cdafaf",
78
+ "@turf/invariant": "^7.1.0-alpha.70+948cdafaf",
79
+ "@types/geojson": "^7946.0.10",
79
80
  "tslib": "^2.6.2"
80
81
  },
81
- "gitHead": "3d3a7917025fbabe191dbddbc89754b86f9c7739"
82
+ "gitHead": "948cdafaf70606d2e27fcc79973fa48ee1182067"
82
83
  }