What is @turf/rhumb-destination?
@turf/rhumb-destination is a module from the Turf.js library that allows you to calculate the destination point given a starting point, distance, and bearing using rhumb lines. Rhumb lines are paths of constant bearing, which are useful for navigation and mapping applications.
What are @turf/rhumb-destination's main functionalities?
Calculate Rhumb Line Destination
This feature allows you to calculate the destination point from a given starting point, distance, and bearing using rhumb lines. The code sample demonstrates how to use the `rhumbDestination` function to find a point 50 kilometers east of the starting point.
const turf = require('@turf/turf');
const start = turf.point([-75.343, 39.984]);
const distance = 50;
const bearing = 90;
const units = 'kilometers';
const destination = turf.rhumbDestination(start, distance, bearing, {units: units});
console.log(destination);
Other packages similar to @turf/rhumb-destination
geolib
Geolib is a library for geospatial calculations. It provides functions for distance calculations, finding the center of a collection of points, and more. Unlike @turf/rhumb-destination, Geolib does not specifically focus on rhumb lines but offers a broader range of geospatial utilities.
geodesy
Geodesy is a library for geodesic calculations. It includes functions for calculating distances, bearings, and destinations on the Earth's surface. While it provides more general geodesic calculations, it does not specifically focus on rhumb lines like @turf/rhumb-destination.
spherical-geometry-js
Spherical Geometry is a library for performing spherical geometry calculations, including distance and area calculations on the Earth's surface. It focuses on spherical rather than rhumb line calculations, making it different from @turf/rhumb-destination.
@turf/rhumb-destination
rhumbDestination
Returns the destination Point having travelled the given distance along a Rhumb line from the
origin Point with the (constant) given bearing.
Parameters
origin
(Geometry | Feature<Point> | Array<number>) starting pointdistance
number distance from the starting pointbearing
number constant bearing angle ranging from -180 to 180 degrees from northunits
[string] miles, kilometers, degrees, or radians (optional, default kilometers
)
Examples
var point = {
"type": "Feature",
"properties": {
"marker-color": "F00"
},
"geometry": {
"type": "Point",
"coordinates": [-75.343, 39.984]
}
};
var distance = 50;
var bearing = 90;
var units = 'miles';
var destination = turf.rhumbDestination(point, distance, bearing, units);
destination.properties['marker-color'] = '#00F';
var addToMap = [point, destination]
Returns Feature<Point> Destination point.
This module is part of the Turfjs project, an open source
module collection dedicated to geographic algorithms. It is maintained in the
Turfjs/turf repository, where you can create
PRs and issues.
Installation
Install this module individually:
$ npm install @turf/rhumb-destination
Or install the Turf module that includes it as a function:
$ npm install @turf/turf