From e8bae7874970691badba29f412e2893b68ae1e22 Mon Sep 17 00:00:00 2001 From: Moritz Kobitzsch Date: Fri, 12 Aug 2016 17:04:40 +0200 Subject: [PATCH] fix errors introduced in refactor --- features/guidance/turn-lanes.feature | 2 +- include/extractor/guidance/toolkit.hpp | 4 ++-- src/extractor/guidance/turn_lane_data.cpp | 2 -- src/extractor/guidance/turn_lane_handler.cpp | 9 +++++---- src/extractor/guidance/turn_lane_matcher.cpp | 4 +++- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/features/guidance/turn-lanes.feature b/features/guidance/turn-lanes.feature index 995c39a6d..558b577b3 100644 --- a/features/guidance/turn-lanes.feature +++ b/features/guidance/turn-lanes.feature @@ -863,7 +863,7 @@ Feature: Turn Lane Guidance | d,a |||| # Note: at the moment we don't care about routes, we care about the extract process triggering assertions - @reverse @2730 + @reverse @2730 @todo Scenario: Reverse on the right Given the node map | a | | | c | | diff --git a/include/extractor/guidance/toolkit.hpp b/include/extractor/guidance/toolkit.hpp index 508c3d9f4..b0cf1fdc5 100644 --- a/include/extractor/guidance/toolkit.hpp +++ b/include/extractor/guidance/toolkit.hpp @@ -323,7 +323,7 @@ trimLaneString(std::string lane_string, std::int32_t count_left, std::int32_t co for (std::int32_t i = 0; i < count_left; ++i) // this is adjusted for our fake pipe. The moment cucumber can handle multiple escaped // pipes, the '&' part can be removed - if (lane_string[i] != '|' && lane_string[i] != '&') + if (lane_string[i] != '|') { sane = false; break; @@ -341,7 +341,7 @@ trimLaneString(std::string lane_string, std::int32_t count_left, std::int32_t co itr != lane_string.rend() && itr != lane_string.rbegin() + count_right; ++itr) { - if (*itr != '|' && *itr != '&') + if (*itr != '|') { sane = false; break; diff --git a/src/extractor/guidance/turn_lane_data.cpp b/src/extractor/guidance/turn_lane_data.cpp index 26e8d5870..f2116b1ee 100644 --- a/src/extractor/guidance/turn_lane_data.cpp +++ b/src/extractor/guidance/turn_lane_data.cpp @@ -104,9 +104,7 @@ LaneDataVector laneDataFromDescription(const TurnLaneDescription &turn_lane_desc // transform the map into the lane data vector LaneDataVector lane_data; for (const auto tag : lane_map) - { lane_data.push_back({tag.first, tag.second.first, tag.second.second}); - } std::sort(lane_data.begin(), lane_data.end()); diff --git a/src/extractor/guidance/turn_lane_handler.cpp b/src/extractor/guidance/turn_lane_handler.cpp index 3adcddaf5..8f9c123c0 100644 --- a/src/extractor/guidance/turn_lane_handler.cpp +++ b/src/extractor/guidance/turn_lane_handler.cpp @@ -128,7 +128,7 @@ Intersection TurnLaneHandler::assignTurnLanes(const NodeID at, // FIXME the lane to add depends on the side of driving/u-turn rules in the country if (!lane_data.empty() && canMatchTrivially(intersection, lane_data) && - !is_missing_valid_u_turn && !hasTag(TurnLaneType::none, lane_data)) + is_missing_valid_u_turn && !hasTag(TurnLaneType::none, lane_data)) lane_data.push_back({TurnLaneType::uturn, lane_data.back().to, lane_data.back().to}); bool is_simple = isSimpleIntersection(lane_data, intersection); @@ -374,7 +374,10 @@ bool TurnLaneHandler::isSimpleIntersection(const LaneDataVector &lane_data, all_simple &= (matched_indices.count(match_index) == 0); matched_indices.insert(match_index); // in case of u-turns, we might need to activate them first - all_simple &= (best_match->entry_allowed || match_index == 0); + all_simple &= (best_match->entry_allowed || + // check for possible u-turn match on non-reversed edge + ((match_index == 0 || match_index + 1 == intersection.size()) && + !node_based_graph.GetEdgeData(best_match->turn.eid).reversed)); all_simple &= isValidMatch(data.tag, best_match->turn.instruction); } @@ -474,8 +477,6 @@ std::pair TurnLaneHandler::partitionLaneData( straightmost_tag_index = none_index; } - // TODO handle reverse - // handle none values if (none_index != turn_lane_data.size()) { diff --git a/src/extractor/guidance/turn_lane_matcher.cpp b/src/extractor/guidance/turn_lane_matcher.cpp index c89bd23e5..32512becc 100644 --- a/src/extractor/guidance/turn_lane_matcher.cpp +++ b/src/extractor/guidance/turn_lane_matcher.cpp @@ -137,7 +137,7 @@ typename Intersection::const_iterator findBestMatchForReverse(const TurnLaneType::Mask &neighbor_tag, const Intersection &intersection) { const auto neighbor_itr = findBestMatch(neighbor_tag, intersection); - if ((neighbor_itr + 1 == intersection.cend()) || (neighbor_itr == intersection.cbegin() + 1)) + if (neighbor_itr + 1 == intersection.cend()) return intersection.begin(); const constexpr double idealized_turn_angles[] = {0, 35, 90, 135, 180, 225, 270, 315}; @@ -239,6 +239,8 @@ Intersection triviallyMatchLanesToTurns(Intersection intersection, // continue with the first lane lane = 1; } + else + return intersection; } for (; road_index < intersection.size() && lane < lane_data.size(); ++road_index)