Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
qwerty108109 committed Oct 24, 2023
1 parent 7d0aea0 commit e203f57
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
18 changes: 9 additions & 9 deletions lib/src/longitude_and_latitude_calculator_base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@ import 'dart:math' show cos, sqrt, asin;

/// Checks if you are awesome. Spoiler: you are.
class LonAndLatDistance {


double lonAndLatDistance ({double lat1 = 34.052235,double lon1 = -118.243683,double lat2 = 40.754932,double lon2 = -73.984016,bool km = false}){
double lonAndLatDistance(
{double lat1 = 34.052235,
double lon1 = -118.243683,
double lat2 = 40.754932,
double lon2 = -73.984016,
bool km = false}) {
var p = 0.017453292519943295;
var a = 0.5 - cos((lat2 - lat1) * p)/2 +
cos(lat1 * p) * cos(lat2 * p) *
(1 - cos((lon2 - lon1) * p))/2;
var a = 0.5 -
cos((lat2 - lat1) * p) / 2 +
cos(lat1 * p) * cos(lat2 * p) * (1 - cos((lon2 - lon1) * p)) / 2;
if (km == true) {
return 12742 * asin(sqrt(a));
} else {
return (12742 * asin(sqrt(a))) * 0.621371;
}
}



}
1 change: 0 additions & 1 deletion test/longitude_and_latitude_calculator_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ void main() {
lon2: -73.984016,
km: false);
expect(miles, 2446.519306778203);

});
});
}

0 comments on commit e203f57

Please sign in to comment.