Remove .osrm.edge_segment_update not needed anymore
This commit is contained in:
parent
1f238fedd8
commit
acbaecf45d
@ -112,7 +112,6 @@ class EdgeBasedGraphFactory
|
||||
void Run(ScriptingEnvironment &scripting_environment,
|
||||
const std::string &original_edge_data_filename,
|
||||
const std::string &turn_lane_data_filename,
|
||||
const std::string &edge_segment_lookup_filename,
|
||||
const std::string &turn_weight_penalties_filename,
|
||||
const std::string &turn_duration_penalties_filename,
|
||||
const std::string &turn_penalties_index_filename,
|
||||
@ -182,7 +181,6 @@ class EdgeBasedGraphFactory
|
||||
void GenerateEdgeExpandedEdges(ScriptingEnvironment &scripting_environment,
|
||||
const std::string &original_edge_data_filename,
|
||||
const std::string &turn_lane_data_filename,
|
||||
const std::string &edge_segment_lookup_filename,
|
||||
const std::string &turn_weight_penalties_filename,
|
||||
const std::string &turn_duration_penalties_filename,
|
||||
const std::string &turn_penalties_index_filename,
|
||||
|
@ -70,7 +70,6 @@ struct ExtractorConfig
|
||||
edge_graph_output_path = basepath + ".osrm.ebg";
|
||||
rtree_nodes_output_path = basepath + ".osrm.ramIndex";
|
||||
rtree_leafs_output_path = basepath + ".osrm.fileIndex";
|
||||
edge_segment_lookup_path = basepath + ".osrm.edge_segment_lookup";
|
||||
turn_duration_penalties_path = basepath + ".osrm.turn_duration_penalties";
|
||||
turn_weight_penalties_path = basepath + ".osrm.turn_weight_penalties";
|
||||
turn_penalties_index_path = basepath + ".osrm.turn_penalties_index";
|
||||
@ -109,7 +108,6 @@ struct ExtractorConfig
|
||||
|
||||
bool generate_edge_lookup;
|
||||
std::string turn_penalties_index_path;
|
||||
std::string edge_segment_lookup_path;
|
||||
|
||||
bool use_metadata;
|
||||
};
|
||||
|
@ -43,7 +43,6 @@ struct UpdaterConfig final
|
||||
void UseDefaultOutputNames()
|
||||
{
|
||||
edge_based_graph_path = osrm_input_path.string() + ".ebg";
|
||||
edge_segment_lookup_path = osrm_input_path.string() + ".edge_segment_lookup";
|
||||
turn_weight_penalties_path = osrm_input_path.string() + ".turn_weight_penalties";
|
||||
turn_duration_penalties_path = osrm_input_path.string() + ".turn_duration_penalties";
|
||||
turn_penalties_index_path = osrm_input_path.string() + ".turn_penalties_index";
|
||||
@ -58,7 +57,6 @@ struct UpdaterConfig final
|
||||
|
||||
std::string edge_based_graph_path;
|
||||
|
||||
std::string edge_segment_lookup_path;
|
||||
std::string turn_weight_penalties_path;
|
||||
std::string turn_duration_penalties_path;
|
||||
std::string turn_penalties_index_path;
|
||||
|
@ -196,7 +196,6 @@ void EdgeBasedGraphFactory::FlushVectorToStream(
|
||||
void EdgeBasedGraphFactory::Run(ScriptingEnvironment &scripting_environment,
|
||||
const std::string &original_edge_data_filename,
|
||||
const std::string &turn_lane_data_filename,
|
||||
const std::string &edge_segment_lookup_filename,
|
||||
const std::string &turn_weight_penalties_filename,
|
||||
const std::string &turn_duration_penalties_filename,
|
||||
const std::string &turn_penalties_index_filename,
|
||||
@ -216,7 +215,6 @@ void EdgeBasedGraphFactory::Run(ScriptingEnvironment &scripting_environment,
|
||||
GenerateEdgeExpandedEdges(scripting_environment,
|
||||
original_edge_data_filename,
|
||||
turn_lane_data_filename,
|
||||
edge_segment_lookup_filename,
|
||||
turn_weight_penalties_filename,
|
||||
turn_duration_penalties_filename,
|
||||
turn_penalties_index_filename,
|
||||
@ -330,7 +328,6 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges(
|
||||
ScriptingEnvironment &scripting_environment,
|
||||
const std::string &original_edge_data_filename,
|
||||
const std::string &turn_lane_data_filename,
|
||||
const std::string &edge_segment_lookup_filename,
|
||||
const std::string &turn_weight_penalties_filename,
|
||||
const std::string &turn_duration_penalties_filename,
|
||||
const std::string &turn_penalties_index_filename,
|
||||
@ -347,9 +344,6 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges(
|
||||
storage::io::FileWriter edge_data_file(original_edge_data_filename,
|
||||
storage::io::FileWriter::HasNoFingerprint);
|
||||
|
||||
storage::io::FileWriter edge_segment_file(edge_segment_lookup_filename,
|
||||
storage::io::FileWriter::HasNoFingerprint);
|
||||
|
||||
storage::io::FileWriter turn_penalties_index_file(turn_penalties_index_filename,
|
||||
storage::io::FileWriter::HasNoFingerprint);
|
||||
|
||||
@ -584,49 +578,7 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges(
|
||||
turn_duration_penalties.push_back(duration_penalty);
|
||||
}
|
||||
|
||||
// Here is where we write out the mapping between the edge-expanded edges, and
|
||||
// the node-based edges that are originally used to calculate the `distance`
|
||||
// for the edge-expanded edges. About 40 lines back, there is:
|
||||
//
|
||||
// unsigned distance = edge_data1.distance;
|
||||
//
|
||||
// This tells us that the weight for an edge-expanded-edge is based on the
|
||||
// weight
|
||||
// of the *source* node-based edge. Therefore, we will look up the individual
|
||||
// segments of the source node-based edge, and write out a mapping between
|
||||
// those and the edge-based-edge ID.
|
||||
// External programs can then use this mapping to quickly perform
|
||||
// updates to the edge-expanded-edge based directly on its ID.
|
||||
if (generate_edge_lookup)
|
||||
{
|
||||
const auto node_based_edges =
|
||||
m_compressed_edge_container.GetBucketReference(incoming_edge);
|
||||
NodeID previous = node_along_road_entering;
|
||||
|
||||
const unsigned node_count = node_based_edges.size() + 1;
|
||||
const QueryNode &first_node = m_node_info_list[previous];
|
||||
|
||||
lookup::SegmentHeaderBlock header = {node_count, first_node.node_id};
|
||||
|
||||
edge_segment_file.WriteOne(header);
|
||||
|
||||
for (auto target_node : node_based_edges)
|
||||
{
|
||||
const QueryNode &from = m_node_info_list[previous];
|
||||
const QueryNode &to = m_node_info_list[target_node.node_id];
|
||||
const double segment_length =
|
||||
util::coordinate_calculation::greatCircleDistance(from, to);
|
||||
|
||||
lookup::SegmentBlock nodeblock{to.node_id,
|
||||
segment_length,
|
||||
target_node.weight,
|
||||
target_node.duration};
|
||||
|
||||
edge_segment_file.WriteOne(nodeblock);
|
||||
previous = target_node.node_id;
|
||||
}
|
||||
|
||||
// We also now write out the mapping between the edge-expanded edges and the
|
||||
// We write out the mapping between the edge-expanded edges and the
|
||||
// original nodes. Since each edge represents a possible maneuver, external
|
||||
// programs can use this to quickly perform updates to edge weights in order
|
||||
// to penalize certain turns.
|
||||
@ -637,6 +589,8 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges(
|
||||
// look
|
||||
// up the node
|
||||
// immediately preceding the turn from the compressed edge container.
|
||||
if (generate_edge_lookup)
|
||||
{
|
||||
const bool isTrivial = m_compressed_edge_container.IsTrivial(incoming_edge);
|
||||
|
||||
const auto &from_node =
|
||||
|
@ -483,7 +483,6 @@ Extractor::BuildEdgeExpandedGraph(ScriptingEnvironment &scripting_environment,
|
||||
edge_based_graph_factory.Run(scripting_environment,
|
||||
config.edge_output_path,
|
||||
config.turn_lane_data_file_name,
|
||||
config.edge_segment_lookup_path,
|
||||
config.turn_weight_penalties_path,
|
||||
config.turn_duration_penalties_path,
|
||||
config.turn_penalties_index_path,
|
||||
|
@ -422,14 +422,6 @@ Updater::LoadAndUpdateEdgeExpandedGraph(std::vector<extractor::EdgeBasedEdge> &e
|
||||
return boost::interprocess::mapped_region();
|
||||
}();
|
||||
|
||||
const auto edge_segment_region = [&] {
|
||||
if (update_edge_weights || update_turn_penalties)
|
||||
{
|
||||
return mmapFile(config.edge_segment_lookup_path, boost::interprocess::read_only);
|
||||
}
|
||||
return boost::interprocess::mapped_region();
|
||||
}();
|
||||
|
||||
// Set the struct packing to 1 byte word sizes. This prevents any padding. We only use
|
||||
// this struct once, so any alignment penalty is trivial. If this is *not* done, then
|
||||
// the struct will be padded out by an extra 4 bytes, and sizeof() will mean we read
|
||||
@ -470,7 +462,6 @@ Updater::LoadAndUpdateEdgeExpandedGraph(std::vector<extractor::EdgeBasedEdge> &e
|
||||
edge_based_edge_list.reserve(graph_header.number_of_edges);
|
||||
util::Log() << "Reading " << graph_header.number_of_edges << " edges from the edge based graph";
|
||||
|
||||
auto segment_speed_lookup = csv::readSegmentValues(config.segment_speed_lookup_paths);
|
||||
auto turn_penalty_lookup = csv::readTurnValues(config.turn_penalty_lookup_paths);
|
||||
|
||||
storage::io::FileReader edges_input_file(config.osrm_input_path.string() + ".edges",
|
||||
@ -482,6 +473,8 @@ Updater::LoadAndUpdateEdgeExpandedGraph(std::vector<extractor::EdgeBasedEdge> &e
|
||||
extractor::SegmentDataContainer segment_data;
|
||||
if (update_edge_weights)
|
||||
{
|
||||
auto segment_speed_lookup = csv::readSegmentValues(config.segment_speed_lookup_paths);
|
||||
|
||||
TIMER_START(segment);
|
||||
std::tie(updated_segments, segment_data) =
|
||||
updaterSegmentData(config, profile_properties, segment_speed_lookup);
|
||||
@ -490,6 +483,10 @@ Updater::LoadAndUpdateEdgeExpandedGraph(std::vector<extractor::EdgeBasedEdge> &e
|
||||
TIMER_STOP(segment);
|
||||
util::Log() << "Updating segment data took " << TIMER_MSEC(segment) << "ms.";
|
||||
}
|
||||
else if (update_turn_penalties)
|
||||
{
|
||||
extractor::io::read(config.geometry_path, segment_data);
|
||||
}
|
||||
|
||||
std::vector<TurnPenalty> turn_weight_penalties;
|
||||
std::vector<TurnPenalty> turn_duration_penalties;
|
||||
@ -529,8 +526,6 @@ Updater::LoadAndUpdateEdgeExpandedGraph(std::vector<extractor::EdgeBasedEdge> &e
|
||||
sizeof(EdgeBasedGraphHeader));
|
||||
BOOST_ASSERT(is_aligned<extractor::EdgeBasedEdge>(edge_based_edge_ptr));
|
||||
|
||||
auto edge_segment_byte_ptr = reinterpret_cast<const char *>(edge_segment_region.get_address());
|
||||
|
||||
bool fallback_to_duration = true;
|
||||
for (std::uint64_t edge_index = 0; edge_index < graph_header.number_of_edges; ++edge_index)
|
||||
{
|
||||
@ -559,47 +554,44 @@ Updater::LoadAndUpdateEdgeExpandedGraph(std::vector<extractor::EdgeBasedEdge> &e
|
||||
}
|
||||
}
|
||||
|
||||
using extractor::lookup::SegmentHeaderBlock;
|
||||
using extractor::lookup::SegmentBlock;
|
||||
|
||||
auto header = reinterpret_cast<const SegmentHeaderBlock *>(edge_segment_byte_ptr);
|
||||
BOOST_ASSERT(is_aligned<SegmentHeaderBlock>(header));
|
||||
edge_segment_byte_ptr += sizeof(SegmentHeaderBlock);
|
||||
|
||||
auto first = reinterpret_cast<const SegmentBlock *>(edge_segment_byte_ptr);
|
||||
BOOST_ASSERT(is_aligned<SegmentBlock>(first));
|
||||
edge_segment_byte_ptr += sizeof(SegmentBlock) * (header->num_osm_nodes - 1);
|
||||
auto last = reinterpret_cast<const SegmentBlock *>(edge_segment_byte_ptr);
|
||||
|
||||
if (needs_update)
|
||||
{
|
||||
// Find a segment with zero speed and simultaneously compute the new edge weight
|
||||
EdgeWeight new_weight = 0;
|
||||
EdgeWeight new_duration = 0;
|
||||
auto osm_node_id = header->previous_osm_node_id;
|
||||
bool skip_edge =
|
||||
std::find_if(first, last, [&](const auto &segment) {
|
||||
auto segment_weight = segment.segment_weight;
|
||||
auto segment_duration = segment.segment_duration;
|
||||
if (auto value = segment_speed_lookup({osm_node_id, segment.this_osm_node_id}))
|
||||
bool skip_edge = false;
|
||||
|
||||
const auto geometry_id = edge_data[edge_index].via_geometry;
|
||||
if (geometry_id.forward)
|
||||
{
|
||||
// If we hit a 0-speed edge, then it's effectively not traversible.
|
||||
// We don't want to include it in the edge_based_edge_list.
|
||||
if (value->speed == 0)
|
||||
return true;
|
||||
|
||||
segment_duration = convertToDuration(value->speed, segment.segment_length);
|
||||
|
||||
segment_weight =
|
||||
convertToWeight(value->weight, weight_multiplier, segment_duration);
|
||||
const auto weights = segment_data.GetForwardWeights(geometry_id.id);
|
||||
for (const auto weight : weights)
|
||||
{
|
||||
if (weight == INVALID_EDGE_WEIGHT)
|
||||
{
|
||||
skip_edge = true;
|
||||
break;
|
||||
}
|
||||
new_weight += weight;
|
||||
}
|
||||
const auto durations = segment_data.GetForwardDurations(geometry_id.id);
|
||||
new_duration = std::accumulate(durations.begin(), durations.end(), 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
const auto weights = segment_data.GetReverseWeights(geometry_id.id);
|
||||
for (const auto weight : weights)
|
||||
{
|
||||
if (weight == INVALID_EDGE_WEIGHT)
|
||||
{
|
||||
skip_edge = true;
|
||||
break;
|
||||
}
|
||||
new_weight += weight;
|
||||
}
|
||||
const auto durations = segment_data.GetReverseDurations(geometry_id.id);
|
||||
new_duration = std::accumulate(durations.begin(), durations.end(), 0);
|
||||
}
|
||||
|
||||
// Update the edge weight and the next OSM node ID
|
||||
osm_node_id = segment.this_osm_node_id;
|
||||
new_weight += segment_weight;
|
||||
new_duration += segment_duration;
|
||||
return false;
|
||||
}) != last;
|
||||
|
||||
// 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
|
||||
@ -625,7 +617,8 @@ Updater::LoadAndUpdateEdgeExpandedGraph(std::vector<extractor::EdgeBasedEdge> &e
|
||||
? value->weight * weight_multiplier
|
||||
: turn_duration_penalty * weight_multiplier / 10.));
|
||||
|
||||
const auto weight_min_value = static_cast<EdgeWeight>(header->num_osm_nodes);
|
||||
const auto num_nodes = segment_data.GetForwardGeometry(geometry_id.id).size();
|
||||
const auto weight_min_value = static_cast<EdgeWeight>(num_nodes);
|
||||
if (turn_weight_penalty + new_weight < weight_min_value)
|
||||
{
|
||||
util::Log(logWARNING) << "turn penalty " << turn_weight_penalty << " for turn "
|
||||
|
Loading…
Reference in New Issue
Block a user