diff --git a/src/Objects/GeometryCollection.php b/src/Objects/GeometryCollection.php index 6e6a42e..8908276 100644 --- a/src/Objects/GeometryCollection.php +++ b/src/Objects/GeometryCollection.php @@ -42,6 +42,10 @@ public function toWkt(): string { $wktData = $this->getWktData(); + if ($wktData === '') { + return 'GEOMETRYCOLLECTION EMPTY'; + } + return "GEOMETRYCOLLECTION({$wktData})"; } diff --git a/tests/Objects/GeometryCollectionTest.php b/tests/Objects/GeometryCollectionTest.php index 30399b6..07cc8e1 100644 --- a/tests/Objects/GeometryCollectionTest.php +++ b/tests/Objects/GeometryCollectionTest.php @@ -669,3 +669,9 @@ TestPlace::factory()->create(['geometry_collection' => $geometryCollection]); })->toThrow(InvalidArgumentException::class); }); + +it('generates empty geometry collection WKT', function (): void { + $geometryCollection = new GeometryCollection([]); + + expect($geometryCollection->toWkt())->toBe('GEOMETRYCOLLECTION EMPTY'); +});