Remove all boundary nodes and use simple u-v-stragtegy to pick id
This commit removes all occurences of unconnected boundary nodes and switches to the simple heuristic of picking U for the forward and V for the backward node. This performs better than several fancy heuristics.
This commit is contained in:
committed by
Patrick Niklaus
parent
bf6698f4cc
commit
57c6c6e51c
@@ -2,7 +2,7 @@
|
||||
#include "extractor/edge_based_edge.hpp"
|
||||
#include "extractor/guidance/turn_analysis.hpp"
|
||||
#include "extractor/guidance/turn_lane_handler.hpp"
|
||||
#include "extractor/node_based_graph_to_edge_based_graph_mapping_writer.hpp"
|
||||
#include "extractor/io.hpp"
|
||||
#include "extractor/scripting_environment.hpp"
|
||||
#include "extractor/suffix_table.hpp"
|
||||
|
||||
@@ -94,8 +94,7 @@ void EdgeBasedGraphFactory::GetEdgeBasedNodeWeights(std::vector<EdgeWeight> &out
|
||||
|
||||
EdgeID EdgeBasedGraphFactory::GetHighestEdgeID() { return m_max_edge_id; }
|
||||
|
||||
boost::optional<EdgeBasedGraphFactory::Mapping>
|
||||
EdgeBasedGraphFactory::InsertEdgeBasedNode(const NodeID node_u, const NodeID node_v)
|
||||
NBGToEBG EdgeBasedGraphFactory::InsertEdgeBasedNode(const NodeID node_u, const NodeID node_v)
|
||||
{
|
||||
// merge edges together into one EdgeBasedNode
|
||||
BOOST_ASSERT(node_u != SPECIAL_NODEID);
|
||||
@@ -113,10 +112,7 @@ EdgeBasedGraphFactory::InsertEdgeBasedNode(const NodeID node_u, const NodeID nod
|
||||
|
||||
const EdgeData &reverse_data = m_node_based_graph->GetEdgeData(edge_id_2);
|
||||
|
||||
if (forward_data.edge_id == SPECIAL_NODEID && reverse_data.edge_id == SPECIAL_NODEID)
|
||||
{
|
||||
return boost::none;
|
||||
}
|
||||
BOOST_ASSERT(forward_data.edge_id != SPECIAL_NODEID || reverse_data.edge_id != SPECIAL_NODEID);
|
||||
|
||||
if (forward_data.edge_id != SPECIAL_NODEID && reverse_data.edge_id == SPECIAL_NODEID)
|
||||
m_edge_based_node_weights[forward_data.edge_id] = INVALID_EDGE_WEIGHT;
|
||||
@@ -176,7 +172,7 @@ EdgeBasedGraphFactory::InsertEdgeBasedNode(const NodeID node_u, const NodeID nod
|
||||
|
||||
BOOST_ASSERT(current_edge_source_coordinate_id == node_v);
|
||||
|
||||
return Mapping{node_u, node_v, forward_data.edge_id, reverse_data.edge_id};
|
||||
return NBGToEBG{node_u, node_v, forward_data.edge_id, reverse_data.edge_id};
|
||||
}
|
||||
|
||||
void EdgeBasedGraphFactory::FlushVectorToStream(
|
||||
@@ -207,7 +203,10 @@ void EdgeBasedGraphFactory::Run(ScriptingEnvironment &scripting_environment,
|
||||
|
||||
TIMER_START(generate_nodes);
|
||||
m_edge_based_node_weights.reserve(m_max_edge_id + 1);
|
||||
GenerateEdgeExpandedNodes(cnbg_ebg_mapping_path);
|
||||
{
|
||||
auto mapping = GenerateEdgeExpandedNodes();
|
||||
io::write(cnbg_ebg_mapping_path, mapping);
|
||||
}
|
||||
TIMER_STOP(generate_nodes);
|
||||
|
||||
TIMER_START(generate_edges);
|
||||
@@ -259,12 +258,9 @@ unsigned EdgeBasedGraphFactory::RenumberEdges()
|
||||
}
|
||||
|
||||
/// Creates the nodes in the edge expanded graph from edges in the node-based graph.
|
||||
void EdgeBasedGraphFactory::GenerateEdgeExpandedNodes(const std::string &cnbg_ebg_mapping_path)
|
||||
std::vector<NBGToEBG> EdgeBasedGraphFactory::GenerateEdgeExpandedNodes()
|
||||
{
|
||||
// Optional writer, for writing out a mapping. Neither default ctor not boost::optional work
|
||||
// with the underlying FileWriter, so hack around that limitation with a unique_ptr.
|
||||
std::unique_ptr<NodeBasedGraphToEdgeBasedGraphMappingWriter> writer;
|
||||
writer = std::make_unique<NodeBasedGraphToEdgeBasedGraphMappingWriter>(cnbg_ebg_mapping_path);
|
||||
std::vector<NBGToEBG> mapping;
|
||||
|
||||
util::Log() << "Generating edge expanded nodes ... ";
|
||||
{
|
||||
@@ -295,21 +291,14 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedNodes(const std::string &cnbg_eb
|
||||
|
||||
BOOST_ASSERT(node_u < node_v);
|
||||
|
||||
boost::optional<Mapping> mapping;
|
||||
|
||||
// if we found a non-forward edge reverse and try again
|
||||
if (edge_data.edge_id == SPECIAL_NODEID)
|
||||
{
|
||||
mapping = InsertEdgeBasedNode(node_v, node_u);
|
||||
mapping.push_back(InsertEdgeBasedNode(node_v, node_u));
|
||||
}
|
||||
else
|
||||
{
|
||||
mapping = InsertEdgeBasedNode(node_u, node_v);
|
||||
}
|
||||
|
||||
if (mapping)
|
||||
{
|
||||
writer->WriteMapping(mapping->u, mapping->v, mapping->head, mapping->tail);
|
||||
mapping.push_back(InsertEdgeBasedNode(node_u, node_v));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -319,6 +308,8 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedNodes(const std::string &cnbg_eb
|
||||
BOOST_ASSERT(m_max_edge_id + 1 == m_edge_based_node_weights.size());
|
||||
|
||||
util::Log() << "Generated " << m_edge_based_node_list.size() << " nodes in edge-expanded graph";
|
||||
|
||||
return mapping;
|
||||
}
|
||||
|
||||
/// Actually it also generates OriginalEdgeData and serializes them...
|
||||
|
||||
Reference in New Issue
Block a user