Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
points.forEach((point, index) => {
const nextPoint = points[index + 1];
if(nextPoint && !nextPoint.final == true) {
// calculate distance between each point
const distance = Math.round(GeoLib.getDistance(point, nextPoint));
const bearing = GeoLib.getBearing(point, nextPoint);
if(bearing !== 0) {
if (distance > 1) {
for (var x = 1; x < distance; x++) {
result.push(Object.assign({}, {bearing}, GeoLib.computeDestinationPoint(point, x, bearing)));
}
} else {
result.push(Object.assign({}, {bearing}, point));
}
}
}
function distanceToPath(lat, lon){
let min = 100000; //in KM
let poi = {latitude: lat, longitude: lon};
for (var i = 0; i < pathPoints.length; i++) {
let dist = geolib.getDistance(poi, {latitude: pathPoints[i][0], longitude: pathPoints[i][1]}) / 1000;
if (dist > min) break;
min = dist;
}
return min; //in KM
}
/* eslint-enable no-console */
var sanFran = {latitude: 37.7833, longitude: -122.4167};
var record;
for (var i = 0; i < quakes.length; i++) {
record = {
dsc: quakes[i].properties.title,
url: quakes[i].properties.url,
mag: +quakes[i].properties.mag,
lng: +quakes[i].geometry.coordinates[0],
lat: +quakes[i].geometry.coordinates[1]
};
record.distance = geo.getDistance(record, sanFran) / 1609.34;
recs.push(record);
}
recs.sort(function (a, b) { return a.distance - b.distance; });
fs.writeFile('../../data/earthquakes.json', JSON.stringify(recs), function (err) {
if (err) throw err;
console.log('json saved');
});
json2csv({data: recs, fields: fields}, function (err, csv) {
if (err) console.log(err);
fs.writeFile('../../data/earthquakes.csv', csv, function (err) {
if (err) throw err;
console.log('csv saved');
});
return function(homeLocation) {
var validDMVLocations = [];
for (var dmvName in dmvInfo) {
var distance = geolib.getDistance(
{latitude: homeLocation.lat, longitude: homeLocation.lng},
{latitude: dmvInfo[dmvName].lat, longitude: dmvInfo[dmvName].lng});
var distanceMiles = 0.000621371 * distance;
if (distanceMiles <= maxDistanceMiles) {
var obj = dmvInfo[dmvName];
obj.name = dmvName;
obj.distanceMiles = distanceMiles;
validDMVLocations.push(obj);
}
}
return validDMVLocations;
};
}
{filteredClubs.map(club => (
))}
{searchByLocation &&
_.each(matches, function(match) {
var userLocation = JSON.parse(location);
var matchLocation = JSON.parse(match.latest_location);
var distance = (geolib.getDistance(userLocation, matchLocation)) * 0.000621371 ;//Convert to miles
if ( distance <= searchRadius ) {
match.distance = distance.toFixed(1);
filteredMatches.push(match);
}
});
getDistance: function(origin = {latitude: 0.0, longitude: 0.0}, destination = {latitude: 0.0, longitude: 0.0}) {
var distance = 0;
if (module.exports.isNumeric(origin.latitude) && module.exports.isNumeric(origin.longitude) &&
module.exports.isNumeric(destination.latitude) && module.exports.isNumeric(destination.latitude)) {
distance = Geolib.getDistance(
{latitude: origin.latitude, longitude: origin.longitude},
{latitude: destination.latitude, longitude: destination.longitude}
);
}
return distance;
},
return dispatch => {
if (oldPosition && position &&
geolib.getDistance(position.coords, oldPosition.coords) < 10) {
return
}
dispatch({
type: 'SET_LOCATION_POSITION',
position
})
dispatch(updateLocationCity())
oldPosition = position
}
}
resultArr = resultArr.filter(item => {
return geolib.getDistance(item, filterCenter) <= req.query.radius;
});
}
var distance;
if (order) {
locations = orderResults(locationSetOriginal, point, queryDistance, withDistances, withCoordinates, withHashes, order, accurate, units);
} else {
for (locationName in locationSetOriginal) {
location = locationSetOriginal[locationName];
if (accurate === true) {
distance = geolib.getDistance(point, location, 1);
if (distance > queryDistance) {
continue;
}
location.distance = convertUnitsFromMeters(units, distance);
} else if (withDistances === true) {
distance = geolib.getDistance(point, location, 1);
location.distance = convertUnitsFromMeters(units, distance);
}
if (withHashes === true) {
location.hash = geohash.encode_int(location.latitude, location.longitude, 52);
}
location.key = locationName;
locations.push(location);
}
}
if (typeof count === 'number') {
locations = locations.slice(0, count);
}