1.0.0 • Published 25 days ago

geo-route v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
25 days ago

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