Skip to content

Commit

Permalink
fix issue with cut segments in route feature
Browse files Browse the repository at this point in the history
Fixes #3.

Release v0.3.3
  • Loading branch information
laufhannes committed Jan 14, 2019
1 parent 80dc973 commit d49db92
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/Feature/Route.php
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}

Expand Down
22 changes: 22 additions & 0 deletions src/Tests/Feature/RouteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}

0 comments on commit d49db92

Please sign in to comment.