Security News
Cloudflare Adds Security.txt Setup Wizard
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
@turf/rhumb-distance
Advanced tools
@turf/rhumb-distance is a module from the Turf.js library that calculates the rhumb line distance between two geographical points. A rhumb line is a path of constant bearing, which is different from the shortest path (great-circle distance) on a sphere. This package is useful for applications that require consistent bearing, such as navigation and mapping.
Calculate Rhumb Distance
This feature calculates the rhumb line distance between two geographical points. The `units` option allows you to specify the unit of measurement, such as miles, kilometers, etc.
const turf = require('@turf/turf');
const point1 = turf.point([-75.343, 39.984]);
const point2 = turf.point([-75.534, 39.123]);
const options = { units: 'miles' };
const distance = turf.rhumbDistance(point1, point2, options);
console.log(distance);
Geolib is a library for geospatial calculations. It provides various methods for distance calculations, including great-circle distance and rhumb line distance. Compared to @turf/rhumb-distance, Geolib offers a broader range of geospatial functions but may not be as specialized in rhumb line calculations.
Geodesy is a library that provides tools for geodesic calculations. It includes methods for calculating distances, bearings, and other geospatial properties. While it offers comprehensive geodesic calculations, it may require more configuration compared to the straightforward usage of @turf/rhumb-distance.
Calculates the distance along a rhumb line between two points in degrees, radians, miles, or kilometers.
Parameters
from
(Geometry | Feature<Point> | Array<number>) origin pointto
(Geometry | Feature<Point> | Array<number>) destination pointunits
[string] can be degrees, radians, miles, or kilometers (optional, default kilometers
)Examples
var from = turf.point([-75.343, 39.984]);
var to = turf.point([-75.534, 39.123]);
var distance = turf.rhumbDistance(from, to, "miles");
//addToMap
var addToMap = [from, to];
from.properties.distance = distance;
to.properties.distance = distance;
Returns number distance between the two points
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.
Install this module individually:
$ npm install @turf/rhumb-distance
Or install the Turf module that includes it as a function:
$ npm install @turf/turf
FAQs
turf rhumb-distance module
The npm package @turf/rhumb-distance receives a total of 559,700 weekly downloads. As such, @turf/rhumb-distance popularity was classified as popular.
We found that @turf/rhumb-distance demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 9 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.
Security News
ENISA’s 2024 report highlights the EU’s top cybersecurity threats, including rising DDoS attacks, ransomware, supply chain vulnerabilities, and weaponized AI.