Created
May 1, 2021 10:51
-
-
Save BABAK0T0/7cd851b4a2ff29814210ca55a2b780a7 to your computer and use it in GitHub Desktop.
Revisions
-
BABAK0T0 created this gist
May 1, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,7 @@ const EARTH_RADIUS = 6371; // Earth radius in km function distanceBetweenTwoCoordinates(lonA, latA, lonB, latB) { const x = (lonB - lonA) * Math.cos((latA + latB) / 2); const y = (latB - latA); return Math.sqrt( x**2 + y**2 ) * EARTH_RADIUS; }