From 388d60025ee74f41d4a95bd9c85a9d4f313736a8 Mon Sep 17 00:00:00 2001 From: bricehartmann Date: Sat, 14 Jul 2018 00:38:35 -0500 Subject: [PATCH] fixes multipolygon parsing of first point in each polygon --- src/Types/Point.php | 2 +- tests/Unit/Types/MultiPolygonTest.php | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Types/Point.php b/src/Types/Point.php index 2a149e80..40719af4 100644 --- a/src/Types/Point.php +++ b/src/Types/Point.php @@ -45,7 +45,7 @@ public function toPair() public static function fromPair($pair) { - list($lng, $lat) = explode(' ', trim($pair)); + list($lng, $lat) = explode(' ', trim($pair, "\t\n\r \x0B()")); return new static((float) $lat, (float) $lng); } diff --git a/tests/Unit/Types/MultiPolygonTest.php b/tests/Unit/Types/MultiPolygonTest.php index adcac1e1..cf5894ff 100644 --- a/tests/Unit/Types/MultiPolygonTest.php +++ b/tests/Unit/Types/MultiPolygonTest.php @@ -13,6 +13,13 @@ public function testFromWKT() $this->assertInstanceOf(MultiPolygon::class, $polygon); $this->assertEquals(2, $polygon->count()); + + $polygon = MultiPolygon::fromWKT('MULTIPOLYGON (((30 20, 45 40, 10 40, 30 20)), ((15 5, 40 10, 10 20, 5 10, 15 5)))'); + $this->assertInstanceOf(MultiPolygon::class, $polygon); + + $this->assertEquals(2, $polygon->count()); + + $this->assertEquals('MULTIPOLYGON(((30 20,45 40,10 40,30 20)),((15 5,40 10,10 20,5 10,15 5)))', $polygon->toWKT()); } public function testToWKT()