Use copressed node-based graph for segregated edges check.

This commit is contained in:
vng 2017-10-20 11:50:21 +00:00 committed by Michael Krasnyk
parent ec7e58e10e
commit 76f793533a
3 changed files with 25 additions and 18 deletions

View File

@ -36,11 +36,10 @@ class NodeBasedGraphFactory
// 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
// turn the graph into the routing graph to be used with the navigation algorithms.
NodeBasedGraphFactory(const boost::filesystem::path &input_file);
void CompressAll(ScriptingEnvironment &scripting_environment,
std::vector<TurnRestriction> &turn_restrictions,
std::vector<ConditionalTurnRestriction> &conditional_turn_restrictions);
NodeBasedGraphFactory(const boost::filesystem::path &input_file,
ScriptingEnvironment &scripting_environment,
std::vector<TurnRestriction> &turn_restrictions,
std::vector<ConditionalTurnRestriction> &conditional_turn_restrictions);
auto &GetGraph() { return compressed_output_graph; }
auto const &GetBarriers() const { return barriers; }
@ -76,7 +75,7 @@ class NodeBasedGraphFactory
// unreferenced entries
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;
// 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

View File

@ -212,7 +212,10 @@ int Extractor::run(ScriptingEnvironment &scripting_environment)
std::vector<EdgeWeight> edge_based_node_weights;
// 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;
TIMER_START(segregated);
@ -223,9 +226,6 @@ int Extractor::run(ScriptingEnvironment &scripting_environment)
util::Log() << "ok, after " << TIMER_SEC(segregated) << "s";
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 ...";
auto const &coordinates = node_based_graph_factory.GetCoordinates();
files::writeNodes(
@ -946,6 +946,7 @@ size_t Extractor::FindSegregatedNodes(NodeBasedGraphFactory &factory)
auto &graph = factory.GetGraph();
auto const &annotation = factory.GetAnnotationData();
auto const &coordinates = factory.GetCoordinates();
auto const &edges = factory.GetCompressedEdges();
auto const get_edge_name = [&](auto const &data) {
/// @todo Make string normalization/lowercase/trim for comparison ...
@ -955,6 +956,17 @@ size_t Extractor::FindSegregatedNodes(NodeBasedGraphFactory &factory)
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) {
return annotation[data.annotation_data].classes;
};
@ -1027,8 +1039,7 @@ size_t Extractor::FindSegregatedNodes(NodeBasedGraphFactory &factory)
NodeID const targetID = graph.GetTarget(edgeID);
if (osrm::util::coordinate_calculation::haversineDistance(coordinates[sourceID],
coordinates[targetID]) > 30.0)
if (get_edge_length(edgeID) > 30.0)
continue;
auto const targetEdges = graph.GetAdjacentEdgeRange(targetID);

View File

@ -15,16 +15,13 @@ namespace osrm
namespace extractor
{
NodeBasedGraphFactory::NodeBasedGraphFactory(const boost::filesystem::path &input_file)
{
LoadDataFromFile(input_file);
}
void NodeBasedGraphFactory::CompressAll(
NodeBasedGraphFactory::NodeBasedGraphFactory(
const boost::filesystem::path &input_file,
ScriptingEnvironment &scripting_environment,
std::vector<TurnRestriction> &turn_restrictions,
std::vector<ConditionalTurnRestriction> &conditional_turn_restrictions)
{
LoadDataFromFile(input_file);
Compress(scripting_environment, turn_restrictions, conditional_turn_restrictions);
CompressGeometry();
CompressAnnotationData();