Add duration to edges and use it in table plugin

This commit is contained in:
Michael Krasnyk
2017-01-19 22:52:09 +01:00
committed by Patrick Niklaus
parent c059d15cb9
commit 25baf51a2c
24 changed files with 312 additions and 126 deletions
+6
View File
@@ -778,6 +778,7 @@ Contractor::LoadEdgeExpandedGraph(const ContractorConfig &config,
// Find a segment with zero speed and simultaneously compute the new edge weight
EdgeWeight new_weight = 0;
// TODO MKR add new_duration if needed
auto osm_node_id = header->previous_osm_node_id;
bool skip_edge =
std::find_if(first, last, [&](const auto &segment) {
@@ -789,6 +790,9 @@ Contractor::LoadEdgeExpandedGraph(const ContractorConfig &config,
if (value->speed == 0)
return true;
// TODO MKR add new_duration = ConvertToDuration(segment.segment_length,
// value->speed) if needed
segment_weight =
std::isfinite(value->weight)
? std::round(value->weight * config.weight_multiplier)
@@ -798,6 +802,7 @@ Contractor::LoadEdgeExpandedGraph(const ContractorConfig &config,
// Update the edge weight and the next OSM node ID
osm_node_id = segment.this_osm_node_id;
new_weight += segment_weight;
// TODO MKR new_duration += segment_duration;
return false;
}) != last;
@@ -844,6 +849,7 @@ Contractor::LoadEdgeExpandedGraph(const ContractorConfig &config,
// Update edge weight
inbuffer.weight = new_weight + turn_weight_penalty;
// TODO MKR inbuffer.duration = new_duration + turn_duration_penalty;
}
edge_based_edge_list.emplace_back(std::move(inbuffer));
+5
View File
@@ -39,16 +39,21 @@ GraphContractor::GraphContractor(int nodes,
forward_edge.data.id = reverse_edge.data.id = id;
forward_edge.data.originalEdges = reverse_edge.data.originalEdges = 1;
forward_edge.data.weight = reverse_edge.data.weight = INVALID_EDGE_WEIGHT;
forward_edge.data.duration = reverse_edge.data.duration = MAXIMAL_EDGE_DURATION;
// remove parallel edges
while (i < edges.size() && edges[i].source == source && edges[i].target == target)
{
if (edges[i].data.forward)
{
forward_edge.data.weight = std::min(edges[i].data.weight, forward_edge.data.weight);
forward_edge.data.duration =
std::min(edges[i].data.duration, forward_edge.data.duration);
}
if (edges[i].data.backward)
{
reverse_edge.data.weight = std::min(edges[i].data.weight, reverse_edge.data.weight);
reverse_edge.data.duration =
std::min(edges[i].data.duration, reverse_edge.data.duration);
}
++i;
}