Use immutable node-based-graph for segregated edges.
This commit is contained in:
parent
32e6ccb037
commit
90e361c3dc
@ -75,6 +75,7 @@ class EdgeBasedGraphFactory
|
||||
const std::unordered_set<NodeID> &traffic_lights,
|
||||
const std::vector<util::Coordinate> &coordinates,
|
||||
const util::NameTable &name_table,
|
||||
const std::unordered_set<EdgeID> &segregated_edges,
|
||||
guidance::LaneDescriptionMap &lane_description_map);
|
||||
|
||||
void Run(ScriptingEnvironment &scripting_environment,
|
||||
@ -157,6 +158,7 @@ class EdgeBasedGraphFactory
|
||||
const CompressedEdgeContainer &m_compressed_edge_container;
|
||||
|
||||
const util::NameTable &name_table;
|
||||
const std::unordered_set<EdgeID> &segregated_edges;
|
||||
guidance::LaneDescriptionMap &lane_description_map;
|
||||
|
||||
// In the edge based graph, any traversable (non reversed) edge of the node-based graph forms a
|
||||
|
@ -72,6 +72,7 @@ class Extractor
|
||||
const std::unordered_set<NodeID> &traffic_lights,
|
||||
const std::vector<TurnRestriction> &turn_restrictions,
|
||||
const std::vector<ConditionalTurnRestriction> &conditional_turn_restrictions,
|
||||
const std::unordered_set<EdgeID> &segregated_edges,
|
||||
// might have to be updated to add new lane combinations
|
||||
guidance::LaneDescriptionMap &turn_lane_map,
|
||||
// for calculating turn penalties
|
||||
@ -102,7 +103,7 @@ class Extractor
|
||||
const std::string &path,
|
||||
std::vector<ConditionalTurnRestriction> &conditional_turn_restrictions);
|
||||
|
||||
size_t FindSegregatedNodes(NodeBasedGraphFactory &factory);
|
||||
std::unordered_set<EdgeID> FindSegregatedNodes(NodeBasedGraphFactory &factory);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ class NodeBasedGraphFactory
|
||||
std::vector<TurnRestriction> &turn_restrictions,
|
||||
std::vector<ConditionalTurnRestriction> &conditional_turn_restrictions);
|
||||
|
||||
auto &GetGraph() { return compressed_output_graph; }
|
||||
auto const &GetGraph() { return compressed_output_graph; }
|
||||
auto const &GetBarriers() const { return barriers; }
|
||||
auto const &GetTrafficSignals() const { return traffic_signals; }
|
||||
auto &GetCompressedEdges() { return compressed_edge_container; }
|
||||
|
@ -22,7 +22,7 @@ struct NodeBasedEdgeData
|
||||
{
|
||||
NodeBasedEdgeData()
|
||||
: weight(INVALID_EDGE_WEIGHT), duration(INVALID_EDGE_WEIGHT), geometry_id({0, false}),
|
||||
reversed(false), segregated(false), annotation_data(-1)
|
||||
reversed(false), annotation_data(-1)
|
||||
{
|
||||
}
|
||||
|
||||
@ -33,7 +33,7 @@ struct NodeBasedEdgeData
|
||||
extractor::NodeBasedEdgeClassification flags,
|
||||
AnnotationID annotation_data)
|
||||
: weight(weight), duration(duration), geometry_id(geometry_id), reversed(reversed),
|
||||
segregated(false), flags(flags), annotation_data(annotation_data)
|
||||
flags(flags), annotation_data(annotation_data)
|
||||
{
|
||||
}
|
||||
|
||||
@ -41,7 +41,6 @@ struct NodeBasedEdgeData
|
||||
EdgeWeight duration;
|
||||
GeometryID geometry_id;
|
||||
bool reversed : 1;
|
||||
bool segregated : 1;
|
||||
extractor::NodeBasedEdgeClassification flags;
|
||||
AnnotationID annotation_data;
|
||||
};
|
||||
|
@ -67,12 +67,13 @@ EdgeBasedGraphFactory::EdgeBasedGraphFactory(
|
||||
const std::unordered_set<NodeID> &traffic_lights,
|
||||
const std::vector<util::Coordinate> &coordinates,
|
||||
const util::NameTable &name_table,
|
||||
const std::unordered_set<EdgeID> &segregated_edges,
|
||||
guidance::LaneDescriptionMap &lane_description_map)
|
||||
: m_edge_based_node_container(node_data_container), m_number_of_edge_based_nodes(0),
|
||||
m_coordinates(coordinates), m_node_based_graph(std::move(node_based_graph)),
|
||||
m_barrier_nodes(barrier_nodes), m_traffic_lights(traffic_lights),
|
||||
m_compressed_edge_container(compressed_edge_container), name_table(name_table),
|
||||
lane_description_map(lane_description_map)
|
||||
segregated_edges(segregated_edges), lane_description_map(lane_description_map)
|
||||
{
|
||||
}
|
||||
|
||||
@ -165,7 +166,7 @@ NBGToEBG EdgeBasedGraphFactory::InsertEdgeBasedNode(const NodeID node_u, const N
|
||||
m_edge_based_node_container.nodes[nbe_to_ebn_mapping[edge_id_1]].annotation_id =
|
||||
forward_data.annotation_data;
|
||||
m_edge_based_node_container.nodes[nbe_to_ebn_mapping[edge_id_1]].segregated =
|
||||
forward_data.segregated;
|
||||
segregated_edges.count(edge_id_1) > 0;
|
||||
|
||||
if (nbe_to_ebn_mapping[edge_id_2] != SPECIAL_EDGEID)
|
||||
{
|
||||
@ -174,7 +175,7 @@ NBGToEBG EdgeBasedGraphFactory::InsertEdgeBasedNode(const NodeID node_u, const N
|
||||
m_edge_based_node_container.nodes[nbe_to_ebn_mapping[edge_id_2]].annotation_id =
|
||||
reverse_data.annotation_data;
|
||||
m_edge_based_node_container.nodes[nbe_to_ebn_mapping[edge_id_2]].segregated =
|
||||
reverse_data.segregated;
|
||||
segregated_edges.count(edge_id_2) > 0;
|
||||
}
|
||||
|
||||
// Add segments of edge-based nodes
|
||||
@ -371,7 +372,8 @@ EdgeBasedGraphFactory::GenerateEdgeExpandedNodes(const WayRestrictionMap &way_re
|
||||
edge_data.geometry_id;
|
||||
m_edge_based_node_container.nodes[edge_based_node_id].annotation_id =
|
||||
edge_data.annotation_data;
|
||||
m_edge_based_node_container.nodes[edge_based_node_id].segregated = edge_data.segregated;
|
||||
m_edge_based_node_container.nodes[edge_based_node_id].segregated =
|
||||
segregated_edges.count(eid) > 0;
|
||||
|
||||
m_edge_based_node_weights.push_back(m_edge_based_node_weights[eid]);
|
||||
|
||||
|
@ -220,11 +220,11 @@ int Extractor::run(ScriptingEnvironment &scripting_environment)
|
||||
util::Log() << "Find segregated edges in node-based graph ..." << std::flush;
|
||||
TIMER_START(segregated);
|
||||
|
||||
const size_t segregated_count = FindSegregatedNodes(node_based_graph_factory);
|
||||
auto segregated_edges = FindSegregatedNodes(node_based_graph_factory);
|
||||
|
||||
TIMER_STOP(segregated);
|
||||
util::Log() << "ok, after " << TIMER_SEC(segregated) << "s";
|
||||
util::Log() << "Segregated edges count = " << segregated_count;
|
||||
util::Log() << "Segregated edges count = " << segregated_edges.size();
|
||||
|
||||
util::Log() << "Writing nodes for nodes-based and edges-based graphs ...";
|
||||
auto const &coordinates = node_based_graph_factory.GetCoordinates();
|
||||
@ -277,6 +277,7 @@ int Extractor::run(ScriptingEnvironment &scripting_environment)
|
||||
traffic_signals,
|
||||
turn_restrictions,
|
||||
conditional_turn_restrictions,
|
||||
segregated_edges,
|
||||
turn_lane_map,
|
||||
scripting_environment,
|
||||
edge_based_nodes_container,
|
||||
@ -664,6 +665,7 @@ EdgeID Extractor::BuildEdgeExpandedGraph(
|
||||
const std::unordered_set<NodeID> &traffic_signals,
|
||||
const std::vector<TurnRestriction> &turn_restrictions,
|
||||
const std::vector<ConditionalTurnRestriction> &conditional_turn_restrictions,
|
||||
const std::unordered_set<EdgeID> &segregated_edges,
|
||||
// might have to be updated to add new lane combinations
|
||||
guidance::LaneDescriptionMap &turn_lane_map,
|
||||
// for calculating turn penalties
|
||||
@ -685,6 +687,7 @@ EdgeID Extractor::BuildEdgeExpandedGraph(
|
||||
traffic_signals,
|
||||
coordinates,
|
||||
name_table,
|
||||
segregated_edges,
|
||||
turn_lane_map);
|
||||
|
||||
const auto create_edge_based_edges = [&]() {
|
||||
@ -949,11 +952,11 @@ bool IsSegregated(std::vector<EdgeInfo> v1,
|
||||
return edgeLength <= threshold;
|
||||
}
|
||||
|
||||
size_t Extractor::FindSegregatedNodes(NodeBasedGraphFactory &factory)
|
||||
std::unordered_set<EdgeID> Extractor::FindSegregatedNodes(NodeBasedGraphFactory &factory)
|
||||
{
|
||||
util::NameTable names(config.GetPath(".osrm.names").string());
|
||||
|
||||
auto &graph = factory.GetGraph();
|
||||
auto const &graph = factory.GetGraph();
|
||||
auto const &annotation = factory.GetAnnotationData();
|
||||
|
||||
guidance::CoordinateExtractor coordExtractor(
|
||||
@ -1039,16 +1042,16 @@ size_t Extractor::FindSegregatedNodes(NodeBasedGraphFactory &factory)
|
||||
edgeLength);
|
||||
};
|
||||
|
||||
size_t segregated_count = 0;
|
||||
std::unordered_set<EdgeID> segregated_edges;
|
||||
|
||||
for (NodeID sourceID = 0; sourceID < graph.GetNumberOfNodes(); ++sourceID)
|
||||
{
|
||||
auto const sourceEdges = graph.GetAdjacentEdgeRange(sourceID);
|
||||
for (EdgeID edgeID : sourceEdges)
|
||||
{
|
||||
auto &edgeData = graph.GetEdgeData(edgeID);
|
||||
auto const &edgeData = graph.GetEdgeData(edgeID);
|
||||
|
||||
if (edgeData.reversed || edgeData.segregated)
|
||||
if (edgeData.reversed)
|
||||
continue;
|
||||
|
||||
NodeID const targetID = graph.GetTarget(edgeID);
|
||||
@ -1056,14 +1059,11 @@ size_t Extractor::FindSegregatedNodes(NodeBasedGraphFactory &factory)
|
||||
|
||||
double const length = get_edge_length(sourceID, edgeID, targetID);
|
||||
if (isSegregatedFn(edgeData, sourceEdges, sourceID, targetEdges, targetID, length))
|
||||
{
|
||||
++segregated_count;
|
||||
edgeData.segregated = true;
|
||||
}
|
||||
segregated_edges.insert(edgeID);
|
||||
}
|
||||
}
|
||||
|
||||
return segregated_count;
|
||||
return segregated_edges;
|
||||
}
|
||||
|
||||
} // namespace extractor
|
||||
|
Loading…
Reference in New Issue
Block a user