Open wil93 opened 5 years ago
There are updates about this?
In my case, I just used a custom class for this:
class GreatCircleDistance {
final double R = 6371000; // radius of Earth, in meters
double latitude1, longitude1;
double latitude2, longitude2;
GreatCircleDistance({this.latitude1, this.latitude2, this.longitude1, this.longitude2});
double distance() {
double phi1 = this.latitude1 * pi / 180; // φ1
double phi2 = this.latitude2 * pi / 180; // φ2
var deltaPhi = (this.latitude2 - this.latitude1) * pi / 180; // Δφ
var deltaLambda = (this.longitude2 - this.longitude1) * pi / 180; // Δλ
var a = sin(deltaPhi / 2) * sin(deltaPhi / 2) +
cos(phi1) * cos(phi2) * sin(deltaLambda / 2) * sin(deltaLambda / 2);
var c = 2 * atan2(sqrt(a), sqrt(1 - a));
return R * c;
}
}
See https://github.com/wil93/ranky/blob/master/lib/data.dart#L86
This looks good. Thank you for that.
Apparently Dart has renamed the
PI
constant in 'dart:math', it is now namedpi
.See: https://api.dart.dev/stable/2.4.0/dart-math/pi-constant.html
When using haversine package I am getting this error: