|
5 | 5 | use GeoJson\Feature\Feature; |
6 | 6 | use GeoJson\GeoJson; |
7 | 7 | use GeoJson\Geometry\LineString; |
| 8 | +use GeoJson\Geometry\MultiPolygon; |
8 | 9 | use GeoJson\Geometry\Point; |
9 | 10 | use GeoJson\Geometry\Polygon; |
10 | 11 | use PHPUnit\Framework\TestCase; |
@@ -70,4 +71,35 @@ public function test_recompute_bbox(): void |
70 | 71 | $bbox = Turf::bbox($feature, true); |
71 | 72 | $this->assertEquals([10, 20, 10, 20], $bbox, 'Should recompute BBox when recompute is true'); |
72 | 73 | } |
| 74 | + |
| 75 | + public function test_bbox_multipolygon(): void |
| 76 | + { |
| 77 | + $multiPolygon = new MultiPolygon([ |
| 78 | + [ |
| 79 | + [[0, 0], [1, 0], [1, 1], [0, 1], [0, 0]], |
| 80 | + ], |
| 81 | + [ |
| 82 | + [[2, 2], [4, 2], [4, 4], [2, 4], [2, 2]], |
| 83 | + ], |
| 84 | + ]); |
| 85 | + |
| 86 | + $bbox = Turf::bbox($multiPolygon); |
| 87 | + $this->assertEquals([0, 0, 4, 4], $bbox, 'MultiPolygon BBox should encompass all polygons'); |
| 88 | + } |
| 89 | + |
| 90 | + public function test_bbox_multipolygon_with_holes(): void |
| 91 | + { |
| 92 | + $multiPolygon = new MultiPolygon([ |
| 93 | + [ |
| 94 | + [[0, 0], [3, 0], [3, 3], [0, 3], [0, 0]], |
| 95 | + [[1, 1], [2, 1], [2, 2], [1, 2], [1, 1]], |
| 96 | + ], |
| 97 | + [ |
| 98 | + [[5, 5], [7, 5], [7, 7], [5, 7], [5, 5]], |
| 99 | + ], |
| 100 | + ]); |
| 101 | + |
| 102 | + $bbox = Turf::bbox($multiPolygon); |
| 103 | + $this->assertEquals([0, 0, 7, 7], $bbox, 'MultiPolygon BBox with holes should encompass all rings'); |
| 104 | + } |
73 | 105 | } |
0 commit comments