Add a summary to each match result showing distance and duration.

Helpful for comparing how long the routing engine thinks the matched
trace should take to travel.
This commit is contained in:
Daniel Patterson 2015-11-13 17:57:07 -05:00
parent d5e4495f89
commit c7e30e2266
3 changed files with 46 additions and 1 deletions

View File

@ -156,6 +156,7 @@ When /^I match with turns I should get$/ do |table|
modes = mode_list json['matchings'][0]['instructions']
times = time_list json['matchings'][0]['instructions']
distances = distance_list json['matchings'][0]['instructions']
summary = json['matchings'][0]['route_summary']
end
end
@ -168,6 +169,9 @@ When /^I match with turns I should get$/ do |table|
if table.headers.include? '#' # comment column
got['#'] = row['#'] # copy value so it always match
end
if table.headers.include? 'duration'
got['duration'] = "#{summary["total_time"]}"
end
sub_matchings = []
if response.code == "200"

View File

@ -79,4 +79,39 @@ Feature: Turn directions/codes
| gm | xg,xm | head,slight_left,destination | gm |
| go | xg,xo | head,straight,destination | go |
| ga | xg,xa | head,slight_right,destination | ga |
| gc | xg,xc | head,right,destination | gc |
| gc | xg,xc | head,right,destination | gc |
Scenario: Turn directions
Given the node map
| o | p | a | b | c |
| n | | | | d |
| m | | x | | e |
| l | | | | f |
| k | j | i | h | g |
And the ways
| nodes |
| xa |
| xb |
| xc |
| xd |
| xe |
| xf |
| xg |
| xh |
| xi |
| xj |
| xk |
| xl |
| xm |
| xn |
| xo |
| xp |
When I match with turns I should get
| trace | route | turns | matchings | duration |
| im | xi,xm | head,left,destination | im | 80 |
| io | xi,xo | head,slight_left,destination | io | 88 |
| ia | xi,xa | head,straight,destination | ia | 80 |
| ic | xi,xc | head,slight_right,destination | ic | 88 |
| ie | xi,xe | head,right,destination | ie | 60 |

View File

@ -238,6 +238,12 @@ template <class DataFacadeT> class MapMatchingPlugin : public BasePlugin
subtrace.values["instructions"] = json_descriptor.BuildTextualDescription(factory, temp_segments);
}
factory.BuildRouteSummary(factory.get_entire_length(),
raw_route.shortest_path_length);
osrm::json::Object json_route_summary;
json_route_summary.values["total_distance"] = factory.summary.distance;
json_route_summary.values["total_time"] = factory.summary.duration;
subtrace.values["route_summary"] = json_route_summary;
}
subtrace.values["indices"] = osrm::json::make_array(sub.indices);