basic turn lane handling
This commit is contained in:
@@ -65,6 +65,42 @@ mirrorDirectionModifier(const extractor::guidance::DirectionModifier::Enum modif
|
||||
return results[modifier];
|
||||
}
|
||||
|
||||
inline bool hasLeftModifier(const extractor::guidance::TurnInstruction instruction)
|
||||
{
|
||||
return instruction.direction_modifier == extractor::guidance::DirectionModifier::SharpLeft ||
|
||||
instruction.direction_modifier == extractor::guidance::DirectionModifier::Left ||
|
||||
instruction.direction_modifier == extractor::guidance::DirectionModifier::SlightLeft;
|
||||
}
|
||||
|
||||
inline bool hasRightModifier(const extractor::guidance::TurnInstruction instruction)
|
||||
{
|
||||
return instruction.direction_modifier == extractor::guidance::DirectionModifier::SharpRight ||
|
||||
instruction.direction_modifier == extractor::guidance::DirectionModifier::Right ||
|
||||
instruction.direction_modifier == extractor::guidance::DirectionModifier::SlightRight;
|
||||
}
|
||||
|
||||
inline bool isLeftTurn(const extractor::guidance::TurnInstruction instruction)
|
||||
{
|
||||
switch (instruction.type)
|
||||
{
|
||||
case extractor::guidance::TurnType::Merge:
|
||||
return hasRightModifier(instruction);
|
||||
default:
|
||||
return hasLeftModifier(instruction);
|
||||
}
|
||||
}
|
||||
|
||||
inline bool isRightTurn(const extractor::guidance::TurnInstruction instruction)
|
||||
{
|
||||
switch (instruction.type)
|
||||
{
|
||||
case extractor::guidance::TurnType::Merge:
|
||||
return hasLeftModifier(instruction);
|
||||
default:
|
||||
return hasRightModifier(instruction);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace guidance
|
||||
} // namespace util
|
||||
} // namespace osrm
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
#ifndef OSRM_UTIL_GUIDANCE_TURN_LANES_HPP
|
||||
#define OSRM_UTIL_GUIDANCE_TURN_LANES_HPP
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <functional>
|
||||
#include <vector>
|
||||
|
||||
#include "util/typedefs.hpp"
|
||||
|
||||
#include <boost/functional/hash.hpp>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace util
|
||||
{
|
||||
namespace guidance
|
||||
{
|
||||
class LaneTupel;
|
||||
} // namespace guidance
|
||||
} // namespace util
|
||||
} // namespace osrm
|
||||
|
||||
namespace std
|
||||
{
|
||||
template <> struct hash<::osrm::util::guidance::LaneTupel>
|
||||
{
|
||||
inline std::size_t operator()(const ::osrm::util::guidance::LaneTupel &bearing_class) const;
|
||||
};
|
||||
} // namespace std
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace util
|
||||
{
|
||||
namespace guidance
|
||||
{
|
||||
|
||||
// The mapping of turn lanes can be done two values. We describe every turn by the number of
|
||||
// contributing lanes and the first lane from the right..
|
||||
// Given a road like this:
|
||||
// | | |
|
||||
// | | |
|
||||
// ----------- |
|
||||
// -^ |
|
||||
// ----------- -------------
|
||||
// -^ ->
|
||||
// --------------------------------
|
||||
// -v |
|
||||
// ---------- |
|
||||
// | |
|
||||
//
|
||||
// we generate a set of tuples in the form of:
|
||||
// (2,1), (1,1), (1,0) for left, through and right respectively
|
||||
class LaneTupel
|
||||
{
|
||||
public:
|
||||
LaneTupel();
|
||||
LaneTupel(const LaneID lanes_in_turn, const LaneID first_lane_from_the_right);
|
||||
|
||||
bool operator==(const LaneTupel other) const;
|
||||
bool operator!=(const LaneTupel other) const;
|
||||
bool operator<(const LaneTupel other) const;
|
||||
|
||||
LaneID lanes_in_turn;
|
||||
LaneID first_lane_from_the_right;
|
||||
|
||||
friend std::size_t std::hash<LaneTupel>::operator()(const LaneTupel &) const;
|
||||
};
|
||||
|
||||
} // namespace guidance
|
||||
} // namespace util
|
||||
} // namespace osrm
|
||||
|
||||
// make Bearing Class hasbable
|
||||
namespace std
|
||||
{
|
||||
inline size_t hash<::osrm::util::guidance::LaneTupel>::
|
||||
operator()(const ::osrm::util::guidance::LaneTupel &lane_tupel) const
|
||||
{
|
||||
return boost::hash_value(*reinterpret_cast<const std::uint16_t *>(&lane_tupel));
|
||||
}
|
||||
} // namespace std
|
||||
|
||||
#endif /* OSRM_UTIL_GUIDANCE_TURN_LANES_HPP */
|
||||
@@ -20,7 +20,7 @@ struct NodeBasedEdgeData
|
||||
NodeBasedEdgeData()
|
||||
: distance(INVALID_EDGE_WEIGHT), edge_id(SPECIAL_NODEID),
|
||||
name_id(std::numeric_limits<unsigned>::max()), access_restricted(false), reversed(false),
|
||||
roundabout(false), travel_mode(TRAVEL_MODE_INACCESSIBLE)
|
||||
roundabout(false), travel_mode(TRAVEL_MODE_INACCESSIBLE), lane_string_id(INVALID_LANE_STRINGID)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -31,10 +31,11 @@ struct NodeBasedEdgeData
|
||||
bool reversed,
|
||||
bool roundabout,
|
||||
bool startpoint,
|
||||
extractor::TravelMode travel_mode)
|
||||
extractor::TravelMode travel_mode,
|
||||
const LaneStringID lane_string_id)
|
||||
: distance(distance), edge_id(edge_id), name_id(name_id),
|
||||
access_restricted(access_restricted), reversed(reversed), roundabout(roundabout),
|
||||
startpoint(startpoint), travel_mode(travel_mode)
|
||||
startpoint(startpoint), travel_mode(travel_mode), lane_string_id(lane_string_id)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -46,6 +47,7 @@ struct NodeBasedEdgeData
|
||||
bool roundabout : 1;
|
||||
bool startpoint : 1;
|
||||
extractor::TravelMode travel_mode : 4;
|
||||
LaneStringID lane_string_id;
|
||||
extractor::guidance::RoadClassificationData road_classification;
|
||||
|
||||
bool IsCompatibleTo(const NodeBasedEdgeData &other) const
|
||||
@@ -80,6 +82,7 @@ NodeBasedDynamicGraphFromEdges(NodeID number_of_nodes,
|
||||
output_edge.data.travel_mode = input_edge.travel_mode;
|
||||
output_edge.data.startpoint = input_edge.startpoint;
|
||||
output_edge.data.road_classification = input_edge.road_classification;
|
||||
output_edge.data.lane_string_id = input_edge.lane_string_id;
|
||||
});
|
||||
|
||||
tbb::parallel_sort(edges_list.begin(), edges_list.end());
|
||||
|
||||
@@ -59,13 +59,18 @@ using EdgeID = std::uint32_t;
|
||||
using NameID = std::uint32_t;
|
||||
using EdgeWeight = std::int32_t;
|
||||
|
||||
using LaneStringID = std::uint16_t;
|
||||
using LaneID = std::uint8_t;
|
||||
static const LaneID INVALID_LANEID = std::numeric_limits<LaneID>::max();
|
||||
static const LaneStringID INVALID_LANE_STRINGID = std::numeric_limits<LaneStringID>::max();
|
||||
|
||||
using BearingClassID = std::uint32_t;
|
||||
static const BearingClassID INVALID_BEARING_CLASSID = std::numeric_limits<std::uint32_t>::max();
|
||||
static const BearingClassID INVALID_BEARING_CLASSID = std::numeric_limits<BearingClassID>::max();
|
||||
|
||||
using DiscreteBearing = std::uint16_t;
|
||||
|
||||
using EntryClassID = std::uint16_t;
|
||||
static const EntryClassID INVALID_ENTRY_CLASSID = std::numeric_limits<std::uint16_t>::max();
|
||||
static const EntryClassID INVALID_ENTRY_CLASSID = std::numeric_limits<EntryClassID>::max();
|
||||
|
||||
static const NodeID SPECIAL_NODEID = std::numeric_limits<NodeID>::max();
|
||||
static const NodeID SPECIAL_SEGMENTID = std::numeric_limits<NodeID>::max() >> 1;
|
||||
|
||||
Reference in New Issue
Block a user