@turf/distance
Advanced tools
Comparing version 5.1.5 to 6.0.0
41
index.js
@@ -1,12 +0,10 @@ | ||
import { getCoord } from '@turf/invariant'; | ||
import { radiansToLength, isObject, degreesToRadians } from '@turf/helpers'; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var invariant_1 = require("@turf/invariant"); | ||
var helpers_1 = require("@turf/helpers"); | ||
//http://en.wikipedia.org/wiki/Haversine_formula | ||
//http://www.movable-type.co.uk/scripts/latlong.html | ||
/** | ||
* Calculates the distance between two {@link Point|points} in degrees, radians, | ||
* miles, or kilometers. This uses the | ||
* [Haversine formula](http://en.wikipedia.org/wiki/Haversine_formula) | ||
* to account for global curvature. | ||
* Calculates the distance between two {@link Point|points} in degrees, radians, miles, or kilometers. | ||
* This uses the [Haversine formula](http://en.wikipedia.org/wiki/Haversine_formula) to account for global curvature. | ||
* | ||
@@ -32,20 +30,13 @@ * @name distance | ||
function distance(from, to, options) { | ||
// Optional parameters | ||
options = options || {}; | ||
if (!isObject(options)) throw new Error('options is invalid'); | ||
var units = options.units; | ||
var coordinates1 = getCoord(from); | ||
var coordinates2 = getCoord(to); | ||
var dLat = degreesToRadians((coordinates2[1] - coordinates1[1])); | ||
var dLon = degreesToRadians((coordinates2[0] - coordinates1[0])); | ||
var lat1 = degreesToRadians(coordinates1[1]); | ||
var lat2 = degreesToRadians(coordinates2[1]); | ||
if (options === void 0) { options = {}; } | ||
var coordinates1 = invariant_1.getCoord(from); | ||
var coordinates2 = invariant_1.getCoord(to); | ||
var dLat = helpers_1.degreesToRadians((coordinates2[1] - coordinates1[1])); | ||
var dLon = helpers_1.degreesToRadians((coordinates2[0] - coordinates1[0])); | ||
var lat1 = helpers_1.degreesToRadians(coordinates1[1]); | ||
var lat2 = helpers_1.degreesToRadians(coordinates2[1]); | ||
var a = Math.pow(Math.sin(dLat / 2), 2) + | ||
Math.pow(Math.sin(dLon / 2), 2) * Math.cos(lat1) * Math.cos(lat2); | ||
return radiansToLength(2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)), units); | ||
Math.pow(Math.sin(dLon / 2), 2) * Math.cos(lat1) * Math.cos(lat2); | ||
return helpers_1.radiansToLength(2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)), options.units); | ||
} | ||
export default distance; | ||
exports.default = distance; |
{ | ||
"name": "@turf/distance", | ||
"version": "5.1.5", | ||
"version": "6.0.0", | ||
"description": "turf 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" | ||
@@ -38,6 +34,5 @@ }, | ||
"devDependencies": { | ||
"@std/esm": "*", | ||
"benchmark": "*", | ||
"load-json-file": "*", | ||
"rollup": "*", | ||
"typescript": "*", | ||
"tape": "*", | ||
@@ -47,9 +42,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
5
7549
5
84
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