Skip to content

Instantly share code, notes, and snippets.

@sbis04

sbis04/main.dart Secret

Created May 30, 2020 09:16
Show Gist options
  • Save sbis04/26e6faa8d703fcefc704fad4d2eba492 to your computer and use it in GitHub Desktop.
Save sbis04/26e6faa8d703fcefc704fad4d2eba492 to your computer and use it in GitHub Desktop.
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