turn lane handler moved to scenario based handling

This commit is contained in:
Moritz Kobitzsch
2016-06-30 09:31:08 +02:00
parent 802b93fa9a
commit 3b81b39998
21 changed files with 955 additions and 292 deletions
@@ -28,7 +28,7 @@ typedef std::vector<TurnLaneData> LaneDataVector;
// convertes a string given in the OSM format into a TurnLaneData vector
OSRM_ATTR_WARN_UNUSED
LaneDataVector laneDataFromDescription(const TurnLaneDescription &turn_lane_description);
LaneDataVector laneDataFromDescription(TurnLaneDescription turn_lane_description);
// Locate A Tag in a lane data vector (if multiple tags are set, the first one found is returned)
LaneDataVector::const_iterator findTag(const TurnLaneType::Mask tag, const LaneDataVector &data);
@@ -37,6 +37,9 @@ LaneDataVector::iterator findTag(const TurnLaneType::Mask tag, LaneDataVector &d
// Returns true if any of the queried tags is contained
bool hasTag(const TurnLaneType::Mask tag, const LaneDataVector &data);
// Check if a set of lanes is a subset of a different set of lanes
bool isSubsetOf(const LaneDataVector &subset_candidate, const LaneDataVector &superset_candidate);
} // namespace lane_data_generation
} // namespace guidance
@@ -33,27 +33,75 @@ namespace lanes
{
class TurnLaneHandler
{
typedef enum TurnLaneScenario {
SIMPLE, // a straightforward assignment
PARTITION_LOCAL, // an assignment that requires partitioning, using local turns
SIMPLE_PREVIOUS, // an assignemtnn using the turns specified at the previous road (e.g.
// traffic light, lanes not drawn up to the intersection)
PARTITION_PREVIOUS, // a set of lanes on a turn with a traffic island. The lanes for the
// turn end at the previous turn (parts of it remain valid without being
// shown again)
SLIPROAD, // Sliproads are simple assignments that, for better visual representation should
// include turns from other roads in their listings
MERGE, // Merging Lanes
NONE, // not a turn lane scenario at all
INVALID, // some error might have occurred
UNKNOWN, // UNKNOWN describes all cases that we are currently not able to handle
NUM_SCENARIOS
} TurnLaneScenario;
const constexpr static char *scenario_names[TurnLaneScenario::NUM_SCENARIOS] = {
"Simple",
"Partition Local",
"Simple Previous",
"Partition Previous",
"Sliproad",
"Merge",
"None",
"Invalid",
"Unknown"};
public:
typedef std::vector<TurnLaneData> LaneDataVector;
TurnLaneHandler(const util::NodeBasedDynamicGraph &node_based_graph,
const std::vector<std::uint32_t> &turn_lane_offsets,
const std::vector<TurnLaneType::Mask> &turn_lane_masks,
const TurnAnalysis &turn_analysis);
std::vector<std::uint32_t> &turn_lane_offsets,
std::vector<TurnLaneType::Mask> &turn_lane_masks,
LaneDescriptionMap &lane_description_map,
const std::vector<QueryNode> &node_info_list,
const TurnAnalysis &turn_analysis,
LaneDataIdMap &id_map);
~TurnLaneHandler();
OSRM_ATTR_WARN_UNUSED
Intersection assignTurnLanes(const NodeID at,
const EdgeID via_edge,
Intersection intersection,
LaneDataIdMap &id_map) const;
Intersection assignTurnLanes(const NodeID at, const EdgeID via_edge, Intersection intersection);
private:
unsigned *count_handled;
unsigned *count_called;
// we need to be able to look at previous intersections to, in some cases, find the correct turn
// lanes for a turn
const util::NodeBasedDynamicGraph &node_based_graph;
const std::vector<std::uint32_t> &turn_lane_offsets;
const std::vector<TurnLaneType::Mask> &turn_lane_masks;
std::vector<std::uint32_t> &turn_lane_offsets;
std::vector<TurnLaneType::Mask> &turn_lane_masks;
LaneDescriptionMap &lane_description_map;
const std::vector<QueryNode> &node_info_list;
const TurnAnalysis &turn_analysis;
LaneDataIdMap &id_map;
// Find out which scenario we have to handle
TurnLaneScenario deduceScenario(const NodeID at,
const EdgeID via_edge,
const Intersection &intersection,
// Output Parameters to reduce repeated creation
LaneDescriptionID &lane_description_id,
LaneDataVector &lane_data,
NodeID &previous_node,
EdgeID &previous_id,
Intersection &previous_intersection,
LaneDataVector &previous_lane_data,
LaneDescriptionID &previous_description_id);
// check whether we can handle an intersection
bool isSimpleIntersection(const LaneDataVector &turn_lane_data,
@@ -63,21 +111,28 @@ class TurnLaneHandler
OSRM_ATTR_WARN_UNUSED
Intersection simpleMatchTuplesToTurns(Intersection intersection,
const LaneDataVector &lane_data,
const LaneDescriptionID lane_string_id,
LaneDataIdMap &id_map) const;
const LaneDescriptionID lane_string_id);
// partition lane data into lane data relevant at current turn and at next turn
OSRM_ATTR_WARN_UNUSED
std::pair<TurnLaneHandler::LaneDataVector, TurnLaneHandler::LaneDataVector> partitionLaneData(
const NodeID at, LaneDataVector turn_lane_data, const Intersection &intersection) const;
// if the current intersections turn string is empty, we check whether there is an incoming
// intersection whose turns might be related to this current intersection
// Sliproad turns have a separated lane to the right/left of other depicted lanes. These lanes
// are not necessarily separated clearly from the rest of the way. As a result, we combine both
// lane entries for our output, while performing the matching with the separated lanes only.
OSRM_ATTR_WARN_UNUSED
Intersection handleTurnAtPreviousIntersection(const NodeID at,
const EdgeID via_edge,
Intersection intersection,
LaneDataIdMap &id_map) const;
Intersection handleSliproadTurn(Intersection intersection,
const LaneDescriptionID lane_description_id,
LaneDataVector lane_data,
const Intersection &previous_intersection,
const LaneDescriptionID &previous_lane_description_id,
const LaneDataVector &previous_lane_data);
// get the lane data for an intersection
void extractLaneData(const EdgeID via_edge,
LaneDescriptionID &lane_description_id,
LaneDataVector &lane_data) const;
};
} // namespace lanes
@@ -22,16 +22,20 @@ namespace lanes
{
// Translate Turn Lane Tags into a matching modifier
DirectionModifier::Enum getMatchingModifier(const TurnLaneType::Mask &tag);
DirectionModifier::Enum getMatchingModifier(const TurnLaneType::Mask tag);
// check whether a match of a given tag and a turn instruction can be seen as valid
bool isValidMatch(const TurnLaneType::Mask &tag, const TurnInstruction instruction);
bool isValidMatch(const TurnLaneType::Mask tag, const TurnInstruction instruction);
// localisation of the best possible match for a tag
typename Intersection::const_iterator findBestMatch(const TurnLaneType::Mask &tag,
typename Intersection::const_iterator findBestMatch(const TurnLaneType::Mask tag,
const Intersection &intersection);
// the quality of a matching to decide between first/second possibility on segregated intersections
double getMatchingQuality( const TurnLaneType::Mask tag, const ConnectedRoad &road );
typename Intersection::const_iterator
findBestMatchForReverse(const TurnLaneType::Mask &leftmost_tag, const Intersection &intersection);
findBestMatchForReverse(const TurnLaneType::Mask leftmost_tag, const Intersection &intersection);
// a match is trivial if all turns can be associated with their best match in a valid way and the
// matches occur in order
@@ -5,6 +5,7 @@
#include <cstddef>
#include <cstdint>
#include <string>
#include <unordered_map>
#include <vector>
#include <boost/assert.hpp>
@@ -95,6 +96,11 @@ struct TurnLaneDescription_hash
}
};
typedef std::unordered_map<guidance::TurnLaneDescription,
LaneDescriptionID,
guidance::TurnLaneDescription_hash>
LaneDescriptionMap;
} // guidance
} // extractor
} // osrm