We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
LatLngBounds.isOverlapping
1 parent b35130f commit 8089dd8Copy full SHA for 8089dd8
2 files changed
lib/src/geo/latlng_bounds.dart
@@ -307,7 +307,7 @@ class LatLngBounds {
307
delta += 360;
308
}
309
delta = delta.abs();
310
- return delta < longitudeWidth || delta < other.longitudeWidth;
+ return delta < (longitudeWidth + other.longitudeWidth) / 2;
311
312
313
@override
test/geo/latlng_bounds_test.dart
@@ -94,5 +94,35 @@ void main() {
94
expect(center.longitude, (-179.86 + 23.86) / 2);
95
});
96
97
+
98
+ group('isOverlapping', () {
99
+ test('should not overlap', () {
100
+ final bounds1 = LatLngBounds(
101
+ const LatLng(49.622376, 18.286332),
102
+ const LatLng(48.721399, 20.122905),
103
+ );
104
+ final bounds2 = LatLngBounds(
105
+ const LatLng(49.33295874620594, 20.58826958952466),
106
+ const LatLng(49.22512969150049, 20.676160214524646),
107
108
109
+ expect(bounds1.isOverlapping(bounds2), isFalse);
110
+ expect(bounds2.isOverlapping(bounds1), isFalse);
111
+ });
112
113
+ test('should overlap', () {
114
115
+ const LatLng(50, 20),
116
+ const LatLng(51, 21),
117
118
119
+ const LatLng(50.5, 20.5),
120
+ const LatLng(51.5, 21.5),
121
122
123
+ expect(bounds1.isOverlapping(bounds2), isTrue);
124
+ expect(bounds2.isOverlapping(bounds1), isTrue);
125
126
127
128
0 commit comments