11import 'dart:math' ;
2- import 'dart:ui' ;
32
43import 'package:google_maps_flutter_platform_interface/google_maps_flutter_platform_interface.dart' ;
54
6- import 'cluster.dart' ;
7-
8- const int _mio = 1000000 ;
9- const int _thd = 1000 ;
10- const double _PI = 3.141592653589793238 ;
11-
12- class _Tuple {
13- final LatLng pos1;
14- final LatLng pos2;
15-
16- _Tuple (this .pos1, this .pos2);
17-
18- bool operator == (o) => o is _Tuple && pos1 == o.pos1 && pos2 == o.pos2;
19- int get hashCode => pos1.hashCode + pos2.hashCode;
20- }
21-
225class DistUtils {
236// Zoom-Level:
247// Level # Tiles Tile width
@@ -47,18 +30,18 @@ class DistUtils {
4730// 18 68 719 476 736 0.001 0.596 1:2 thousand some buildings, trees
4831// 19 274 877 906 944 0.0005 0.298 1:1 thousand local highway and crossing details
4932// 20 1 099 511 627 776 0.00025 0.149 1:5 hundred A mid-sized building
50- final Map <_Tuple , double > distCache = {};
33+ final Map <( LatLng , LatLng ) , double > distCache = {};
5134
5235 double getLatLonDist (LatLng point1, LatLng point2, int zoomLevel) {
53- if (distCache[_Tuple (point1, point2)] != null ) {
54- return distCache[_Tuple (point1, point2)]! ;
36+ if (distCache[(point1, point2)] != null ) {
37+ return distCache[(point1, point2)]! ;
5538 }
5639 double meterPerPixel = _getScalingFactor (zoomLevel);
5740 double dist = getDistanceFromLatLonInKm (point1.latitude, point1.longitude,
5841 point2.latitude, point2.longitude) /
59- (meterPerPixel / _thd );
42+ (meterPerPixel / 1000 );
6043 // print("dist is $x");
61- distCache[_Tuple (point1, point2)] = dist;
44+ distCache[(point1, point2)] = dist;
6245 return dist;
6346 }
6447
@@ -78,7 +61,7 @@ class DistUtils {
7861 }
7962
8063 double _degreeToRadian (double degree) {
81- return degree * _PI / 180 ;
64+ return degree * pi / 180 ;
8265 }
8366
8467 double _getScalingFactor (int zoomLevel) {
0 commit comments