Use copressed node-based graph for segregated edges check.
This commit is contained in:
parent
ec7e58e10e
commit
76f793533a
@ -36,11 +36,10 @@ class NodeBasedGraphFactory
|
|||||||
// node-based graph to represent the OSM network. This includes geometry compression, annotation
|
// node-based graph to represent the OSM network. This includes geometry compression, annotation
|
||||||
// data optimisation and many other aspects. After this step, the edge-based graph factory can
|
// data optimisation and many other aspects. After this step, the edge-based graph factory can
|
||||||
// turn the graph into the routing graph to be used with the navigation algorithms.
|
// turn the graph into the routing graph to be used with the navigation algorithms.
|
||||||
NodeBasedGraphFactory(const boost::filesystem::path &input_file);
|
NodeBasedGraphFactory(const boost::filesystem::path &input_file,
|
||||||
|
ScriptingEnvironment &scripting_environment,
|
||||||
void CompressAll(ScriptingEnvironment &scripting_environment,
|
std::vector<TurnRestriction> &turn_restrictions,
|
||||||
std::vector<TurnRestriction> &turn_restrictions,
|
std::vector<ConditionalTurnRestriction> &conditional_turn_restrictions);
|
||||||
std::vector<ConditionalTurnRestriction> &conditional_turn_restrictions);
|
|
||||||
|
|
||||||
auto &GetGraph() { return compressed_output_graph; }
|
auto &GetGraph() { return compressed_output_graph; }
|
||||||
auto const &GetBarriers() const { return barriers; }
|
auto const &GetBarriers() const { return barriers; }
|
||||||
@ -76,7 +75,7 @@ class NodeBasedGraphFactory
|
|||||||
// unreferenced entries
|
// unreferenced entries
|
||||||
void CompressAnnotationData();
|
void CompressAnnotationData();
|
||||||
|
|
||||||
// After produce, this will contain a compresse version of the node-based graph
|
// After produce, this will contain a compressed version of the node-based graph
|
||||||
util::NodeBasedDynamicGraph compressed_output_graph;
|
util::NodeBasedDynamicGraph compressed_output_graph;
|
||||||
// To store the meta-data for the graph that is purely annotative / not used for the navigation
|
// To store the meta-data for the graph that is purely annotative / not used for the navigation
|
||||||
// itself. Since the edges of a node-based graph form the nodes of the edge based graphs, we
|
// itself. Since the edges of a node-based graph form the nodes of the edge based graphs, we
|
||||||
|
@ -212,7 +212,10 @@ int Extractor::run(ScriptingEnvironment &scripting_environment)
|
|||||||
std::vector<EdgeWeight> edge_based_node_weights;
|
std::vector<EdgeWeight> edge_based_node_weights;
|
||||||
|
|
||||||
// Create a node-based graph from the OSRM file
|
// Create a node-based graph from the OSRM file
|
||||||
NodeBasedGraphFactory node_based_graph_factory(config.GetPath(".osrm"));
|
NodeBasedGraphFactory node_based_graph_factory(config.GetPath(".osrm"),
|
||||||
|
scripting_environment,
|
||||||
|
turn_restrictions,
|
||||||
|
conditional_turn_restrictions);
|
||||||
|
|
||||||
util::Log() << "Find segregated edges in node-based graph ..." << std::flush;
|
util::Log() << "Find segregated edges in node-based graph ..." << std::flush;
|
||||||
TIMER_START(segregated);
|
TIMER_START(segregated);
|
||||||
@ -223,9 +226,6 @@ int Extractor::run(ScriptingEnvironment &scripting_environment)
|
|||||||
util::Log() << "ok, after " << TIMER_SEC(segregated) << "s";
|
util::Log() << "ok, after " << TIMER_SEC(segregated) << "s";
|
||||||
util::Log() << "Segregated edges count = " << segregated_count;
|
util::Log() << "Segregated edges count = " << segregated_count;
|
||||||
|
|
||||||
node_based_graph_factory.CompressAll(
|
|
||||||
scripting_environment, turn_restrictions, conditional_turn_restrictions);
|
|
||||||
|
|
||||||
util::Log() << "Writing nodes for nodes-based and edges-based graphs ...";
|
util::Log() << "Writing nodes for nodes-based and edges-based graphs ...";
|
||||||
auto const &coordinates = node_based_graph_factory.GetCoordinates();
|
auto const &coordinates = node_based_graph_factory.GetCoordinates();
|
||||||
files::writeNodes(
|
files::writeNodes(
|
||||||
@ -946,6 +946,7 @@ size_t Extractor::FindSegregatedNodes(NodeBasedGraphFactory &factory)
|
|||||||
auto &graph = factory.GetGraph();
|
auto &graph = factory.GetGraph();
|
||||||
auto const &annotation = factory.GetAnnotationData();
|
auto const &annotation = factory.GetAnnotationData();
|
||||||
auto const &coordinates = factory.GetCoordinates();
|
auto const &coordinates = factory.GetCoordinates();
|
||||||
|
auto const &edges = factory.GetCompressedEdges();
|
||||||
|
|
||||||
auto const get_edge_name = [&](auto const &data) {
|
auto const get_edge_name = [&](auto const &data) {
|
||||||
/// @todo Make string normalization/lowercase/trim for comparison ...
|
/// @todo Make string normalization/lowercase/trim for comparison ...
|
||||||
@ -955,6 +956,17 @@ size_t Extractor::FindSegregatedNodes(NodeBasedGraphFactory &factory)
|
|||||||
return names.GetNameForID(id);
|
return names.GetNameForID(id);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
auto const get_edge_length = [&](EdgeID id) {
|
||||||
|
auto const geom = edges.GetBucketReference(id);
|
||||||
|
double length = 0.0;
|
||||||
|
for (size_t i = 1; i < geom.size(); ++i)
|
||||||
|
{
|
||||||
|
length += osrm::util::coordinate_calculation::haversineDistance(
|
||||||
|
coordinates[geom[i - 1].node_id], coordinates[geom[i].node_id]);
|
||||||
|
}
|
||||||
|
return length;
|
||||||
|
};
|
||||||
|
|
||||||
auto const get_edge_classes = [&](auto const &data) {
|
auto const get_edge_classes = [&](auto const &data) {
|
||||||
return annotation[data.annotation_data].classes;
|
return annotation[data.annotation_data].classes;
|
||||||
};
|
};
|
||||||
@ -1027,8 +1039,7 @@ size_t Extractor::FindSegregatedNodes(NodeBasedGraphFactory &factory)
|
|||||||
|
|
||||||
NodeID const targetID = graph.GetTarget(edgeID);
|
NodeID const targetID = graph.GetTarget(edgeID);
|
||||||
|
|
||||||
if (osrm::util::coordinate_calculation::haversineDistance(coordinates[sourceID],
|
if (get_edge_length(edgeID) > 30.0)
|
||||||
coordinates[targetID]) > 30.0)
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
auto const targetEdges = graph.GetAdjacentEdgeRange(targetID);
|
auto const targetEdges = graph.GetAdjacentEdgeRange(targetID);
|
||||||
|
@ -15,16 +15,13 @@ namespace osrm
|
|||||||
namespace extractor
|
namespace extractor
|
||||||
{
|
{
|
||||||
|
|
||||||
NodeBasedGraphFactory::NodeBasedGraphFactory(const boost::filesystem::path &input_file)
|
NodeBasedGraphFactory::NodeBasedGraphFactory(
|
||||||
{
|
const boost::filesystem::path &input_file,
|
||||||
LoadDataFromFile(input_file);
|
|
||||||
}
|
|
||||||
|
|
||||||
void NodeBasedGraphFactory::CompressAll(
|
|
||||||
ScriptingEnvironment &scripting_environment,
|
ScriptingEnvironment &scripting_environment,
|
||||||
std::vector<TurnRestriction> &turn_restrictions,
|
std::vector<TurnRestriction> &turn_restrictions,
|
||||||
std::vector<ConditionalTurnRestriction> &conditional_turn_restrictions)
|
std::vector<ConditionalTurnRestriction> &conditional_turn_restrictions)
|
||||||
{
|
{
|
||||||
|
LoadDataFromFile(input_file);
|
||||||
Compress(scripting_environment, turn_restrictions, conditional_turn_restrictions);
|
Compress(scripting_environment, turn_restrictions, conditional_turn_restrictions);
|
||||||
CompressGeometry();
|
CompressGeometry();
|
||||||
CompressAnnotationData();
|
CompressAnnotationData();
|
||||||
|
Loading…
Reference in New Issue
Block a user