Skip to content

Commit 5e7ed48

Browse files
committed
Compares lng and lat instead of array value to ensure correct usage regardless of dimensions
1 parent 7623f12 commit 5e7ed48

2 files changed

Lines changed: 12 additions & 8 deletions

File tree

lib/src/booleans/boolean_contains.dart

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,13 @@ bool _isPolyInPoly(GeoJSONObject geom1, GeoJSONObject geom2) {
8585
return true;
8686
}
8787

88+
/// True when [bbox1] contains [bbox2] in longitude and latitude (RFC 7946 order).
89+
/// Uses [BBox] getters so four- and six-number bboxes both resolve correctly.
8890
bool _doBBoxesOverlap(BBox bbox1, BBox bbox2) {
89-
if (bbox1[0]! > bbox2[0]! ||
90-
bbox1[2]! < bbox2[2]! ||
91-
bbox1[1]! > bbox2[1]! ||
92-
bbox1[3]! < bbox2[3]!) {
91+
if (bbox1.lng1 > bbox2.lng1 ||
92+
bbox1.lng2 < bbox2.lng2 ||
93+
bbox1.lat1 > bbox2.lat1 ||
94+
bbox1.lat2 < bbox2.lat2) {
9395
return false;
9496
}
9597

lib/src/booleans/boolean_helper.dart

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,11 +179,13 @@ bool _isLineCrossingThePolygon(LineString line, GeoJSONObject polygon) {
179179
);
180180
}
181181

182+
/// True when [bbox1] contains [bbox2] in longitude and latitude (RFC 7946 order).
183+
/// Uses [BBox] getters so four- and six-number bboxes both resolve correctly.
182184
bool _doBBoxesOverlap(BBox bbox1, BBox bbox2) {
183-
if (bbox1[0]! > bbox2[0]!) return false;
184-
if (bbox1[2]! < bbox2[2]!) return false;
185-
if (bbox1[1]! > bbox2[1]!) return false;
186-
if (bbox1[3]! < bbox2[3]!) return false;
185+
if (bbox1.lng1 > bbox2.lng1) return false;
186+
if (bbox1.lng2 < bbox2.lng2) return false;
187+
if (bbox1.lat1 > bbox2.lat1) return false;
188+
if (bbox1.lat2 < bbox2.lat2) return false;
187189
return true;
188190
}
189191

0 commit comments

Comments
 (0)