diff --git a/composer.json b/composer.json index d3b2c46..75267f1 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "runalyze/static-maps", "description": "Library to create static images from various map tile providers.", - "version": "0.3.1", + "version": "0.3.3", "license": "MIT", "require": { "php": ">=7.0", diff --git a/src/Feature/Route.php b/src/Feature/Route.php index d56a1c7..d600a68 100644 --- a/src/Feature/Route.php +++ b/src/Feature/Route.php @@ -118,7 +118,7 @@ protected function getLineSegments(array $coordinates): array return []; } - if (2 == count($coordinates[0]) || !is_array($coordinates[0][0])) { + if (2 == count($coordinates[0]) && !is_array($coordinates[0][0])) { return [$coordinates]; } diff --git a/src/Tests/Feature/RouteTest.php b/src/Tests/Feature/RouteTest.php index cf5380f..bf6063c 100644 --- a/src/Tests/Feature/RouteTest.php +++ b/src/Tests/Feature/RouteTest.php @@ -57,4 +57,26 @@ protected function assertThatBoundingBoxIsEqual(BoundingBoxInterface $expected, $this->assertEquals($expected->getMinLongitude(), $actual->getMinLongitude(), '', 0.001); $this->assertEquals($expected->getMaxLongitude(), $actual->getMaxLongitude(), '', 0.001); } + + /** + * @see https://github.com/Runalyze/static-maps/issues/3 + */ + public function testExampleWithBreaksInCoordinates() + { + $route = new Route([ + [ + [51.034692, 13.791008], + [51.034692, 13.791008] + ], + [ + [51.034708, 13.790972], + [51.034720, 13.790943], + [51.034733, 13.790913], + [51.034747, 13.790882] + ] + ]); + + $this->assertFalse($route->isEmpty()); + $this->assertThatBoundingBoxIsEqual(new BoundingBox(51.034, 51.035, 13.790, 13.791), $route->getBoundingBox()); + } }