Skip to content

Commit 102db62

Browse files
Fix WKT for empty geometry collections (#132)
1 parent 567434b commit 102db62

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/Objects/GeometryCollection.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ public function toWkt(): string
4242
{
4343
$wktData = $this->getWktData();
4444

45+
if ($wktData === '') {
46+
return 'GEOMETRYCOLLECTION EMPTY';
47+
}
48+
4549
return "GEOMETRYCOLLECTION({$wktData})";
4650
}
4751

tests/Objects/GeometryCollectionTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -669,3 +669,9 @@
669669
TestPlace::factory()->create(['geometry_collection' => $geometryCollection]);
670670
})->toThrow(InvalidArgumentException::class);
671671
});
672+
673+
it('generates empty geometry collection WKT', function (): void {
674+
$geometryCollection = new GeometryCollection([]);
675+
676+
expect($geometryCollection->toWkt())->toBe('GEOMETRYCOLLECTION EMPTY');
677+
});

0 commit comments

Comments
 (0)