@turf/distance
Advanced tools
Comparing version 4.7.3 to 5.0.0
@@ -1,12 +0,12 @@ | ||
/// <reference types="geojson" /> | ||
import { Units, Point, Feature, Position } from '@turf/helpers' | ||
import {Units} from '@turf/helpers' | ||
type Point = GeoJSON.Feature<GeoJSON.Point> | GeoJSON.Point | number[]; | ||
/** | ||
* http://turfjs.org/docs/#distance | ||
*/ | ||
declare function distance(from: Point, to: Point, units?: Units): number; | ||
declare namespace distance { } | ||
export = distance; | ||
export default function distance( | ||
from: Feature<Point> | Point | Position, | ||
to: Feature<Point> | Point | Position, | ||
options?: { | ||
units?: Units | ||
} | ||
): number; |
17
index.js
@@ -1,3 +0,4 @@ | ||
var getCoord = require('@turf/invariant').getCoord; | ||
var radiansToDistance = require('@turf/helpers').radiansToDistance; | ||
import { getCoord } from '@turf/invariant'; | ||
import { radiansToDistance } from '@turf/helpers'; | ||
//http://en.wikipedia.org/wiki/Haversine_formula | ||
@@ -15,3 +16,4 @@ //http://www.movable-type.co.uk/scripts/latlong.html | ||
* @param {Geometry|Feature<Point>|Array<number>} to destination point | ||
* @param {string} [units=kilometers] can be degrees, radians, miles, or kilometers | ||
* @param {Object} [options={}] Optional parameters | ||
* @param {string} [options.units='kilometers'] can be degrees, radians, miles, or kilometers | ||
* @returns {number} distance between the two points | ||
@@ -29,3 +31,6 @@ * @example | ||
*/ | ||
module.exports = function (from, to, units) { | ||
function distance(from, to, options) { | ||
// Backwards compatible with v4.0 | ||
var units = (typeof options === 'object') ? options.units : options; | ||
var degrees2radians = Math.PI / 180; | ||
@@ -43,2 +48,4 @@ var coordinates1 = getCoord(from); | ||
return radiansToDistance(2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)), units); | ||
}; | ||
} | ||
export default distance; |
{ | ||
"name": "@turf/distance", | ||
"version": "4.7.3", | ||
"version": "5.0.0", | ||
"description": "turf distance module", | ||
"main": "index.js", | ||
"main": "main", | ||
"module": "index", | ||
"jsnext:main": "index", | ||
"types": "index.d.ts", | ||
"files": [ | ||
"index.js", | ||
"index.d.ts" | ||
"index.d.ts", | ||
"main.js" | ||
], | ||
"scripts": { | ||
"test": "node test.js", | ||
"bench": "node bench.js" | ||
"pretest": "rollup -c ../../rollup.config.js", | ||
"test": "node -r @std/esm test.js", | ||
"posttest": "uglifyjs main.js -o main.min.js", | ||
"bench": "node -r @std/esm bench.js" | ||
}, | ||
@@ -32,11 +37,18 @@ "repository": { | ||
"devDependencies": { | ||
"benchmark": "^2.1.4", | ||
"load-json-file": "^2.0.0", | ||
"tape": "^4.6.3", | ||
"write-json-file": "^2.0.0" | ||
"benchmark": "*", | ||
"load-json-file": "*", | ||
"tape": "*", | ||
"write-json-file": "*", | ||
"rollup": "*", | ||
"@std/esm": "*", | ||
"uglify-js": "*" | ||
}, | ||
"dependencies": { | ||
"@turf/helpers": "^4.7.3", | ||
"@turf/invariant": "^4.7.3" | ||
"@turf/helpers": "5.0.0", | ||
"@turf/invariant": "5.0.0" | ||
}, | ||
"@std/esm": { | ||
"esm": "js", | ||
"cjs": true | ||
} | ||
} |
# @turf/distance | ||
# distance | ||
<!-- Generated by documentation.js. Update this documentation by updating the source code. --> | ||
## distance | ||
Calculates the distance between two [points](http://geojson.org/geojson-spec.html#point) in degrees, radians, | ||
@@ -14,3 +16,3 @@ miles, or kilometers. This uses the | ||
- `to` **([Geometry](http://geojson.org/geojson-spec.html#geometry) \| [Feature](http://geojson.org/geojson-spec.html#feature-objects)<[Point](http://geojson.org/geojson-spec.html#point)> | [Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)<[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)>)** destination point | ||
- `units` **\[[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** can be degrees, radians, miles, or kilometers (optional, default `kilometers`) | ||
- `units` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** can be degrees, radians, miles, or kilometers (optional, default `kilometers`) | ||
@@ -17,0 +19,0 @@ **Examples** |
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
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
8641
6
97
58
7
+ Added@turf/helpers@5.0.0(transitive)
+ Added@turf/invariant@5.0.0(transitive)
- Removed@turf/helpers@4.7.3(transitive)
- Removed@turf/invariant@4.7.3(transitive)
Updated@turf/helpers@5.0.0
Updated@turf/invariant@5.0.0