@@ -47,5 +47,52 @@ void main() {
4747 expect (bounds1.hashCode, bounds2.hashCode);
4848 });
4949 });
50+
51+ group ('center' , () {
52+ // cf. https://github.com/fleaflet/flutter_map/issues/1689
53+ test ('should calculate center point #1' , () async {
54+ final bounds = LatLngBounds (
55+ const LatLng (- 77.45 , - 171.16 ),
56+ const LatLng (46.64 , 25.88 ),
57+ );
58+ final center = bounds.center;
59+ expect (center.latitude, greaterThanOrEqualTo (- 90 ));
60+ expect (center.latitude, lessThanOrEqualTo (90 ));
61+ expect (center.longitude, greaterThanOrEqualTo (- 180 ));
62+ expect (center.longitude, lessThanOrEqualTo (180 ));
63+ });
64+ test ('should calculate center point #2' , () async {
65+ final bounds = LatLngBounds (
66+ const LatLng (- 0.87 , - 179.86 ),
67+ const LatLng (84.92 , 23.86 ),
68+ );
69+ final center = bounds.center;
70+ expect (center.latitude, greaterThanOrEqualTo (- 90 ));
71+ expect (center.latitude, lessThanOrEqualTo (90 ));
72+ expect (center.longitude, greaterThanOrEqualTo (- 180 ));
73+ expect (center.longitude, lessThanOrEqualTo (180 ));
74+ });
75+ });
76+
77+ group ('simpleCenter' , () {
78+ test ('should calculate center point #1' , () async {
79+ final bounds = LatLngBounds (
80+ const LatLng (- 77.45 , - 171.16 ),
81+ const LatLng (46.64 , 25.88 ),
82+ );
83+ final center = bounds.simpleCenter;
84+ expect (center.latitude, (- 77.45 + 46.64 ) / 2 );
85+ expect (center.longitude, (- 171.16 + 25.88 ) / 2 );
86+ });
87+ test ('should calculate center point #2' , () async {
88+ final bounds = LatLngBounds (
89+ const LatLng (- 0.87 , - 179.86 ),
90+ const LatLng (84.92 , 23.86 ),
91+ );
92+ final center = bounds.simpleCenter;
93+ expect (center.latitude, (- 0.87 + 84.92 ) / 2 );
94+ expect (center.longitude, (- 179.86 + 23.86 ) / 2 );
95+ });
96+ });
5097 });
5198}
0 commit comments