Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update distance docs #2032

Merged
merged 2 commits into from
Feb 14, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions packages/turf-distance/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import { getCoord } from "@turf/invariant";
import { radiansToLength, degreesToRadians, Coord, Units } from "@turf/helpers";
import {
radiansToLength,
degreesToRadians,
Coord,
Units,
Point,
} from "@turf/helpers";

//http://en.wikipedia.org/wiki/Haversine_formula
//http://www.movable-type.co.uk/scripts/latlong.html
Expand All @@ -9,8 +15,8 @@ import { radiansToLength, degreesToRadians, Coord, Units } from "@turf/helpers";
* This uses the [Haversine formula](http://en.wikipedia.org/wiki/Haversine_formula) to account for global curvature.
*
* @name distance
* @param {Coord} from origin point
* @param {Coord} to destination point
* @param {Coord | Point} from origin point or coordinate
* @param {Coord | Point} to destination point or coordinate
* @param {Object} [options={}] Optional parameters
* @param {string} [options.units='kilometers'] can be degrees, radians, miles, or kilometers
* @returns {number} distance between the two points
Expand All @@ -27,8 +33,8 @@ import { radiansToLength, degreesToRadians, Coord, Units } from "@turf/helpers";
* to.properties.distance = distance;
*/
function distance(
from: Coord,
to: Coord,
from: Coord | Point,
to: Coord | Point,
options: {
units?: Units;
} = {}
Expand Down