diff --git a/src/thor/timedistancebssmatrix.cc b/src/thor/timedistancebssmatrix.cc index aac7a1d4bf..88b6dd9069 100644 --- a/src/thor/timedistancebssmatrix.cc +++ b/src/thor/timedistancebssmatrix.cc @@ -463,7 +463,7 @@ bool TimeDistanceBSSMatrix::UpdateDestinations( // Subtract the partial remaining cost and distance along the edge. float remainder = dest_edge->second; Cost newcost = pred.cost() - (pedestrian_costing_->EdgeCost(edge, tile) * remainder); - if (newcost.cost < dest.best_cost.cost) { + if (newcost.cost > 0 && newcost.cost < dest.best_cost.cost) { dest.best_cost = newcost; dest.distance = pred.path_distance() - (edge->length() * remainder); } diff --git a/src/thor/timedistancematrix.cc b/src/thor/timedistancematrix.cc index 3188103243..43873706c1 100644 --- a/src/thor/timedistancematrix.cc +++ b/src/thor/timedistancematrix.cc @@ -518,7 +518,7 @@ bool TimeDistanceMatrix::UpdateDestinations( float remainder = dest_edge->second; Cost newcost = pred.cost() - (costing_->EdgeCost(edge, tile, time_info, flow_sources) * remainder); - if (newcost.cost < dest.best_cost.cost) { + if (newcost.cost > 0 && newcost.cost < dest.best_cost.cost) { dest.best_cost = newcost; dest.distance = pred.path_distance() - (edge->length() * remainder); }