Skip to content

Commit

Permalink
Fix bug with latlong
Browse files Browse the repository at this point in the history
  • Loading branch information
codergautam committed Dec 28, 2024
1 parent 8a5e12b commit 2d80e51
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions components/calcPoints.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Number.prototype.toRad = function() {
return this * Math.PI / 180;
}
export function findDistance(lat1, lon1, lat2, lon2) {
try {
var R = 6371; // km
var dLat = (lat2-lat1).toRad();
var dLon = (lon2-lon1).toRad();
Expand All @@ -10,6 +11,10 @@ export function findDistance(lat1, lon1, lat2, lon2) {
Math.sin(dLon/2) * Math.sin(dLon/2);
var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
var d = R * c;
} catch(e) {
console.log(e);
return 0;
}
return d;
}
export default function calcPoints({lat, lon, guessLat, guessLon, usedHint, maxDist}) {
Expand Down

0 comments on commit 2d80e51

Please sign in to comment.