Take stop signs into account during routing
This commit is contained in:
@@ -69,8 +69,8 @@ class EdgeBasedGraphFactory
|
||||
EdgeBasedNodeDataContainer &node_data_container,
|
||||
const CompressedEdgeContainer &compressed_edge_container,
|
||||
const std::unordered_set<NodeID> &barrier_nodes,
|
||||
const TrafficSignals &traffic_signals,
|
||||
const StopSigns &stop_signs,
|
||||
const TrafficFlowControlNodes &traffic_signals,
|
||||
const TrafficFlowControlNodes &stop_signs,
|
||||
const std::vector<util::Coordinate> &coordinates,
|
||||
const NameTable &name_table,
|
||||
const std::unordered_set<EdgeID> &segregated_edges,
|
||||
@@ -136,8 +136,8 @@ class EdgeBasedGraphFactory
|
||||
const util::NodeBasedDynamicGraph &m_node_based_graph;
|
||||
|
||||
const std::unordered_set<NodeID> &m_barrier_nodes;
|
||||
const TrafficSignals &m_traffic_signals;
|
||||
const StopSigns &m_stop_signs;
|
||||
const TrafficFlowControlNodes &m_traffic_signals;
|
||||
const TrafficFlowControlNodes &m_stop_signs;
|
||||
|
||||
const CompressedEdgeContainer &m_compressed_edge_container;
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
#include "extractor/scripting_environment.hpp"
|
||||
|
||||
#include "storage/tar_fwd.hpp"
|
||||
#include "traffic_lights.hpp"
|
||||
#include "traffic_signals.hpp"
|
||||
|
||||
#include <unordered_map>
|
||||
@@ -28,25 +27,22 @@ namespace extractor
|
||||
class ExtractionContainers
|
||||
{
|
||||
using ReferencedWays = std::unordered_map<OSMWayID, NodesOfWay>;
|
||||
using ReferencedTrafficSignals =
|
||||
using ReferencedTrafficFlowControlNodes =
|
||||
std::pair<std::unordered_set<OSMNodeID>, std::unordered_multimap<OSMNodeID, OSMNodeID>>;
|
||||
using ReferencedStopSigns =
|
||||
std::pair<std::unordered_set<OSMNodeID>, std::unordered_multimap<OSMNodeID, OSMNodeID>>;
|
||||
|
||||
// The relationship between way and nodes is lost during node preparation.
|
||||
// We identify the ways and nodes relevant to restrictions/overrides/signals prior to
|
||||
// node processing so that they can be referenced in the preparation phase.
|
||||
ReferencedWays IdentifyRestrictionWays();
|
||||
ReferencedWays IdentifyManeuverOverrideWays();
|
||||
ReferencedTrafficSignals IdentifyTrafficSignals();
|
||||
ReferencedStopSigns IdentifyStopSigns();
|
||||
ReferencedTrafficFlowControlNodes IdentifyTrafficSignals();
|
||||
ReferencedTrafficFlowControlNodes IdentifyStopSigns();
|
||||
|
||||
|
||||
void PrepareNodes();
|
||||
void PrepareManeuverOverrides(const ReferencedWays &maneuver_override_ways);
|
||||
void PrepareRestrictions(const ReferencedWays &restriction_ways);
|
||||
void PrepareTrafficSignals(const ReferencedTrafficSignals &referenced_traffic_signals);
|
||||
void PrepareStopSigns(const ReferencedStopSigns &referenced_stop_signs);
|
||||
void PrepareTrafficSignals(const ReferencedTrafficFlowControlNodes &referenced_traffic_signals);
|
||||
void PrepareStopSigns(const ReferencedTrafficFlowControlNodes &referenced_stop_signs);
|
||||
|
||||
void PrepareEdges(ScriptingEnvironment &scripting_environment);
|
||||
|
||||
@@ -61,10 +57,10 @@ class ExtractionContainers
|
||||
using NameOffsets = std::vector<size_t>;
|
||||
using WayIDVector = std::vector<OSMWayID>;
|
||||
using WayNodeIDOffsets = std::vector<size_t>;
|
||||
using InputTrafficSignal = std::pair<OSMNodeID, TrafficLightClass::Direction>;
|
||||
using InputStopSign = std::pair<OSMNodeID, StopSign::Direction>;
|
||||
using InputGiveWay = std::pair<OSMNodeID, GiveWay::Direction>;
|
||||
using InputTrafficFlowControlNode = std::pair<OSMNodeID, TrafficFlowControlNodeDirection>;
|
||||
|
||||
|
||||
|
||||
std::vector<OSMNodeID> barrier_nodes;
|
||||
NodeIDVector used_node_id_list;
|
||||
NodeVector all_nodes_list;
|
||||
@@ -78,15 +74,14 @@ class ExtractionContainers
|
||||
|
||||
unsigned max_internal_node_id;
|
||||
|
||||
std::vector<InputTrafficSignal> external_traffic_signals;
|
||||
TrafficSignals internal_traffic_signals;
|
||||
std::vector<InputTrafficFlowControlNode> external_traffic_signals;
|
||||
TrafficFlowControlNodes internal_traffic_signals;
|
||||
|
||||
|
||||
std::vector<InputStopSign> external_stop_signs;
|
||||
StopSigns internal_stop_signs;
|
||||
std::vector<InputTrafficFlowControlNode> external_stop_signs;
|
||||
TrafficFlowControlNodes internal_stop_signs;
|
||||
|
||||
std::vector<InputStopSign> external_give_ways;
|
||||
GiveWaySigns internal_give_ways;
|
||||
std::vector<InputTrafficFlowControlNode> external_give_ways;
|
||||
TrafficFlowControlNodes internal_give_ways;
|
||||
|
||||
std::vector<NodeBasedEdge> used_edges;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef EXTRACTION_NODE_HPP
|
||||
#define EXTRACTION_NODE_HPP
|
||||
|
||||
#include "traffic_lights.hpp"
|
||||
#include "traffic_signals.hpp"
|
||||
#include <cstdint>
|
||||
|
||||
namespace osrm
|
||||
@@ -12,20 +12,20 @@ namespace extractor
|
||||
|
||||
struct ExtractionNode
|
||||
{
|
||||
ExtractionNode() : traffic_lights(TrafficLightClass::NONE), barrier(false) {}
|
||||
ExtractionNode() : traffic_lights(TrafficFlowControlNodeDirection::NONE), barrier(false) {}
|
||||
void clear()
|
||||
{
|
||||
traffic_lights = TrafficLightClass::NONE;
|
||||
stop_sign = StopSign::Direction::NONE;
|
||||
give_way = GiveWay::Direction::NONE;
|
||||
traffic_lights = TrafficFlowControlNodeDirection::NONE;
|
||||
stop_sign = TrafficFlowControlNodeDirection::NONE;
|
||||
give_way = TrafficFlowControlNodeDirection::NONE;
|
||||
barrier = false;
|
||||
}
|
||||
TrafficLightClass::Direction traffic_lights;
|
||||
TrafficFlowControlNodeDirection traffic_lights;
|
||||
bool barrier;
|
||||
|
||||
|
||||
StopSign::Direction stop_sign;
|
||||
GiveWay::Direction give_way;
|
||||
TrafficFlowControlNodeDirection stop_sign;
|
||||
TrafficFlowControlNodeDirection give_way;
|
||||
};
|
||||
} // namespace extractor
|
||||
} // namespace osrm
|
||||
|
||||
@@ -66,8 +66,8 @@ class Extractor
|
||||
LaneDescriptionMap turn_lane_map;
|
||||
std::vector<TurnRestriction> turn_restrictions;
|
||||
std::vector<UnresolvedManeuverOverride> unresolved_maneuver_overrides;
|
||||
TrafficSignals traffic_signals;
|
||||
StopSigns stop_signs;
|
||||
TrafficFlowControlNodes traffic_signals;
|
||||
TrafficFlowControlNodes stop_signs;
|
||||
std::unordered_set<NodeID> barriers;
|
||||
std::vector<util::Coordinate> osm_coordinates;
|
||||
extractor::PackedOSMIDs osm_node_ids;
|
||||
@@ -87,8 +87,8 @@ class Extractor
|
||||
const std::vector<util::Coordinate> &coordinates,
|
||||
const CompressedEdgeContainer &compressed_edge_container,
|
||||
const std::unordered_set<NodeID> &barrier_nodes,
|
||||
const TrafficSignals &traffic_signals,
|
||||
const StopSigns &stop_signs,
|
||||
const TrafficFlowControlNodes &traffic_signals,
|
||||
const TrafficFlowControlNodes &stop_signs,
|
||||
const RestrictionGraph &restriction_graph,
|
||||
const std::unordered_set<EdgeID> &segregated_edges,
|
||||
const NameTable &name_table,
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
|
||||
namespace osmium
|
||||
{
|
||||
@@ -72,6 +73,7 @@ class ExtractorCallbacks
|
||||
bool fallback_to_duration;
|
||||
bool force_split_edges;
|
||||
|
||||
|
||||
public:
|
||||
using ClassesMap = std::unordered_map<std::string, ClassData>;
|
||||
|
||||
|
||||
@@ -26,8 +26,8 @@ class GraphCompressor
|
||||
|
||||
public:
|
||||
void Compress(const std::unordered_set<NodeID> &barrier_nodes,
|
||||
const TrafficSignals &traffic_signals,
|
||||
const StopSigns &stop_signs,
|
||||
const TrafficFlowControlNodes &traffic_signals,
|
||||
const TrafficFlowControlNodes &stop_signs,
|
||||
ScriptingEnvironment &scripting_environment,
|
||||
std::vector<TurnRestriction> &turn_restrictions,
|
||||
std::vector<UnresolvedManeuverOverride> &maneuver_overrides,
|
||||
|
||||
@@ -41,8 +41,8 @@ class NodeBasedGraphFactory
|
||||
NodeBasedGraphFactory(ScriptingEnvironment &scripting_environment,
|
||||
std::vector<TurnRestriction> &turn_restrictions,
|
||||
std::vector<UnresolvedManeuverOverride> &maneuver_overrides,
|
||||
const TrafficSignals &traffic_signals,
|
||||
const StopSigns &stop_signs,
|
||||
const TrafficFlowControlNodes &traffic_signals,
|
||||
const TrafficFlowControlNodes &stop_signs,
|
||||
|
||||
std::unordered_set<NodeID> &&barriers,
|
||||
std::vector<util::Coordinate> &&coordinates,
|
||||
@@ -75,8 +75,8 @@ class NodeBasedGraphFactory
|
||||
void Compress(ScriptingEnvironment &scripting_environment,
|
||||
std::vector<TurnRestriction> &turn_restrictions,
|
||||
std::vector<UnresolvedManeuverOverride> &maneuver_overrides,
|
||||
const TrafficSignals &traffic_signals,
|
||||
const StopSigns &stop_signs);
|
||||
const TrafficFlowControlNodes &traffic_signals,
|
||||
const TrafficFlowControlNodes &stop_signs);
|
||||
|
||||
// Most ways are bidirectional, making the geometry in forward and backward direction the same,
|
||||
// except for reversal. We make use of this fact by keeping only one representation of the
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
#ifndef OSRM_EXTRACTOR_TRAFFIC_LIGHTS_DATA_HPP_
|
||||
#define OSRM_EXTRACTOR_TRAFFIC_LIGHTS_DATA_HPP_
|
||||
|
||||
#include <cstdint>
|
||||
namespace osrm
|
||||
{
|
||||
namespace extractor
|
||||
{
|
||||
|
||||
namespace TrafficLightClass
|
||||
{
|
||||
// The traffic light annotation is extracted from node tags.
|
||||
// The directions in which the traffic light applies are relative to the way containing the node.
|
||||
enum Direction
|
||||
{
|
||||
NONE = 0,
|
||||
DIRECTION_ALL = 1,
|
||||
DIRECTION_FORWARD = 2,
|
||||
DIRECTION_REVERSE = 3
|
||||
};
|
||||
} // namespace TrafficLightClass
|
||||
|
||||
// Stop Signs tagged on nodes can be present or not. In addition Stop Signs have
|
||||
// an optional way direction they apply to. If the direction is unknown from the
|
||||
// data we have to compute by checking the distance to the next intersection.
|
||||
//
|
||||
// Impl. detail: namespace + enum instead of enum class to make Luabind happy
|
||||
namespace StopSign
|
||||
{
|
||||
enum Direction : std::uint8_t
|
||||
{
|
||||
NONE = 0,
|
||||
DIRECTION_ALL = 1,
|
||||
DIRECTION_FORWARD = 2,
|
||||
DIRECTION_REVERSE = 3
|
||||
};
|
||||
}
|
||||
|
||||
// Give Way is the complement to priority roads. Tagging is the same as Stop Signs.
|
||||
// See explanation above.
|
||||
namespace GiveWay
|
||||
{
|
||||
enum Direction : std::uint8_t
|
||||
{
|
||||
NONE = 0,
|
||||
DIRECTION_ALL = 1,
|
||||
DIRECTION_FORWARD = 2,
|
||||
DIRECTION_REVERSE = 3
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
} // namespace extractor
|
||||
} // namespace osrm
|
||||
|
||||
#endif // OSRM_EXTRACTOR_TRAFFIC_LIGHTS_DATA_HPP_
|
||||
@@ -11,26 +11,36 @@ namespace osrm
|
||||
namespace extractor
|
||||
{
|
||||
|
||||
// TODO: better naming
|
||||
struct RoadObjects
|
||||
// Stop Signs tagged on nodes can be present or not. In addition Stop Signs have
|
||||
// an optional way direction they apply to. If the direction is unknown from the
|
||||
// data we have to compute by checking the distance to the next intersection.
|
||||
//
|
||||
// Impl. detail: namespace + enum instead of enum class to make Luabind happy
|
||||
|
||||
|
||||
// The traffic light annotation is extracted from node tags.
|
||||
// The directions in which the traffic light applies are relative to the way containing the node.
|
||||
enum class TrafficFlowControlNodeDirection : std::uint8_t
|
||||
{
|
||||
NONE = 0,
|
||||
ALL = 1,
|
||||
FORWARD = 2,
|
||||
REVERSE = 3
|
||||
};
|
||||
|
||||
// represents traffic lights, stop signs, give way signs, etc.
|
||||
struct TrafficFlowControlNodes
|
||||
{
|
||||
std::unordered_set<NodeID> bidirectional_nodes;
|
||||
std::unordered_set<std::pair<NodeID, NodeID>, boost::hash<std::pair<NodeID, NodeID>>>
|
||||
unidirectional_segments;
|
||||
|
||||
inline bool HasSignal(NodeID from, NodeID to) const
|
||||
inline bool Has(NodeID from, NodeID to) const
|
||||
{
|
||||
return bidirectional_nodes.count(to) > 0 || unidirectional_segments.count({from, to}) > 0;
|
||||
}
|
||||
};
|
||||
|
||||
struct TrafficSignals final : public RoadObjects {};
|
||||
|
||||
// TODO: better naming ?
|
||||
struct StopSigns final : public RoadObjects {};
|
||||
struct GiveWaySigns final : public RoadObjects {};
|
||||
|
||||
|
||||
} // namespace extractor
|
||||
} // namespace osrm
|
||||
|
||||
|
||||
Reference in New Issue
Block a user