@turf/rhumb-distance
Advanced tools
Comparing version 5.1.5 to 6.0.0
38
index.js
@@ -0,5 +1,6 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
// https://en.wikipedia.org/wiki/Rhumb_line | ||
import { convertLength, earthRadius, isObject } from '@turf/helpers'; | ||
import { getCoord } from '@turf/invariant'; | ||
var helpers_1 = require("@turf/helpers"); | ||
var invariant_1 = require("@turf/invariant"); | ||
/** | ||
@@ -28,14 +29,5 @@ * Calculates the distance along a rhumb line between two {@link Point|points} in degrees, radians, | ||
function rhumbDistance(from, to, options) { | ||
// Optional parameters | ||
options = options || {}; | ||
if (!isObject(options)) throw new Error('options is invalid'); | ||
var units = options.units; | ||
// validation | ||
if (!from) throw new Error('from point is required'); | ||
if (!to) throw new Error('to point is required'); | ||
var origin = getCoord(from); | ||
var destination = getCoord(to); | ||
if (options === void 0) { options = {}; } | ||
var origin = invariant_1.getCoord(from); | ||
var destination = invariant_1.getCoord(to); | ||
// compensate the crossing of the 180th meridian (https://macwright.org/2016/09/26/the-180th-meridian.html) | ||
@@ -45,6 +37,5 @@ // solution from https://github.com/mapbox/mapbox-gl-js/issues/3250#issuecomment-294887678 | ||
var distanceInMeters = calculateRhumbDistance(origin, destination); | ||
var distance = convertLength(distanceInMeters, 'meters', units); | ||
var distance = helpers_1.convertLength(distanceInMeters, 'meters', options.units); | ||
return distance; | ||
} | ||
/** | ||
@@ -72,6 +63,4 @@ * Returns the distance travelling from ‘this’ point to destination point along a rhumb line. | ||
// θ => theta | ||
radius = (radius === undefined) ? earthRadius : Number(radius); | ||
radius = (radius === undefined) ? helpers_1.earthRadius : Number(radius); | ||
// see www.edwilliams.org/avform.htm#Rhumb | ||
var R = radius; | ||
@@ -83,4 +72,4 @@ var phi1 = origin[1] * Math.PI / 180; | ||
// if dLon over 180° take shorter rhumb line across the anti-meridian: | ||
if (DeltaLambda > Math.PI) DeltaLambda -= 2 * Math.PI; | ||
if (DeltaLambda > Math.PI) | ||
DeltaLambda -= 2 * Math.PI; | ||
// on Mercator projection, longitude distances shrink by latitude; q is the 'stretch factor' | ||
@@ -90,10 +79,7 @@ // q becomes ill-conditioned along E-W line (0/0); use empirical tolerance to avoid it | ||
var 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; | ||
return dist; | ||
} | ||
export default rhumbDistance; | ||
exports.default = rhumbDistance; |
{ | ||
"name": "@turf/rhumb-distance", | ||
"version": "5.1.5", | ||
"version": "6.0.0", | ||
"description": "turf rhumb-distance module", | ||
"main": "main.js", | ||
"module": "main.es.js", | ||
"types": "index.d.ts", | ||
"main": "index", | ||
"files": [ | ||
"index.js", | ||
"index.d.ts", | ||
"main.js", | ||
"main.es.js" | ||
"index.ts" | ||
], | ||
"scripts": { | ||
"pretest": "rollup -c ../../rollup.config.js", | ||
"test": "node -r @std/esm test.js", | ||
"posttest": "node -r @std/esm ../../scripts/validate-es5-dependencies.js", | ||
"bench": "node -r @std/esm bench.js", | ||
"prepare": "tsc", | ||
"pretest": "tsc", | ||
"test": "node test.js", | ||
"bench": "node bench.js", | ||
"docs": "node ../../scripts/generate-readmes" | ||
@@ -46,7 +42,6 @@ }, | ||
"devDependencies": { | ||
"@std/esm": "*", | ||
"@turf/distance": "^5.1.5", | ||
"@turf/distance": "*", | ||
"benchmark": "*", | ||
"load-json-file": "*", | ||
"rollup": "*", | ||
"typescript": "*", | ||
"tape": "*", | ||
@@ -56,9 +51,5 @@ "write-json-file": "*" | ||
"dependencies": { | ||
"@turf/helpers": "^5.1.5", | ||
"@turf/invariant": "^5.1.5" | ||
}, | ||
"@std/esm": { | ||
"esm": "js", | ||
"cjs": true | ||
"@turf/helpers": "6.x", | ||
"@turf/invariant": "6.x" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6
11224
5
158
1
+ Added@turf/helpers@6.5.0(transitive)
+ Added@turf/invariant@6.5.0(transitive)
- Removed@turf/helpers@5.1.5(transitive)
- Removed@turf/invariant@5.2.0(transitive)
Updated@turf/helpers@6.x
Updated@turf/invariant@6.x