basic turn lane handling
This commit is contained in:
@@ -55,7 +55,8 @@ class EdgeBasedGraphFactory
|
||||
std::shared_ptr<const RestrictionMap> restriction_map,
|
||||
const std::vector<QueryNode> &node_info_list,
|
||||
ProfileProperties profile_properties,
|
||||
const util::NameTable &name_table);
|
||||
const util::NameTable &name_table,
|
||||
const util::NameTable &turn_lanes);
|
||||
|
||||
void Run(const std::string &original_edge_data_filename,
|
||||
lua_State *lua_state,
|
||||
@@ -117,6 +118,7 @@ class EdgeBasedGraphFactory
|
||||
ProfileProperties profile_properties;
|
||||
|
||||
const util::NameTable &name_table;
|
||||
const util::NameTable &turn_lanes;
|
||||
|
||||
void CompressGeometry();
|
||||
unsigned RenumberEdges();
|
||||
|
||||
@@ -37,7 +37,9 @@ class ExtractionContainers
|
||||
void WriteNodes(std::ofstream &file_out_stream) const;
|
||||
void WriteRestrictions(const std::string &restrictions_file_name) const;
|
||||
void WriteEdges(std::ofstream &file_out_stream) const;
|
||||
void WriteNames(const std::string &names_file_name) const;
|
||||
void WriteCharData(const std::string &file_name,
|
||||
const stxxl::vector<unsigned> &offests,
|
||||
const stxxl::vector<char> &char_data) const;
|
||||
|
||||
public:
|
||||
using STXXLNodeIDVector = stxxl::vector<OSMNodeID>;
|
||||
@@ -51,6 +53,8 @@ class ExtractionContainers
|
||||
STXXLEdgeVector all_edges_list;
|
||||
stxxl::vector<char> name_char_data;
|
||||
stxxl::vector<unsigned> name_lengths;
|
||||
stxxl::vector<char> turn_lane_char_data;
|
||||
stxxl::vector<unsigned> turn_lane_lengths;
|
||||
STXXLRestrictionsVector restrictions_list;
|
||||
STXXLWayIDStartEndVector way_start_end_id_list;
|
||||
std::unordered_map<OSMNodeID, NodeID> external_to_internal_node_id_map;
|
||||
@@ -61,6 +65,7 @@ class ExtractionContainers
|
||||
void PrepareData(const std::string &output_file_name,
|
||||
const std::string &restrictions_file_name,
|
||||
const std::string &names_file_name,
|
||||
const std::string &turn_lane_file_name,
|
||||
lua_State *segment_state);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
#include <limits>
|
||||
#include <string>
|
||||
|
||||
#include "extractor/guidance/toolkit.hpp"
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace extractor
|
||||
@@ -98,6 +100,12 @@ inline unsigned parseDuration(const std::string &s)
|
||||
|
||||
return !s.empty() && iter == s.end() ? duration : std::numeric_limits<unsigned>::max();
|
||||
}
|
||||
|
||||
inline std::string
|
||||
trimLaneString(std::string lane_string, std::int32_t count_left, std::int32_t count_right)
|
||||
{
|
||||
return extractor::guidance::trimLaneString(std::move(lane_string), count_left, count_right);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include "extractor/travel_mode.hpp"
|
||||
#include "util/typedefs.hpp"
|
||||
#include "util/guidance/turn_lanes.hpp"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@@ -35,6 +36,8 @@ struct ExtractionWay
|
||||
destinations.clear();
|
||||
forward_travel_mode = TRAVEL_MODE_INACCESSIBLE;
|
||||
backward_travel_mode = TRAVEL_MODE_INACCESSIBLE;
|
||||
turn_lanes_forward.clear();
|
||||
turn_lanes_backward.clear();
|
||||
}
|
||||
|
||||
// These accessors exists because it's not possible to take the address of a bitfield,
|
||||
@@ -50,6 +53,8 @@ struct ExtractionWay
|
||||
std::string name;
|
||||
std::string pronunciation;
|
||||
std::string destinations;
|
||||
std::string turn_lanes_forward;
|
||||
std::string turn_lanes_backward;
|
||||
bool roundabout;
|
||||
bool is_access_restricted;
|
||||
bool is_startpoint;
|
||||
|
||||
@@ -38,6 +38,7 @@ class ExtractorCallbacks
|
||||
using MapKey = std::pair<std::string, std::string>;
|
||||
using MapVal = unsigned;
|
||||
std::unordered_map<MapKey, MapVal, boost::hash<MapKey>> string_map;
|
||||
std::unordered_map<std::string, LaneStringID> lane_map;
|
||||
ExtractionContainers &external_memory;
|
||||
|
||||
public:
|
||||
|
||||
@@ -61,6 +61,7 @@ struct ExtractorConfig
|
||||
output_file_name = basepath + ".osrm";
|
||||
restriction_file_name = basepath + ".osrm.restrictions";
|
||||
names_file_name = basepath + ".osrm.names";
|
||||
turn_lane_file_name = basepath + ".osrm.tld";
|
||||
timestamp_file_name = basepath + ".osrm.timestamp";
|
||||
geometry_output_path = basepath + ".osrm.geometry";
|
||||
node_output_path = basepath + ".osrm.nodes";
|
||||
@@ -82,6 +83,7 @@ struct ExtractorConfig
|
||||
std::string output_file_name;
|
||||
std::string restriction_file_name;
|
||||
std::string names_file_name;
|
||||
std::string turn_lane_file_name;
|
||||
std::string timestamp_file_name;
|
||||
std::string geometry_output_path;
|
||||
std::string edge_output_path;
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
#ifndef OSRM_EXTRACTOR_GUIDANCE_DEBUG_HPP_
|
||||
#define OSRM_EXTRACTOR_GUIDANCE_DEBUG_HPP_
|
||||
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace extractor
|
||||
{
|
||||
namespace guidance
|
||||
{
|
||||
|
||||
inline void print(const LaneDataVector &turn_lane_data)
|
||||
{
|
||||
std::cout << " Tags:\n";
|
||||
for (auto entry : turn_lane_data)
|
||||
std::cout << "\t" << entry.tag << " from: " << static_cast<int>(entry.from)
|
||||
<< " to: " << static_cast<int>(entry.to) << "\n";
|
||||
std::cout << std::flush;
|
||||
}
|
||||
|
||||
inline void printTurnAssignmentData(const NodeID at,
|
||||
const LaneDataVector &turn_lane_data,
|
||||
const Intersection &intersection,
|
||||
const std::vector<QueryNode> &node_info_list)
|
||||
{
|
||||
std::cout << "[Turn Assignment Progress]\nLocation:";
|
||||
auto coordinate = node_info_list[at];
|
||||
std::cout << std::setprecision(12) << toFloating(coordinate.lat) << " "
|
||||
<< toFloating(coordinate.lon) << "\n";
|
||||
|
||||
std::cout << " Intersection:\n";
|
||||
for (const auto &road)
|
||||
std::cout << "\t" << toString(road) << "\n";
|
||||
|
||||
//flushes as well
|
||||
print(turn_lane_data);
|
||||
}
|
||||
|
||||
} // namespace guidance
|
||||
} // namespace extractor
|
||||
} // namespace osrm
|
||||
|
||||
#endif /* OSRM_EXTRACTOR_GUIDANCE_DEBUG_HPP_ */
|
||||
@@ -59,6 +59,9 @@ std::string toString(const ConnectedRoad &road);
|
||||
|
||||
typedef std::vector<ConnectedRoad> Intersection;
|
||||
|
||||
Intersection::const_iterator findClosestTurn(const Intersection &intersection, const double angle);
|
||||
Intersection::iterator findClosestTurn(Intersection &intersection, const double angle);
|
||||
|
||||
} // namespace guidance
|
||||
} // namespace extractor
|
||||
} // namespace osrm
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "extractor/restriction_map.hpp"
|
||||
#include "util/node_based_graph.hpp"
|
||||
#include "util/typedefs.hpp"
|
||||
#include "util/name_table.hpp"
|
||||
|
||||
#include <unordered_set>
|
||||
#include <vector>
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
#define OSRM_EXTRACTOR_GUIDANCE_MOTORWAY_HANDLER_HPP_
|
||||
|
||||
#include "extractor/guidance/intersection.hpp"
|
||||
#include "extractor/guidance/intersection_generator.hpp"
|
||||
#include "extractor/guidance/intersection_handler.hpp"
|
||||
#include "extractor/query_node.hpp"
|
||||
|
||||
@@ -26,8 +25,7 @@ class MotorwayHandler : public IntersectionHandler
|
||||
MotorwayHandler(const util::NodeBasedDynamicGraph &node_based_graph,
|
||||
const std::vector<QueryNode> &node_info_list,
|
||||
const util::NameTable &name_table,
|
||||
const SuffixTable &street_name_suffix_table,
|
||||
const IntersectionGenerator &intersection_generator);
|
||||
const SuffixTable &street_name_suffix_table);
|
||||
~MotorwayHandler() override final;
|
||||
|
||||
// check whether the handler can actually handle the intersection
|
||||
@@ -47,8 +45,6 @@ class MotorwayHandler : public IntersectionHandler
|
||||
Intersection fromRamp(const EdgeID via_edge, Intersection intersection) const;
|
||||
|
||||
Intersection fallback(Intersection intersection) const;
|
||||
|
||||
const IntersectionGenerator &intersection_generator;
|
||||
};
|
||||
|
||||
} // namespace guidance
|
||||
|
||||
@@ -476,6 +476,77 @@ inline bool hasRoundaboutType(const TurnInstruction instruction)
|
||||
return std::find(valid_types, valid_end, instruction.type) != valid_end;
|
||||
}
|
||||
|
||||
// Public service vehicle lanes and similar can introduce additional lanes into the lane string that
|
||||
// are not specifically marked for left/right turns. This function can be used from the profile to
|
||||
// trim the lane string appropriately
|
||||
//
|
||||
// left|throught|
|
||||
// in combination with lanes:psv:forward=1
|
||||
// will be corrected to left|throught, since the final lane is not drivable.
|
||||
// This is in contrast to a situation with lanes:psv:forward=0 (or not set) where left|through|
|
||||
// represents left|through|through
|
||||
inline std::string
|
||||
trimLaneString(std::string lane_string, std::int32_t count_left, std::int32_t count_right)
|
||||
{
|
||||
if (count_left)
|
||||
{
|
||||
bool sane = count_left < static_cast<std::int32_t>(lane_string.size());
|
||||
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] != '&')
|
||||
{
|
||||
sane = false;
|
||||
break;
|
||||
}
|
||||
|
||||
if (sane)
|
||||
{
|
||||
lane_string.erase(lane_string.begin(), lane_string.begin() + count_left);
|
||||
}
|
||||
}
|
||||
if (count_right)
|
||||
{
|
||||
bool sane = count_right < static_cast<std::int32_t>(lane_string.size());
|
||||
for (auto itr = lane_string.rbegin();
|
||||
itr != lane_string.rend() && itr != lane_string.rbegin() + count_right;
|
||||
++itr)
|
||||
{
|
||||
if (*itr != '|' && *itr != '&')
|
||||
{
|
||||
sane = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (sane)
|
||||
lane_string.resize(lane_string.size() - count_right);
|
||||
}
|
||||
return lane_string;
|
||||
}
|
||||
|
||||
inline bool entersRoundabout(const extractor::guidance::TurnInstruction instruction)
|
||||
{
|
||||
return (instruction.type == extractor::guidance::TurnType::EnterRoundabout ||
|
||||
instruction.type == extractor::guidance::TurnType::EnterRotary ||
|
||||
instruction.type == extractor::guidance::TurnType::EnterRoundaboutIntersection ||
|
||||
instruction.type == extractor::guidance::TurnType::EnterRoundaboutAtExit ||
|
||||
instruction.type == extractor::guidance::TurnType::EnterRotaryAtExit ||
|
||||
instruction.type == extractor::guidance::TurnType::EnterRoundaboutIntersectionAtExit ||
|
||||
instruction.type == extractor::guidance::TurnType::EnterAndExitRoundabout ||
|
||||
instruction.type == extractor::guidance::TurnType::EnterAndExitRotary ||
|
||||
instruction.type == extractor::guidance::TurnType::EnterAndExitRotary);
|
||||
}
|
||||
|
||||
inline bool leavesRoundabout(const extractor::guidance::TurnInstruction instruction)
|
||||
{
|
||||
return (instruction.type == extractor::guidance::TurnType::ExitRoundabout ||
|
||||
instruction.type == extractor::guidance::TurnType::ExitRotary ||
|
||||
instruction.type == extractor::guidance::TurnType::ExitRoundaboutIntersection ||
|
||||
instruction.type == extractor::guidance::TurnType::EnterAndExitRoundabout ||
|
||||
instruction.type == extractor::guidance::TurnType::EnterAndExitRotary ||
|
||||
instruction.type == extractor::guidance::TurnType::EnterAndExitRoundaboutIntersection);
|
||||
}
|
||||
|
||||
} // namespace guidance
|
||||
} // namespace extractor
|
||||
} // namespace osrm
|
||||
|
||||
@@ -44,10 +44,14 @@ class TurnAnalysis
|
||||
const SuffixTable &street_name_suffix_table);
|
||||
|
||||
// the entry into the turn analysis
|
||||
std::vector<TurnOperation> getTurns(const NodeID from_node, const EdgeID via_eid) const;
|
||||
|
||||
// access to the intersection representation for classification purposes
|
||||
Intersection getIntersection(const NodeID from_node, const EdgeID via_eid) const;
|
||||
Intersection
|
||||
assignTurnTypes(const NodeID from_node, const EdgeID via_eid, Intersection intersection) const;
|
||||
|
||||
std::vector<TurnOperation>
|
||||
transformIntersectionIntoTurns(const Intersection &intersection) const;
|
||||
|
||||
const IntersectionGenerator& getGenerator() const;
|
||||
|
||||
private:
|
||||
const util::NodeBasedDynamicGraph &node_based_graph;
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
#ifndef OSRM_EXTRACTOR_GUIDANCE_TURN_DISCOVERY_HPP_
|
||||
#define OSRM_EXTRACTOR_GUIDANCE_TURN_DISCOVERY_HPP_
|
||||
|
||||
#include "extractor/guidance/intersection.hpp"
|
||||
#include "extractor/guidance/turn_analysis.hpp"
|
||||
#include "util/typedefs.hpp"
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace extractor
|
||||
{
|
||||
namespace guidance
|
||||
{
|
||||
namespace lanes
|
||||
{
|
||||
|
||||
// OSRM processes edges by looking at a via_edge, coming into an intersection. For turn lanes, we
|
||||
// might require to actually look back a turn. We do so in the hope that the turn lanes match up at
|
||||
// the previous intersection for all incoming lanes.
|
||||
bool findPreviousIntersection(
|
||||
const NodeID node,
|
||||
const EdgeID via_edge,
|
||||
const Intersection intersection,
|
||||
const TurnAnalysis &turn_analysis, // to generate other intersections
|
||||
const util::NodeBasedDynamicGraph &node_based_graph, // query edge data
|
||||
// output parameters, will be in an arbitrary state on failure
|
||||
NodeID &result_node,
|
||||
EdgeID &result_via_edge,
|
||||
Intersection &result_intersection);
|
||||
|
||||
} // namespace lanes
|
||||
} // namespace guidance
|
||||
} // namespace extractor
|
||||
} // namespace osrm
|
||||
|
||||
#endif /*OSRM_EXTRACTOR_GUIDANCE_TURN_DISCOVERY_HPP_*/
|
||||
@@ -6,6 +6,8 @@
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
#include "extractor/guidance/roundabout_type.hpp"
|
||||
#include "util/guidance/turn_lanes.hpp"
|
||||
#include "util/typedefs.hpp"
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
@@ -53,48 +55,47 @@ const constexpr Enum EnterRotary = 12; // Enter a rotary
|
||||
const constexpr Enum EnterAndExitRotary = 13; // Touching a rotary
|
||||
const constexpr Enum EnterRoundaboutIntersection = 14; // Entering a small Roundabout
|
||||
const constexpr Enum EnterAndExitRoundaboutIntersection = 15; // Touching a roundabout
|
||||
const constexpr Enum UseLane = 16; // No Turn, but you need to stay on a given lane!
|
||||
|
||||
// Values below here are silent instructions
|
||||
const constexpr Enum NoTurn = 16; // end of segment without turn/middle of a segment
|
||||
const constexpr Enum Suppressed = 17; // location that suppresses a turn
|
||||
const constexpr Enum EnterRoundaboutAtExit = 18; // Entering a small Roundabout at a countable exit
|
||||
const constexpr Enum ExitRoundabout = 19; // Exiting a small Roundabout
|
||||
const constexpr Enum EnterRotaryAtExit = 20; // Enter A Rotary at a countable exit
|
||||
const constexpr Enum ExitRotary = 21; // Exit a rotary
|
||||
const constexpr Enum NoTurn = 17; // end of segment without turn/middle of a segment
|
||||
const constexpr Enum Suppressed = 18; // location that suppresses a turn
|
||||
const constexpr Enum EnterRoundaboutAtExit = 19; // Entering a small Roundabout at a countable exit
|
||||
const constexpr Enum ExitRoundabout = 20; // Exiting a small Roundabout
|
||||
const constexpr Enum EnterRotaryAtExit = 21; // Enter A Rotary at a countable exit
|
||||
const constexpr Enum ExitRotary = 22; // Exit a rotary
|
||||
const constexpr Enum EnterRoundaboutIntersectionAtExit =
|
||||
22; // Entering a small Roundabout at a countable exit
|
||||
const constexpr Enum ExitRoundaboutIntersection = 23; // Exiting a small Roundabout
|
||||
const constexpr Enum StayOnRoundabout = 24; // Continue on Either a small or a large Roundabout
|
||||
23; // Entering a small Roundabout at a countable exit
|
||||
const constexpr Enum ExitRoundaboutIntersection = 24; // Exiting a small Roundabout
|
||||
const constexpr Enum StayOnRoundabout = 25; // Continue on Either a small or a large Roundabout
|
||||
const constexpr Enum Sliproad =
|
||||
25; // Something that looks like a ramp, but is actually just a small sliproad
|
||||
26; // Something that looks like a ramp, but is actually just a small sliproad
|
||||
}
|
||||
|
||||
// turn angle in 1.40625 degree -> 128 == 180 degree
|
||||
struct TurnInstruction
|
||||
{
|
||||
using LaneTupel = util::guidance::LaneTupel;
|
||||
TurnInstruction(const TurnType::Enum type = TurnType::Invalid,
|
||||
const DirectionModifier::Enum direction_modifier = DirectionModifier::Straight)
|
||||
: type(type), direction_modifier(direction_modifier)
|
||||
const DirectionModifier::Enum direction_modifier = DirectionModifier::Straight,
|
||||
const LaneTupel lane_tupel = {0, INVALID_LANEID})
|
||||
: type(type), direction_modifier(direction_modifier), lane_tupel(lane_tupel)
|
||||
{
|
||||
}
|
||||
|
||||
TurnType::Enum type : 5;
|
||||
DirectionModifier::Enum direction_modifier : 3;
|
||||
// the lane tupel that is used for the turn
|
||||
LaneTupel lane_tupel;
|
||||
|
||||
static TurnInstruction INVALID()
|
||||
{
|
||||
return TurnInstruction(TurnType::Invalid, DirectionModifier::UTurn);
|
||||
}
|
||||
static TurnInstruction INVALID() { return {TurnType::Invalid, DirectionModifier::UTurn}; }
|
||||
|
||||
static TurnInstruction NO_TURN()
|
||||
{
|
||||
return TurnInstruction(TurnType::NoTurn, DirectionModifier::UTurn);
|
||||
}
|
||||
static TurnInstruction NO_TURN() { return {TurnType::NoTurn, DirectionModifier::UTurn}; }
|
||||
|
||||
static TurnInstruction REMAIN_ROUNDABOUT(const RoundaboutType,
|
||||
const DirectionModifier::Enum modifier)
|
||||
{
|
||||
return TurnInstruction(TurnType::StayOnRoundabout, modifier);
|
||||
return {TurnType::StayOnRoundabout, modifier};
|
||||
}
|
||||
|
||||
static TurnInstruction ENTER_ROUNDABOUT(const RoundaboutType roundabout_type,
|
||||
@@ -146,16 +147,18 @@ struct TurnInstruction
|
||||
}
|
||||
};
|
||||
|
||||
static_assert(sizeof(TurnInstruction) == 1, "TurnInstruction does not fit one byte");
|
||||
static_assert(sizeof(TurnInstruction) == 3, "TurnInstruction does not fit three byte");
|
||||
|
||||
inline bool operator!=(const TurnInstruction lhs, const TurnInstruction rhs)
|
||||
{
|
||||
return lhs.type != rhs.type || lhs.direction_modifier != rhs.direction_modifier;
|
||||
return lhs.type != rhs.type || lhs.direction_modifier != rhs.direction_modifier ||
|
||||
lhs.lane_tupel != rhs.lane_tupel;
|
||||
}
|
||||
|
||||
inline bool operator==(const TurnInstruction lhs, const TurnInstruction rhs)
|
||||
{
|
||||
return lhs.type == rhs.type && lhs.direction_modifier == rhs.direction_modifier;
|
||||
return lhs.type == rhs.type && lhs.direction_modifier == rhs.direction_modifier &&
|
||||
lhs.lane_tupel == rhs.lane_tupel;
|
||||
}
|
||||
|
||||
} // namespace guidance
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
#ifndef OSRM_EXTRACTOR_GUIDANCE_TURN_LANE_AUGMENTATION_HPP_
|
||||
#define OSRM_EXTRACTOR_GUIDANCE_TURN_LANE_AUGMENTATION_HPP_
|
||||
|
||||
#include "extractor/guidance/intersection.hpp"
|
||||
#include "extractor/guidance/turn_lane_data.hpp"
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace extractor
|
||||
{
|
||||
namespace guidance
|
||||
{
|
||||
namespace lanes
|
||||
{
|
||||
|
||||
LaneDataVector handleNoneValueAtSimpleTurn(LaneDataVector lane_data,
|
||||
const Intersection &intersection);
|
||||
|
||||
} // namespace lanes
|
||||
} // namespace guidance
|
||||
} // namespace extractor
|
||||
} // namespace osrm
|
||||
|
||||
#endif /* OSRM_EXTRACTOR_GUIDANCE_TURN_LANE_AUGMENTATION_HPP_ */
|
||||
@@ -0,0 +1,42 @@
|
||||
#ifndef OSRM_EXTRACTOR_GUIDANCE_TURN_LANE_DATA_HPP_
|
||||
#define OSRM_EXTRACTOR_GUIDANCE_TURN_LANE_DATA_HPP_
|
||||
|
||||
#include "util/typedefs.hpp"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace extractor
|
||||
{
|
||||
namespace guidance
|
||||
{
|
||||
namespace lanes
|
||||
{
|
||||
|
||||
struct TurnLaneData
|
||||
{
|
||||
std::string tag;
|
||||
LaneID from;
|
||||
LaneID to;
|
||||
|
||||
bool operator<(const TurnLaneData &other) const;
|
||||
};
|
||||
typedef std::vector<TurnLaneData> LaneDataVector;
|
||||
|
||||
// convertes a string given in the OSM format into a TurnLaneData vector
|
||||
LaneDataVector laneDataFromString(std::string turn_lane_string);
|
||||
|
||||
// Locate A Tag in a lane data vector
|
||||
LaneDataVector::const_iterator findTag(const std::string &tag, const LaneDataVector &data);
|
||||
LaneDataVector::iterator findTag(const std::string &tag, LaneDataVector &data);
|
||||
|
||||
bool hasTag(const std::string &tag, const LaneDataVector &data);
|
||||
|
||||
} // namespace lane_data_generation
|
||||
|
||||
} // namespace guidance
|
||||
} // namespace extractor
|
||||
} // namespace osrm
|
||||
|
||||
#endif /* OSRM_EXTRACTOR_GUIDANCE_TURN_LANE_DATA_HPP_ */
|
||||
@@ -0,0 +1,79 @@
|
||||
#ifndef OSRM_EXTRACTOR_GUIDANCE_TURN_LANE_HANDLER_HPP_
|
||||
#define OSRM_EXTRACTOR_GUIDANCE_TURN_LANE_HANDLER_HPP_
|
||||
|
||||
#include "extractor/guidance/intersection.hpp"
|
||||
#include "extractor/guidance/turn_analysis.hpp"
|
||||
#include "extractor/guidance/turn_lane_data.hpp"
|
||||
#include "extractor/query_node.hpp"
|
||||
|
||||
#include "util/guidance/turn_lanes.hpp"
|
||||
#include "util/name_table.hpp"
|
||||
#include "util/node_based_graph.hpp"
|
||||
#include "util/typedefs.hpp"
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace extractor
|
||||
{
|
||||
namespace guidance
|
||||
{
|
||||
|
||||
// Given an Intersection, the graph to access the data and the turn lanes, the turn lane matcher
|
||||
// assigns appropriate turn tupels to the different turns.
|
||||
namespace lanes
|
||||
{
|
||||
class TurnLaneHandler
|
||||
{
|
||||
public:
|
||||
typedef std::vector<TurnLaneData> LaneDataVector;
|
||||
|
||||
TurnLaneHandler(const util::NodeBasedDynamicGraph &node_based_graph,
|
||||
const util::NameTable &turn_lane_strings,
|
||||
const std::vector<QueryNode> &node_info_list,
|
||||
const TurnAnalysis &turn_analysis);
|
||||
|
||||
Intersection
|
||||
assignTurnLanes(const NodeID at, const EdgeID via_edge, Intersection intersection) const;
|
||||
|
||||
private:
|
||||
using LaneTupel = util::guidance::LaneTupel;
|
||||
std::unordered_map<LaneTupel, std::uint16_t> lane_tupels;
|
||||
|
||||
// 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 util::NameTable &turn_lane_strings;
|
||||
const std::vector<QueryNode> &node_info_list;
|
||||
const TurnAnalysis &turn_analysis;
|
||||
|
||||
// check whether we can handle an intersection
|
||||
bool isSimpleIntersection(const LaneDataVector &turn_lane_data,
|
||||
const Intersection &intersection) const;
|
||||
|
||||
// in case of a simple intersection, assign the lane entries
|
||||
Intersection simpleMatchTuplesToTurns(Intersection intersection,
|
||||
const LaneDataVector &lane_data) const;
|
||||
|
||||
// partition lane data into lane data relevant at current turn and at next turn
|
||||
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
|
||||
Intersection handleTurnAtPreviousIntersection(const NodeID at,
|
||||
const EdgeID via_edge,
|
||||
Intersection intersection) const;
|
||||
};
|
||||
|
||||
} // namespace lanes
|
||||
} // namespace guidance
|
||||
} // namespace extractor
|
||||
} // namespace osrm
|
||||
|
||||
#endif // OSRM_EXTRACTOR_GUIDANCE_TURN_LANE_HANDLER_HPP_
|
||||
@@ -0,0 +1,54 @@
|
||||
#ifndef OSRM_EXTRACTOR_GUIDANCE_TURN_LANE_MATCHER_HPP_
|
||||
#define OSRM_EXTRACTOR_GUIDANCE_TURN_LANE_MATCHER_HPP_
|
||||
|
||||
#include "extractor/guidance/intersection.hpp"
|
||||
#include "extractor/guidance/turn_instruction.hpp"
|
||||
#include "extractor/guidance/turn_lane_data.hpp"
|
||||
|
||||
#include "util/guidance/turn_lanes.hpp"
|
||||
#include "util/node_based_graph.hpp"
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace extractor
|
||||
{
|
||||
namespace guidance
|
||||
{
|
||||
namespace lanes
|
||||
{
|
||||
|
||||
// Translate Turn Lane Tags into a matching modifier
|
||||
DirectionModifier::Enum getMatchingModifier(const std::string &tag);
|
||||
|
||||
// check whether a match of a given tag and a turn instruction can be seen as valid
|
||||
bool isValidMatch(const std::string &tag, const TurnInstruction instruction);
|
||||
|
||||
// Every tag is somewhat idealized in form of the expected angle. A through lane should go straight
|
||||
// (or follow a 180 degree turn angle between in/out segments.) The following function tries to find
|
||||
// the best possible match for every tag in a given intersection, considering a few corner cases
|
||||
// introduced to OSRM handling u-turns
|
||||
typename Intersection::const_iterator findBestMatch(const std::string &tag,
|
||||
const Intersection &intersection);
|
||||
// Reverse is a special case, because it requires access to the leftmost tag. It has its own
|
||||
// matching function as a result of that. The leftmost tag is required, since u-turns are disabled
|
||||
// by default in OSRM. Therefor we cannot check whether a turn is allowed, since it could be
|
||||
// possible that it is forbidden. In addition, the best u-turn angle does not necessarily represent
|
||||
// the u-turn, since it could be a sharp-left turn instead on a road with a middle island.
|
||||
typename Intersection::const_iterator findBestMatchForReverse(const std::string &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
|
||||
bool canMatchTrivially(const Intersection &intersection, const LaneDataVector &lane_data);
|
||||
|
||||
// perform a trivial match on the turn lanes
|
||||
Intersection triviallyMatchLanesToTurns(Intersection intersection,
|
||||
const LaneDataVector &lane_data,
|
||||
const util::NodeBasedDynamicGraph &node_based_graph);
|
||||
|
||||
} // namespace lanes
|
||||
} // namespace guidance
|
||||
} // namespace extractor
|
||||
} // namespace osrm
|
||||
|
||||
#endif /*OSRM_EXTRACTOR_GUIDANCE_TURN_LANE_MATCHER_HPP_*/
|
||||
@@ -29,7 +29,6 @@ struct InternalExtractorEdge
|
||||
|
||||
struct WeightData
|
||||
{
|
||||
|
||||
WeightData() : duration(0.0), type(WeightType::INVALID) {}
|
||||
|
||||
union {
|
||||
@@ -51,6 +50,7 @@ struct InternalExtractorEdge
|
||||
true,
|
||||
TRAVEL_MODE_INACCESSIBLE,
|
||||
false,
|
||||
INVALID_LANE_STRINGID,
|
||||
guidance::RoadClassificationData())
|
||||
{
|
||||
}
|
||||
@@ -66,6 +66,7 @@ struct InternalExtractorEdge
|
||||
bool startpoint,
|
||||
TravelMode travel_mode,
|
||||
bool is_split,
|
||||
const LaneStringID lane_id,
|
||||
guidance::RoadClassificationData road_classification)
|
||||
: result(OSMNodeID(source),
|
||||
OSMNodeID(target),
|
||||
@@ -78,6 +79,7 @@ struct InternalExtractorEdge
|
||||
startpoint,
|
||||
travel_mode,
|
||||
is_split,
|
||||
lane_id,
|
||||
std::move(road_classification)),
|
||||
weight_data(std::move(weight_data))
|
||||
{
|
||||
@@ -104,6 +106,7 @@ struct InternalExtractorEdge
|
||||
true,
|
||||
TRAVEL_MODE_INACCESSIBLE,
|
||||
false,
|
||||
INVALID_LANE_STRINGID,
|
||||
guidance::RoadClassificationData());
|
||||
}
|
||||
static InternalExtractorEdge max_osm_value()
|
||||
@@ -119,6 +122,7 @@ struct InternalExtractorEdge
|
||||
true,
|
||||
TRAVEL_MODE_INACCESSIBLE,
|
||||
false,
|
||||
INVALID_LANE_STRINGID,
|
||||
guidance::RoadClassificationData());
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ struct NodeBasedEdge
|
||||
bool startpoint,
|
||||
TravelMode travel_mode,
|
||||
bool is_split,
|
||||
const LaneStringID lane_id,
|
||||
guidance::RoadClassificationData road_classification);
|
||||
|
||||
bool operator<(const NodeBasedEdge &other) const;
|
||||
@@ -41,6 +42,7 @@ struct NodeBasedEdge
|
||||
bool startpoint : 1;
|
||||
bool is_split : 1;
|
||||
TravelMode travel_mode : 4;
|
||||
LaneStringID lane_string_id;
|
||||
guidance::RoadClassificationData road_classification;
|
||||
};
|
||||
|
||||
@@ -57,6 +59,7 @@ struct NodeBasedEdgeWithOSM : NodeBasedEdge
|
||||
bool startpoint,
|
||||
TravelMode travel_mode,
|
||||
bool is_split,
|
||||
const LaneStringID lane_string_id,
|
||||
guidance::RoadClassificationData road_classification);
|
||||
|
||||
OSMNodeID osm_source_id;
|
||||
@@ -68,7 +71,7 @@ struct NodeBasedEdgeWithOSM : NodeBasedEdge
|
||||
inline NodeBasedEdge::NodeBasedEdge()
|
||||
: source(SPECIAL_NODEID), target(SPECIAL_NODEID), name_id(0), weight(0), forward(false),
|
||||
backward(false), roundabout(false), access_restricted(false), startpoint(true),
|
||||
is_split(false), travel_mode(false)
|
||||
is_split(false), travel_mode(false), lane_string_id(0)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -83,10 +86,11 @@ inline NodeBasedEdge::NodeBasedEdge(NodeID source,
|
||||
bool startpoint,
|
||||
TravelMode travel_mode,
|
||||
bool is_split,
|
||||
const LaneStringID lane_string_id,
|
||||
guidance::RoadClassificationData road_classification)
|
||||
: source(source), target(target), name_id(name_id), weight(weight), forward(forward),
|
||||
backward(backward), roundabout(roundabout), access_restricted(access_restricted),
|
||||
startpoint(startpoint), is_split(is_split), travel_mode(travel_mode),
|
||||
startpoint(startpoint), is_split(is_split), travel_mode(travel_mode), lane_string_id(lane_string_id),
|
||||
road_classification(std::move(road_classification))
|
||||
{
|
||||
}
|
||||
@@ -120,6 +124,7 @@ inline NodeBasedEdgeWithOSM::NodeBasedEdgeWithOSM(
|
||||
bool startpoint,
|
||||
TravelMode travel_mode,
|
||||
bool is_split,
|
||||
const LaneStringID lane_string_id,
|
||||
guidance::RoadClassificationData road_classification)
|
||||
: NodeBasedEdge(SPECIAL_NODEID,
|
||||
SPECIAL_NODEID,
|
||||
@@ -132,6 +137,7 @@ inline NodeBasedEdgeWithOSM::NodeBasedEdgeWithOSM(
|
||||
startpoint,
|
||||
travel_mode,
|
||||
is_split,
|
||||
lane_string_id,
|
||||
std::move(road_classification)),
|
||||
osm_source_id(std::move(source)), osm_target_id(std::move(target))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user