Skip to content

Commit 34c10e4

Browse files
authored
Merge pull request #56 from bricehartmann/bugfix/multipolygon-wkt-parsing
Multipolygon WKT Parsing Bugfix
2 parents 99c02b2 + 388d600 commit 34c10e4

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/Types/Point.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function toPair()
4545

4646
public static function fromPair($pair)
4747
{
48-
list($lng, $lat) = explode(' ', trim($pair));
48+
list($lng, $lat) = explode(' ', trim($pair, "\t\n\r \x0B()"));
4949

5050
return new static((float) $lat, (float) $lng);
5151
}

tests/Unit/Types/MultiPolygonTest.php

+7
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ public function testFromWKT()
1313
$this->assertInstanceOf(MultiPolygon::class, $polygon);
1414

1515
$this->assertEquals(2, $polygon->count());
16+
17+
$polygon = MultiPolygon::fromWKT('MULTIPOLYGON (((30 20, 45 40, 10 40, 30 20)), ((15 5, 40 10, 10 20, 5 10, 15 5)))');
18+
$this->assertInstanceOf(MultiPolygon::class, $polygon);
19+
20+
$this->assertEquals(2, $polygon->count());
21+
22+
$this->assertEquals('MULTIPOLYGON(((30 20,45 40,10 40,30 20)),((15 5,40 10,10 20,5 10,15 5)))', $polygon->toWKT());
1623
}
1724

1825
public function testToWKT()

0 commit comments

Comments
 (0)