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

Simplify unnecessary union type in turfDistance #2618

Merged
merged 1 commit into from
Jun 13, 2024
Merged
Changes from all commits
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
13 changes: 6 additions & 7 deletions packages/turf-distance/index.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
import { Point } from "geojson";
import { getCoord } from "@turf/invariant";
import { radiansToLength, degreesToRadians, Coord, Units } from "@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.
* Calculates the distance between two {@link Coord|coordinates} in degrees, radians, miles, or kilometers.
* This uses the [Haversine formula](http://en.wikipedia.org/wiki/Haversine_formula) to account for global curvature.
*
* @name distance
* @param {Coord | Point} from origin point or coordinate
* @param {Coord | Point} to destination point or coordinate
* @param {Coord} from origin coordinate
* @param {Coord} to destination 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
* @returns {number} distance between the two coordinates
* @example
* var from = turf.point([-75.343, 39.984]);
* var to = turf.point([-75.534, 39.123]);
Expand All @@ -28,8 +27,8 @@ import { radiansToLength, degreesToRadians, Coord, Units } from "@turf/helpers";
* to.properties.distance = distance;
*/
function distance(
from: Coord | Point,
to: Coord | Point,
from: Coord,
to: Coord,
options: {
units?: Units;
} = {}
Expand Down
Loading