Replace optional<EdgeWeight> with constant value

This commit is contained in:
Patrick Niklaus
2018-02-06 00:47:00 +00:00
committed by Patrick Niklaus
parent f65958fc14
commit 84845ffaa6
3 changed files with 13 additions and 15 deletions
+4 -4
View File
@@ -112,8 +112,8 @@ void CompressedEdgeContainer::CompressEdge(
const EdgeWeight weight2,
const EdgeDuration duration1,
const EdgeDuration duration2,
const boost::optional<EdgeWeight> node_weight_penalty,
const boost::optional<EdgeDuration> node_duration_penalty)
const EdgeWeight node_weight_penalty,
const EdgeDuration node_duration_penalty)
{
// remove super-trivial geometries
BOOST_ASSERT(SPECIAL_EDGEID != edge_id_1);
@@ -169,10 +169,10 @@ void CompressedEdgeContainer::CompressEdge(
// if the via-node offers a penalty, we add the weight of the penalty as an artificial
// segment that references SPECIAL_NODEID
if (node_weight_penalty && node_duration_penalty)
if (node_weight_penalty != INVALID_EDGE_WEIGHT && node_duration_penalty != MAXIMAL_EDGE_DURATION)
{
edge_bucket_list1.emplace_back(OnewayCompressedEdge{
via_node_id, ClipWeight(*node_weight_penalty), ClipDuration(*node_duration_penalty)});
via_node_id, ClipWeight(node_weight_penalty), ClipDuration(node_duration_penalty)});
}
if (HasEntryForID(edge_id_2))
+7 -7
View File
@@ -211,8 +211,8 @@ void GraphCompressor::Compress(
// doesn't have access to.
*/
const bool has_node_penalty = traffic_signals.find(node_v) != traffic_signals.end();
boost::optional<EdgeDuration> node_duration_penalty = boost::none;
boost::optional<EdgeWeight> node_weight_penalty = boost::none;
EdgeDuration node_duration_penalty = MAXIMAL_EDGE_DURATION;
EdgeWeight node_weight_penalty = INVALID_EDGE_WEIGHT;
if (has_node_penalty)
{
// we cannot handle this as node penalty, if it depends on turn direction
@@ -277,12 +277,12 @@ void GraphCompressor::Compress(
graph.GetEdgeData(forward_e1).duration += forward_duration2;
graph.GetEdgeData(reverse_e1).duration += reverse_duration2;
if (node_weight_penalty && node_duration_penalty)
if (node_weight_penalty != INVALID_EDGE_WEIGHT && node_duration_penalty != MAXIMAL_EDGE_DURATION)
{
graph.GetEdgeData(forward_e1).weight += *node_weight_penalty;
graph.GetEdgeData(reverse_e1).weight += *node_weight_penalty;
graph.GetEdgeData(forward_e1).duration += *node_duration_penalty;
graph.GetEdgeData(reverse_e1).duration += *node_duration_penalty;
graph.GetEdgeData(forward_e1).weight += node_weight_penalty;
graph.GetEdgeData(reverse_e1).weight += node_weight_penalty;
graph.GetEdgeData(forward_e1).duration += node_duration_penalty;
graph.GetEdgeData(reverse_e1).duration += node_duration_penalty;
}
// extend e1's to targets of e2's