Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

geo-route

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

geo-route

Calculate distances between GPS coordinates using the Haversine formula

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

Route Distance Calculator A Node.js package for calculating distances between GPS coordinates using the Haversine formula. This package can be used to estimate travel distances based on a series of waypoints or locations along a geo.

Installation To use the Route Distance Calculator package in your Node.js project, you can install it via npm:

bash Copy code npm install geo-route Usage Importing the Package javascript Copy code const RouteCalculator = require('geo-route'); Using the Functions

  1. Haversine Calculation The haversine method calculates the great-circle distance between two points on the Earth's surface using their latitude and longitude coordinates.

javascript Copy code const distance = RouteCalculator.haversine(lat1, lon1, lat2, lon2); 2. Find Location within Range The findLocation method takes a starting point, a geo (array of waypoints with latitude, longitude, and optional place name), and a range (in meters). It calculates the total distance traveled along the geo within the specified range and returns the nearest location within that range.

javascript Copy code const location = RouteCalculator.findLocation(startPoint, geo, range); Example javascript Copy code const RouteCalculator = require('geo-route');

const startPoint = [28.582769375987805, 77.32807517051698]; const geo = [ { lat: 28.583117962750734, lng: 77.32767820358278, place: "A" }, { lat: 28.582726980221604, lng: 77.3271417617798, place: "B" }, { lat: 28.58241607741395, lng: 77.32751190662385, place: "C" }, { lat: 28.58282119301215, lng: 77.32810735702515, place: "D" }, { lat: 28.582420788069395, lng: 77.3285096883774, place: "E" } ]; const range = 15; // 15 meters

const location = RouteCalculator.findLocation(startPoint, geo, range); console.log(location); License This project is licensed under the MIT License - see the LICENSE file for details.

Contributing Contributions are welcome! Please open an issue or submit a pull request to suggest changes or improvements.

Bugs/Issues If you encounter any bugs or issues, please report them on the GitHub Issues page.

Author Saurabh Singh

Keywords

FAQs

Package last updated on 12 Apr 2024

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc