From c6472eb2899f00c4afdfc3649b4717813c19cb92 Mon Sep 17 00:00:00 2001 From: Kajari Ghosh Date: Sat, 29 Oct 2016 11:22:09 -0400 Subject: [PATCH] Map matching test coverage fix (#3201) * fixed map matching test coverage --- features/step_definitions/matching.js | 14 ++++++- features/testbot/matching.feature | 38 +++++++++---------- .../routing_algorithms/map_matching.hpp | 3 +- include/extractor/profile_properties.hpp | 2 +- 4 files changed, 34 insertions(+), 23 deletions(-) diff --git a/features/step_definitions/matching.js b/features/step_definitions/matching.js index 41cd0ea37..f2e18ab14 100644 --- a/features/step_definitions/matching.js +++ b/features/step_definitions/matching.js @@ -43,7 +43,17 @@ module.exports = function () { if (res.statusCode === 200) { if (headers.has('matchings')) { - subMatchings = json.matchings.filter(m => !!m).map(sub => sub.matched_points); + subMatchings = []; + var sub = [json.tracepoints[0].location]; + for(var i = 1; i < json.tracepoints.length; i++){ + if(json.tracepoints[i-1].matchings_index === json.tracepoints[i].matchings_index) { + sub.push(json.tracepoints[i].location); + } else { + subMatchings.push(sub); + sub = [json.tracepoints[i].location]; + } + } + subMatchings.push(sub); } if (headers.has('turns')) { @@ -68,7 +78,7 @@ module.exports = function () { if (headers.has('geometry')) { if (json.matchings.length != 1) throw new Error('*** Checking geometry only supported for matchings with one subtrace'); - geometry = json.matchings[0].geometry; + geometry = json.matchings[0].geometry.coordinates; } if (headers.has('OSM IDs')) { diff --git a/features/testbot/matching.feature b/features/testbot/matching.feature index 0c2f3f30f..dd43362d1 100644 --- a/features/testbot/matching.feature +++ b/features/testbot/matching.feature @@ -5,9 +5,11 @@ Feature: Basic Map Matching Given the profile "testbot" Given a grid size of 10 meters Given the extract extra arguments "--generate-edge-lookup" + Given the query options + | geometries | geojson | Scenario: Testbot - Map matching with outlier that has no candidate - Given a grid size of 100 meters + Given a grid size of 10 meters Given the node map | a | b | c | d | | | | | | @@ -102,13 +104,13 @@ Feature: Basic Map Matching | fe | yes | When I match I should get - | trace | matchings | - | dcba | hg,gf,fe | - | efgh | ab,bc,cd | + | trace | matchings | + | dcba | hgfe | + | efgh | abcd | Scenario: Testbot - Duration details Given the query options - | annotations | true | + | annotations | true | Given the node map | a | b | c | d | e | | g | h | @@ -128,14 +130,14 @@ Feature: Basic Map Matching When I match I should get | trace | matchings | annotation | - | abeh | abcedgh | 1:9.897633:1,0:0:0,1:10.008842:0,1:10.008842:0,1:10.008842:0,0:0:0,2:20.017685:0,1:10.008842:0 | - | abci | abc,ci | 1:9.897633:1,0:0:0,1:10.008842:0,0:0.111209:0,1:10.010367:0 | + | abeh | abeh | 1:9.897633:1,0:0:0,1:10.008842:0,1:10.008842:0,1:10.008842:0,0:0:0,2:20.017685:0,1:10.008842:0 | + | abci | abci | 1:9.897633:1,0:0:0,1:10.008842:0,0:0.111209:0,1:10.010367:0 | # The following is the same as the above, but separated for readability (line length) When I match I should get | trace | matchings | OSM IDs | - | abeh | abcedgh | 1,2,3,2,3,4,5,4,5,6,7 | - | abci | abc,ci | 1,2,3,2,3,8,3,8 | + | abeh | abeh | 1,2,3,2,3,4,5,4,5,6,7 | + | abci | abci | 1,2,3,2,3,8,3,8 | Scenario: Testbot - Regression test for #3037 Given the query options @@ -143,13 +145,11 @@ Feature: Basic Map Matching | geometries | geojson | Given the node map - """ - a--->---b--->---c - | | | - | ^ | - | | | - e--->---f--->---g - """ + | a | | b | | c | + | | | | | | + | | | | | | + | | | | | | + | e | | f | | g | And the ways | nodes | oneway | @@ -166,7 +166,7 @@ Feature: Basic Map Matching Scenario: Testbot - Geometry details Given the query options | overview | full | - | geometries | polyline | + | geometries | geojson | Given the node map | a | b | c | @@ -178,5 +178,5 @@ Feature: Basic Map Matching | bd | no | When I match I should get - | trace | matchings | geometry | - | abd | abd | 1,1,1,1.00009,1,1.00009,0.99991,1.00009 | + | trace | matchings | geometry | + | abd | abd | 1,1,1.000089,1,1.000089,1,1.000089,0.99991 | diff --git a/include/engine/routing_algorithms/map_matching.hpp b/include/engine/routing_algorithms/map_matching.hpp index 343e26ab8..ba43f6d47 100644 --- a/include/engine/routing_algorithms/map_matching.hpp +++ b/include/engine/routing_algorithms/map_matching.hpp @@ -251,6 +251,7 @@ class MapMatching final : public BasicRoutingInterface(0UL, current_viterbi.size())) { + const double emission_pr = emission_log_probabilities[t][s_prime]; double new_value = prev_viterbi[s] + emission_pr; if (current_viterbi[s_prime] > new_value) @@ -290,7 +291,7 @@ class MapMatching final : public BasicRoutingInterface prune if (d_t >= max_distance_delta) { - continue; + continue; } const double transition_pr = transition_log_probability(d_t); diff --git a/include/extractor/profile_properties.hpp b/include/extractor/profile_properties.hpp index 58a191d4a..16e2d3640 100644 --- a/include/extractor/profile_properties.hpp +++ b/include/extractor/profile_properties.hpp @@ -12,7 +12,7 @@ struct ProfileProperties { ProfileProperties() : traffic_signal_penalty(0), u_turn_penalty(0), continue_straight_at_waypoint(true), - use_turn_restrictions(false), left_hand_driving(false) + use_turn_restrictions(false), left_hand_driving(false) { }