Socket
Socket
Sign inDemoInstall

@turf/rhumb-distance

Package Overview
Dependencies
Maintainers
7
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@turf/rhumb-distance - npm Package Compare versions

Comparing version 6.5.0 to 7.0.0-alpha.0

29

dist/es/index.js

@@ -26,6 +26,5 @@ // https://en.wikipedia.org/wiki/Rhumb_line

*/
function rhumbDistance(from, to, options) {
if (options === void 0) { options = {}; }
var origin = getCoord(from);
var destination = getCoord(to);
function rhumbDistance(from, to, options = {}) {
const origin = getCoord(from);
const destination = getCoord(to);
// compensate the crossing of the 180th meridian (https://macwright.org/2016/09/26/the-180th-meridian.html)

@@ -39,4 +38,4 @@ // solution from https://github.com/mapbox/mapbox-gl-js/issues/3250#issuecomment-294887678

: 0;
var distanceInMeters = calculateRhumbDistance(origin, destination);
var distance = convertLength(distanceInMeters, "meters", options.units);
const distanceInMeters = calculateRhumbDistance(origin, destination);
const distance = convertLength(distanceInMeters, "meters", options.units);
return distance;

@@ -68,7 +67,7 @@ }

// see www.edwilliams.org/avform.htm#Rhumb
var R = radius;
var phi1 = (origin[1] * Math.PI) / 180;
var phi2 = (destination[1] * Math.PI) / 180;
var DeltaPhi = phi2 - phi1;
var DeltaLambda = (Math.abs(destination[0] - origin[0]) * Math.PI) / 180;
const R = radius;
const phi1 = (origin[1] * Math.PI) / 180;
const phi2 = (destination[1] * Math.PI) / 180;
const DeltaPhi = phi2 - phi1;
let DeltaLambda = (Math.abs(destination[0] - origin[0]) * Math.PI) / 180;
// if dLon over 180° take shorter rhumb line across the anti-meridian:

@@ -80,9 +79,9 @@ if (DeltaLambda > Math.PI) {

// q becomes ill-conditioned along E-W line (0/0); use empirical tolerance to avoid it
var DeltaPsi = Math.log(Math.tan(phi2 / 2 + Math.PI / 4) / Math.tan(phi1 / 2 + Math.PI / 4));
var q = Math.abs(DeltaPsi) > 10e-12 ? DeltaPhi / DeltaPsi : Math.cos(phi1);
const DeltaPsi = Math.log(Math.tan(phi2 / 2 + Math.PI / 4) / Math.tan(phi1 / 2 + Math.PI / 4));
const q = Math.abs(DeltaPsi) > 10e-12 ? DeltaPhi / DeltaPsi : Math.cos(phi1);
// distance is pythagoras on 'stretched' Mercator projection
var delta = Math.sqrt(DeltaPhi * DeltaPhi + q * q * DeltaLambda * DeltaLambda); // angular distance in radians
var dist = delta * R;
const delta = Math.sqrt(DeltaPhi * DeltaPhi + q * q * DeltaLambda * DeltaLambda); // angular distance in radians
const dist = delta * R;
return dist;
}
export default rhumbDistance;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
// https://en.wikipedia.org/wiki/Rhumb_line
var helpers_1 = require("@turf/helpers");
var invariant_1 = require("@turf/invariant");
const helpers_1 = require("@turf/helpers");
const invariant_1 = require("@turf/invariant");
/**

@@ -28,6 +28,5 @@ * Calculates the distance along a rhumb line between two {@link Point|points} in degrees, radians,

*/
function rhumbDistance(from, to, options) {
if (options === void 0) { options = {}; }
var origin = invariant_1.getCoord(from);
var destination = invariant_1.getCoord(to);
function rhumbDistance(from, to, options = {}) {
const origin = invariant_1.getCoord(from);
const destination = invariant_1.getCoord(to);
// compensate the crossing of the 180th meridian (https://macwright.org/2016/09/26/the-180th-meridian.html)

@@ -41,4 +40,4 @@ // solution from https://github.com/mapbox/mapbox-gl-js/issues/3250#issuecomment-294887678

: 0;
var distanceInMeters = calculateRhumbDistance(origin, destination);
var distance = helpers_1.convertLength(distanceInMeters, "meters", options.units);
const distanceInMeters = calculateRhumbDistance(origin, destination);
const distance = helpers_1.convertLength(distanceInMeters, "meters", options.units);
return distance;

@@ -70,7 +69,7 @@ }

// see www.edwilliams.org/avform.htm#Rhumb
var R = radius;
var phi1 = (origin[1] * Math.PI) / 180;
var phi2 = (destination[1] * Math.PI) / 180;
var DeltaPhi = phi2 - phi1;
var DeltaLambda = (Math.abs(destination[0] - origin[0]) * Math.PI) / 180;
const R = radius;
const phi1 = (origin[1] * Math.PI) / 180;
const phi2 = (destination[1] * Math.PI) / 180;
const DeltaPhi = phi2 - phi1;
let DeltaLambda = (Math.abs(destination[0] - origin[0]) * Math.PI) / 180;
// if dLon over 180° take shorter rhumb line across the anti-meridian:

@@ -82,9 +81,9 @@ if (DeltaLambda > Math.PI) {

// q becomes ill-conditioned along E-W line (0/0); use empirical tolerance to avoid it
var DeltaPsi = Math.log(Math.tan(phi2 / 2 + Math.PI / 4) / Math.tan(phi1 / 2 + Math.PI / 4));
var q = Math.abs(DeltaPsi) > 10e-12 ? DeltaPhi / DeltaPsi : Math.cos(phi1);
const DeltaPsi = Math.log(Math.tan(phi2 / 2 + Math.PI / 4) / Math.tan(phi1 / 2 + Math.PI / 4));
const q = Math.abs(DeltaPsi) > 10e-12 ? DeltaPhi / DeltaPsi : Math.cos(phi1);
// distance is pythagoras on 'stretched' Mercator projection
var delta = Math.sqrt(DeltaPhi * DeltaPhi + q * q * DeltaLambda * DeltaLambda); // angular distance in radians
var dist = delta * R;
const delta = Math.sqrt(DeltaPhi * DeltaPhi + q * q * DeltaLambda * DeltaLambda); // angular distance in radians
const dist = delta * R;
return dist;
}
exports.default = rhumbDistance;
{
"name": "@turf/rhumb-distance",
"version": "6.5.0",
"version": "7.0.0-alpha.0",
"description": "turf rhumb-distance module",

@@ -57,3 +57,3 @@ "author": "Turf Authors",

"devDependencies": {
"@turf/distance": "^6.5.0",
"@turf/distance": "^7.0.0-alpha.0",
"@types/tape": "*",

@@ -70,6 +70,7 @@ "benchmark": "*",

"dependencies": {
"@turf/helpers": "^6.5.0",
"@turf/invariant": "^6.5.0"
"@turf/helpers": "^7.0.0-alpha.0",
"@turf/invariant": "^7.0.0-alpha.0",
"tslib": "^2.3.0"
},
"gitHead": "5375941072b90d489389db22b43bfe809d5e451e"
"gitHead": "0edc4c491b999e5ace770a61e1cf549f7c004189"
}

@@ -10,11 +10,12 @@ # @turf/rhumb-distance

**Parameters**
### Parameters
- `from` **[Coord][2]** origin point
- `to` **[Coord][2]** destination point
- `options` **[Object][3]?** Optional parameters
- `options.units` **[string][4]** can be degrees, radians, miles, or kilometers (optional, default `"kilometers"`)
* `from` **[Coord][2]** origin point
* `to` **[Coord][2]** destination point
* `options` **[Object][3]?** Optional parameters
**Examples**
* `options.units` **[string][4]** can be degrees, radians, miles, or kilometers (optional, default `"kilometers"`)
### Examples
```javascript

@@ -21,0 +22,0 @@ var from = turf.point([-75.343, 39.984]);

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc