Uses parsed len(turn:lanes) to fixup number of lanes, resolves #4472

This commit is contained in:
Daniel J. Hofmann 2017-09-04 16:14:35 +02:00 committed by Daniel J. H
parent c37a8ddd83
commit d7bcafcb59
2 changed files with 54 additions and 12 deletions

View File

@ -280,6 +280,35 @@ Feature: Simple Turns
| a,d | road,road | depart,arrive | | a,d | road,road | depart,arrive |
| e,a | road,road | depart,arrive | | e,a | road,road | depart,arrive |
Scenario: Splitting Road with many lanes; same as above makes sure len(turn:lanes) work as expected
Given the node map
"""
f - - - - - - - - - - - - - - - - - - - - e
'
'
'
'
'
a - - - - - b
'
'
'
'
'
c - - - - - - - - - - - - - - - - - - - - d
"""
And the ways
| nodes | highway | name | turn:lanes | oneway |
| ab | primary | road | left\|left\|right\|right | no |
| bcd | primary | road | through\|through | yes |
| efb | primary | road | through\|through | yes |
When I route I should get
| waypoints | route | turns |
| a,d | road,road | depart,arrive |
| e,a | road,road | depart,arrive |
@todo @todo
# currently the intersections don't match up do to the `merging` process. # currently the intersections don't match up do to the `merging` process.
# The intermediate intersection is technically no-turn at all, since the road continues. # The intermediate intersection is technically no-turn at all, since the road continues.

View File

@ -287,23 +287,36 @@ void ExtractorCallbacks::ProcessWay(const osmium::Way &input_way, const Extracti
return lane_description; return lane_description;
}; };
// convert the lane description into an ID and, if necessary, remember the description in the // If we could parse turn lanes but could not parse number of lanes,
// description_map // count the turn lanes and use them for the way's number of lanes.
const auto requestId = [&](const std::string &lane_string) { auto road_classification = parsed_way.road_classification;
if (lane_string.empty()) std::uint8_t road_deduced_num_lanes = 0;
return INVALID_LANE_DESCRIPTIONID;
TurnLaneDescription lane_description = laneStringToDescription(std::move(lane_string));
return lane_description_map.ConcurrentFindOrAdd(lane_description);
};
// Deduplicates street names, refs, destinations, pronunciation, exits. // Deduplicates street names, refs, destinations, pronunciation, exits.
// In case we do not already store the key, inserts (key, id) tuple and return id. // In case we do not already store the key, inserts (key, id) tuple and return id.
// Otherwise fetches the id based on the name and returns it without insertion. // Otherwise fetches the id based on the name and returns it without insertion.
const auto turn_lane_id_forward = requestId(parsed_way.turn_lanes_forward); auto turn_lane_id_forward = INVALID_LANE_DESCRIPTIONID;
const auto turn_lane_id_backward = requestId(parsed_way.turn_lanes_backward); auto turn_lane_id_backward = INVALID_LANE_DESCRIPTIONID;
const auto road_classification = parsed_way.road_classification; // RoadClassification represents a the class for unidirectional ways,
// therefore we need to add up deduced forward and backward lane counts.
if (!parsed_way.turn_lanes_forward.empty())
{
auto desc = laneStringToDescription(parsed_way.turn_lanes_forward);
turn_lane_id_forward = lane_description_map.ConcurrentFindOrAdd(desc);
road_deduced_num_lanes += desc.size();
}
if (!parsed_way.turn_lanes_backward.empty())
{
auto desc = laneStringToDescription(parsed_way.turn_lanes_backward);
turn_lane_id_backward = lane_description_map.ConcurrentFindOrAdd(desc);
road_deduced_num_lanes += desc.size();
}
road_classification.SetNumberOfLanes(std::max(road_deduced_num_lanes, // len(turn:lanes)
road_classification.GetNumberOfLanes()));
// Get the unique identifier for the street name, destination, and ref // Get the unique identifier for the street name, destination, and ref
const auto name_iterator = string_map.find(MapKey(parsed_way.name, const auto name_iterator = string_map.find(MapKey(parsed_way.name,