Handle oneways in get_forward_backward_by_key

This commit is contained in:
Michael Krasnyk 2018-02-20 13:12:20 +01:00
parent 7c8c25f7bc
commit 6f4af330ed
4 changed files with 22 additions and 13 deletions

View File

@ -201,7 +201,7 @@ Feature: Motorway Guidance
| a,e | abcde,abcde | depart,arrive | | a,e | abcde,abcde | depart,arrive |
| f,e | fgc,abcde,abcde | depart,merge slight left,arrive | | f,e | fgc,abcde,abcde | depart,merge slight left,arrive |
| a,i | abcde,chi,chi | depart,off ramp slight right,arrive | | a,i | abcde,chi,chi | depart,off ramp slight right,arrive |
| f,i | fgc,chi,chi | depart,off ramp right,arrive | | f,i | fgc,chi,chi | depart,off ramp slight right,arrive |
Scenario: On And Off Ramp Left Scenario: On And Off Ramp Left
Given the node map Given the node map
@ -221,7 +221,7 @@ Feature: Motorway Guidance
| a,e | abcde,abcde | depart,arrive | | a,e | abcde,abcde | depart,arrive |
| f,e | fgc,abcde,abcde | depart,merge slight right,arrive | | f,e | fgc,abcde,abcde | depart,merge slight right,arrive |
| a,i | abcde,chi,chi | depart,off ramp slight left,arrive | | a,i | abcde,chi,chi | depart,off ramp slight left,arrive |
| f,i | fgc,chi,chi | depart,off ramp left,arrive | | f,i | fgc,chi,chi | depart,off ramp slight left,arrive |
Scenario: Merging Motorways Scenario: Merging Motorways
Given the node map Given the node map

View File

@ -14,13 +14,23 @@ function Tags.get_forward_backward_by_key(way,data,key)
local forward = way:get_value_by_key(key .. ':forward') local forward = way:get_value_by_key(key .. ':forward')
local backward = way:get_value_by_key(key .. ':backward') local backward = way:get_value_by_key(key .. ':backward')
if forward and backward then if not forward or not backward then
return forward, backward local common = way:get_value_by_key(key)
if (data.oneway) then
if data.is_forward_oneway then
forward = forward or common
end
if data.is_reverse_oneway then
backward = backward or common
end
else
forward = forward or common
backward = backward or common
end
end end
local common = way:get_value_by_key(key) return forward, backward
return forward or common,
backward or common
end end
-- return [forward,backward] values, searching a -- return [forward,backward] values, searching a

View File

@ -185,7 +185,7 @@ util::Coordinate CoordinateExtractor::ExtractRepresentativeCoordinate(
*/ */
const bool first_coordinate_is_far_away = [&first_distance, considered_lanes]() { const bool first_coordinate_is_far_away = [&first_distance, considered_lanes]() {
const auto required_distance = const auto required_distance =
considered_lanes * 0.5 * ASSUMED_LANE_WIDTH + LOOKAHEAD_DISTANCE_WITHOUT_LANES; considered_lanes * ASSUMED_LANE_WIDTH + LOOKAHEAD_DISTANCE_WITHOUT_LANES;
return first_distance > required_distance; return first_distance > required_distance;
}(); }();
@ -196,8 +196,7 @@ util::Coordinate CoordinateExtractor::ExtractRepresentativeCoordinate(
} }
// now, after the simple checks have succeeded make our further computations simpler // now, after the simple checks have succeeded make our further computations simpler
const auto lookahead_distance = const auto lookahead_distance = FAR_LOOKAHEAD_DISTANCE + considered_lanes * ASSUMED_LANE_WIDTH;
FAR_LOOKAHEAD_DISTANCE + considered_lanes * ASSUMED_LANE_WIDTH * 0.5;
/* /*
* The coordinates along the road are in different distances from the source. If only very few * The coordinates along the road are in different distances from the source. If only very few
@ -286,7 +285,7 @@ util::Coordinate CoordinateExtractor::ExtractRepresentativeCoordinate(
const bool starts_of_without_turn = [&]() { const bool starts_of_without_turn = [&]() {
return straight_distance >= return straight_distance >=
considered_lanes * 0.5 * ASSUMED_LANE_WIDTH + LOOKAHEAD_DISTANCE_WITHOUT_LANES; considered_lanes * ASSUMED_LANE_WIDTH + LOOKAHEAD_DISTANCE_WITHOUT_LANES;
}(); }();
if (starts_of_without_turn) if (starts_of_without_turn)
@ -355,7 +354,7 @@ util::Coordinate CoordinateExtractor::ExtractRepresentativeCoordinate(
if (IsCurve(coordinates, if (IsCurve(coordinates,
segment_distances, segment_distances,
total_distance, total_distance,
considered_lanes * 0.5 * ASSUMED_LANE_WIDTH, considered_lanes * ASSUMED_LANE_WIDTH,
turn_edge_data)) turn_edge_data))
{ {
if (total_distance <= skipping_inaccuracies_distance) if (total_distance <= skipping_inaccuracies_distance)

View File

@ -10,7 +10,7 @@ exports.three_test_coordinates = [[7.41337, 43.72956],
exports.two_test_coordinates = exports.three_test_coordinates.slice(0, 2) exports.two_test_coordinates = exports.three_test_coordinates.slice(0, 2)
exports.test_tile = {'at': [17059, 11948, 15], 'size': 168612}; exports.test_tile = {'at': [17059, 11948, 15], 'size': 168605};
// Test files generated by the routing engine; check test/data // Test files generated by the routing engine; check test/data
if (process.env.OSRM_DATA_PATH !== undefined) { if (process.env.OSRM_DATA_PATH !== undefined) {