Created
June 20, 2020 17:22
Star
You must be signed in to star a gist
Calculate distance of two points
This file contains 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 characters
import 'dart:math' show cos, sqrt, asin; | |
double _coordinateDistance(lat1, lon1, lat2, lon2) { | |
var p = 0.017453292519943295; | |
var c = cos; | |
var a = 0.5 - | |
c((lat2 - lat1) * p) / 2 + | |
c(lat1 * p) * c(lat2 * p) * (1 - c((lon2 - lon1) * p)) / 2; | |
return 12742 * asin(sqrt(a)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment