geotask
v1.0.9
Published
calculateDistance() is function which calculate the distance between two point. It accept the path of the file which contain object in every single line (as define in requirement) and return the array of the object who is within 100 km and array is sorted
Downloads
6
Readme
This module for find the distance between two points(one point is fixed) which containe latitude and longitude
calculateDistance() is function which calculate the distance between two point. It accept the path of the file which contain object in every single line (as define in requirement) and return the array of the object who is within 100 km and array is sorted in respect of user_id
below is the demo how we can use this function
const { calculateDistance } = require('geotask');
let arr = calculateDistance('./abc.txt');
console.log('value of the arr---', arr);
// abc.txt file is like somewhat
{"latitude": "53.0033946", "user_id": 1104, "name": "Thomas", "longitude": "-6.3877505"}
one line one object
in return you get the array of object like [ { latitude: '53.0033946', user_id: 1104, name: 'Lisa Ahearn', longitude: '-6.3877505', distanceInKm: 38.395, valueInRadian: { latitude: 0.9254560961904762, longitude: -0.11153215158730159 } } ]
two new key added in existing object
1 - distanceInKm - which is sdisplaying the distance from the given point in kilo meter 2 - valueInRadian - convert the latitude and longitude value into radian (which is specially mention in the requirement)