Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add source phantom weight to first segment when merging legs #4949

Merged
merged 9 commits into from
Mar 13, 2018
24 changes: 24 additions & 0 deletions features/testbot/matching.feature
Original file line number Diff line number Diff line change
Expand Up @@ -718,3 +718,27 @@ Feature: Basic Map Matching
| abe | 1,0.99973,1.00027,0.99973,1.00027,1 | depart,turn left,arrive | Ok |
| ahd | 1,0.99973,1.00027,0.99973,1.00027,0.999461 | depart,turn right,arrive | Ok |
| ahe | 1,0.99973,1.00027,0.99973,1.00027,1 | depart,turn left,arrive | Ok |

@match @testbot
Scenario: Regression test - duration aggregation for phantom nodes
Given the profile "testbot"
Given a grid size of 10 meters
Given the node map
"""
a--1-b2cd-3--e
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i suggest to make forward and reverse phantom node weights for bc segment different as a--1-b2-cd-3--e

"""
And the ways
| nodes |
| ab |
| bcd |
| de |
Given the query options
| geometries | geojson |
| overview | full |
| steps | true |
| waypoints | 0;2 |
| annotations | duration,weight |
| generate_hints | false |
When I match I should get
| trace | geometry | a:duration | a:weight | duration |
| 123 | 1.000135,1,1.000225,1,1.000315,1,1.00036,1,1.00045,1 | 1:1:0.5:1 | 1:1:0.5:1 | 3.5 |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... and here add a test for a reversed trace as 321

19 changes: 16 additions & 3 deletions include/engine/internal_route_result.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,22 @@ inline InternalRouteResult CollapseInternalRouteResult(const InternalRouteResult
collapsed.target_traversed_in_reverse.back() =
leggy_result.target_traversed_in_reverse[i];
// copy path segments into current leg
last_segment.insert(last_segment.end(),
leggy_result.unpacked_path_segments[i].begin(),
leggy_result.unpacked_path_segments[i].end());
if (!leggy_result.unpacked_path_segments[i].empty())
{
auto old_size = last_segment.size();
last_segment.insert(last_segment.end(),
leggy_result.unpacked_path_segments[i].begin(),
leggy_result.unpacked_path_segments[i].end());

// The first segment of the unpacked path is missing the weight of the
// source phantom. We need to add those values back so that the total
// edge weight is correct
last_segment[old_size].weight_until_turn +=
leggy_result.segment_end_coordinates[i].source_phantom.forward_weight;
Copy link
Contributor

@oxidase oxidase Mar 10, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the source phantom is traversed in reverse then the reverse weight must be used:

leggy_result.source_traversed_in_reverse[i] ?
leggy_result.segment_end_coordinates[i].source_phantom.reverse_weight :
leggy_result.segment_end_coordinates[i].source_phantom.forward_weight;


last_segment[old_size].duration_until_turn +=
leggy_result.segment_end_coordinates[i].source_phantom.forward_duration;
}
}
}
return collapsed;
Expand Down