diff --git a/features/testbot/matching.feature b/features/testbot/matching.feature index 44cea5e99..c5ae5cea5 100644 --- a/features/testbot/matching.feature +++ b/features/testbot/matching.feature @@ -358,8 +358,8 @@ Feature: Basic Map Matching | trace | matchings | alternatives | | abcdef | abcde | 0,0,0,0,1,1 | - Scenario: Testbot - Speed greater than speed threshhold - Given a grid size of 10 meters + Scenario: Testbot - Speed greater than speed threshold + Given a grid size of 100 meters Given the query options | geometries | geojson | @@ -379,8 +379,8 @@ Feature: Basic Map Matching | trace | timestamps | matchings | | abcd | 0 1 2 3 | ab,cd | - Scenario: Testbot - Speed less than speed threshhold - Given a grid size of 10 meters + Scenario: Testbot - Speed less than speed threshold + Given a grid size of 100 meters Given the query options | geometries | geojson | @@ -397,6 +397,28 @@ Feature: Basic Map Matching | trace | timestamps | matchings | | abcd | 0 1 2 3 | abcd | + Scenario: Testbot - Huge gap in the coordinates + Given a grid size of 100 meters + Given the query options + | geometries | geojson | + | gaps | ignore | + + Given the node map + """ + a b c d ---- x + | + | + y ---- z ---- efjk + """ + + And the ways + | nodes | oneway | + | abcdxyzefjk | no | + + When I match I should get + | trace | timestamps | matchings | + | abcdefjk | 0 1 2 3 50 51 52 53 | abcdefjk | + # Regression test 1 for issue 3176 Scenario: Testbot - multiple segments: properly expose OSM IDs Given the query options diff --git a/src/engine/routing_algorithms/map_matching.cpp b/src/engine/routing_algorithms/map_matching.cpp index f79034da7..8cdabf92e 100644 --- a/src/engine/routing_algorithms/map_matching.cpp +++ b/src/engine/routing_algorithms/map_matching.cpp @@ -79,16 +79,6 @@ SubMatchingList mapMatching(SearchEngineData &engine_working_data, } }(); const auto max_broken_time = median_sample_time * MAX_BROKEN_STATES; - const auto max_distance_delta = [&] { - if (use_timestamps) - { - return median_sample_time * facade.GetMapMatchingMaxSpeed(); - } - else - { - return MAX_DISTANCE_DELTA; - } - }(); std::vector> emission_log_probabilities(trace_coordinates.size()); if (trace_gps_precision.empty()) @@ -155,13 +145,24 @@ SubMatchingList mapMatching(SearchEngineData &engine_working_data, for (auto t = initial_timestamp + 1; t < candidates_list.size(); ++t) { + const auto step_time = trace_timestamps[t] - trace_timestamps[prev_unbroken_timestamps.back()]; + const auto max_distance_delta = [&] { + if (use_timestamps) + { + return step_time * facade.GetMapMatchingMaxSpeed(); + } + else + { + return MAX_DISTANCE_DELTA; + } + }(); + const bool gap_in_trace = [&]() { // use temporal information if available to determine a split // but do not determine split by timestamps if wasn't asked about it if (use_timestamps && allow_splitting) { - return trace_timestamps[t] - trace_timestamps[prev_unbroken_timestamps.back()] > - max_broken_time; + return step_time > max_broken_time; } else {