From 8c7f744b1ad1c66b5c98a1572581e9ffb856605f Mon Sep 17 00:00:00 2001 From: Daniel Patterson Date: Thu, 8 Dec 2016 14:35:34 -0800 Subject: [PATCH] Update node weights if traffic data is applied. --- include/contractor/contractor.hpp | 1 + src/contractor/contractor.cpp | 29 ++++++++++++++++++----------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/include/contractor/contractor.hpp b/include/contractor/contractor.hpp index 7cc70cc48..2f6b250d0 100644 --- a/include/contractor/contractor.hpp +++ b/include/contractor/contractor.hpp @@ -81,6 +81,7 @@ class Contractor EdgeID LoadEdgeExpandedGraph(const std::string &edge_based_graph_path, util::DeallocatingVector &edge_based_edge_list, + std::vector &node_weights, const std::string &edge_segment_lookup_path, const std::string &edge_penalty_path, const std::vector &segment_speed_path, diff --git a/src/contractor/contractor.cpp b/src/contractor/contractor.cpp index 55b8fcbbb..9a7f38cc5 100644 --- a/src/contractor/contractor.cpp +++ b/src/contractor/contractor.cpp @@ -136,12 +136,24 @@ int Contractor::Run() TIMER_START(preparing); + util::Log() << "Reading node weights."; + std::vector node_weights; + std::string node_file_name = config.osrm_input_path.string() + ".enw"; + + { + storage::io::FileReader node_file(node_file_name, + storage::io::FileReader::VerifyFingerprint); + node_file.DeserializeVector(node_weights); + } + util::Log() << "Done reading node weights."; + util::Log() << "Loading edge-expanded graph representation"; util::DeallocatingVector edge_based_edge_list; EdgeID max_edge_id = LoadEdgeExpandedGraph(config.edge_based_graph_path, edge_based_edge_list, + node_weights, config.edge_segment_lookup_path, config.edge_penalty_path, config.segment_speed_lookup_paths, @@ -163,17 +175,6 @@ int Contractor::Run() ReadNodeLevels(node_levels); } - util::Log() << "Reading node weights."; - std::vector node_weights; - std::string node_file_name = config.osrm_input_path.string() + ".enw"; - - { - storage::io::FileReader node_file(node_file_name, - storage::io::FileReader::VerifyFingerprint); - node_file.DeserializeVector(node_weights); - } - util::Log() << "Done reading node weights."; - util::DeallocatingVector contracted_edge_list; ContractGraph(max_edge_id, edge_based_edge_list, @@ -499,6 +500,7 @@ parse_turn_penalty_lookup_from_csv_files(const std::vector &turn_pe EdgeID Contractor::LoadEdgeExpandedGraph( std::string const &edge_based_graph_filename, util::DeallocatingVector &edge_based_edge_list, + std::vector &node_weights, const std::string &edge_segment_lookup_filename, const std::string &edge_penalty_filename, const std::vector &segment_speed_filenames, @@ -914,6 +916,11 @@ EdgeID Contractor::LoadEdgeExpandedGraph( previous_osm_node_id = segmentblocks[i].this_osm_node_id; } + // Update the node-weight cache. This is the weight of the edge-based-node only, + // it doesn't include the turn. We may visit the same node multiple times, but + // we should always assign the same value here. + node_weights[inbuffer.source] = new_weight; + // We found a zero-speed edge, so we'll skip this whole edge-based-edge which // effectively removes it from the routing network. if (skip_this_edge)