From c048a36a4c20bcbf6476da9504891f258fa3d440 Mon Sep 17 00:00:00 2001 From: Michael Krasnyk Date: Tue, 27 Feb 2018 13:39:01 +0100 Subject: [PATCH] Use smaller range for U-turn angles in map-matching --- CHANGELOG.md | 8 +++-- features/step_definitions/matching.js | 2 +- features/testbot/matching.feature | 31 +++++++++++++++++++ include/engine/guidance/assemble_geometry.hpp | 4 ++- src/engine/plugins/match.cpp | 2 +- 5 files changed, 41 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dd255e6f0..aea2568d0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,12 +1,14 @@ # UNRELEASED - Changes from 5.16.0: - - Bugfixes: fix deduplication of route steps when waypoints are used [#4909](https://github.com/Project-OSRM/osrm-backend/issues/4909) + - Bugfixes: + - fix deduplication of route steps when waypoints are used [#4909](https://github.com/Project-OSRM/osrm-backend/issues/4909) + - FIXED #4920: Use smaller range for U-turn angles in map-matching [#4920](https://github.com/Project-OSRM/osrm-backend/pull/4920) - Tools: - `osrm-routed` accepts a new property `--memory_file` to store memory in a file on disk. - NodeJS: - `OSRM` object accepts a new option `memory_file` that stores the memory in a file on disk. - - Internals - - CHANGED #4845: Updated segregated intersection identification + - Internals + - CHANGED #4845: Updated segregated intersection identification # 5.16.0 diff --git a/features/step_definitions/matching.js b/features/step_definitions/matching.js index 1b96e0a8a..d7c62ee07 100644 --- a/features/step_definitions/matching.js +++ b/features/step_definitions/matching.js @@ -74,7 +74,7 @@ module.exports = function () { if (headers.has('turns')) { if (json.matchings.length != 1) throw new Error('*** Checking turns only supported for matchings with one subtrace'); - turns = this.turnList(json.matchings[0].instructions); + turns = this.turnList(json.matchings[0]); } if (headers.has('route')) { diff --git a/features/testbot/matching.feature b/features/testbot/matching.feature index 32254d1fb..568f8bd64 100644 --- a/features/testbot/matching.feature +++ b/features/testbot/matching.feature @@ -684,3 +684,34 @@ Feature: Basic Map Matching When I match I should get | trace | geometry | code | | bgkj | 1.000135,1,1.000135,0.99964,1.000387,0.999137 | Ok | + + + @match @testbot + Scenario: Regression test - waypoints trimming too much geometry + Given the profile "testbot" + Given a grid size of 10 meters + Given the query options + | geometries | geojson | + Given the node map + """ + e + ; + ; + a-----b-----c + ; + ; + d + """ + And the ways + | nodes | + | abc | + | bde | + Given the query options + | waypoints | 0;2 | + | overview | full | + | steps | true | + When I match I should get + | trace | geometry | turns | code | + | abc | 1,0.99973,1.00027,0.99973,1.000539,0.99973 | depart,arrive | Ok | + | abd | 1,0.99973,1.00027,0.99973,1.00027,0.999461 | depart,turn right,arrive | Ok | + | abe | 1,0.99973,1.00027,0.99973,1.00027,1 | depart,turn left,arrive | Ok | diff --git a/include/engine/guidance/assemble_geometry.hpp b/include/engine/guidance/assemble_geometry.hpp index 67be502ea..235e86934 100644 --- a/include/engine/guidance/assemble_geometry.hpp +++ b/include/engine/guidance/assemble_geometry.hpp @@ -80,7 +80,9 @@ inline LegGeometry assembleGeometry(const datafacade::BaseDataFacade &facade, prev_coordinate = coordinate; const auto osm_node_id = facade.GetOSMNodeIDOfNode(path_point.turn_via_node); - if (osm_node_id != geometry.osm_node_ids.back()) + + if (osm_node_id != geometry.osm_node_ids.back() || + path_point.turn_instruction.type != osrm::guidance::TurnType::NoTurn) { geometry.annotations.emplace_back(LegGeometry::Annotation{ current_distance, diff --git a/src/engine/plugins/match.cpp b/src/engine/plugins/match.cpp index 2319abc02..8323b0ab6 100644 --- a/src/engine/plugins/match.cpp +++ b/src/engine/plugins/match.cpp @@ -44,7 +44,7 @@ void filterCandidates(const std::vector &coordinates, coordinates[current_coordinate + 1]); // sharp turns indicate a possible uturn - if (turn_angle <= 90.0 || turn_angle >= 270.0) + if (turn_angle <= 45.0 || turn_angle >= 315.0) { allow_uturn = true; }