Use distance functions from many to many

This commit is contained in:
Patrick Niklaus
2018-04-27 05:00:59 +00:00
committed by Patrick Niklaus
parent a649a8a5cf
commit 89fabc1b9c
5 changed files with 111 additions and 94 deletions
@@ -321,24 +321,10 @@ void annotatePath(const FacadeT &facade,
}
}
template <typename Algorithm>
double getPathDistance(const DataFacade<Algorithm> &facade,
const std::vector<PathData> &unpacked_path,
const PhantomNode &source_phantom,
const PhantomNode &target_phantom)
{
double distance = 0;
auto prev_coordinate = source_phantom.location;
for (const auto &p : unpacked_path)
{
const auto current_coordinate = facade.GetCoordinateOfNode(p.turn_via_node);
distance += util::coordinate_calculation::fccApproximateDistance(prev_coordinate, current_coordinate);
prev_coordinate = current_coordinate;
}
distance += util::coordinate_calculation::fccApproximateDistance(prev_coordinate, target_phantom.location);
return distance;
}
void adjustPathDistanceToPhantomNodes(const std::vector<NodeID> &path,
const PhantomNode &source_phantom,
const PhantomNode &target_phantom,
EdgeDistance &distance);
template <typename AlgorithmT>
InternalRouteResult extractRoute(const DataFacade<AlgorithmT> &facade,
@@ -120,7 +120,7 @@ inline LevelID getNodeQueryLevel(const MultiLevelPartition &partition,
}
return result;
}
}
} // namespace
// Heaps only record for each node its predecessor ("parent") on the shortest path.
// For re-constructing the actual path we need to trace back all parent "pointers".
@@ -680,11 +680,20 @@ double getNetworkDistance(SearchEngineData<Algorithm> &engine_working_data,
return std::numeric_limits<double>::max();
}
std::vector<PathData> unpacked_path;
EdgeDistance distance = 0;
annotatePath(facade, phantom_nodes, unpacked_nodes, unpacked_edges, unpacked_path);
if (!unpacked_nodes.empty())
{
for (auto node_iter = unpacked_nodes.begin(); node_iter != std::prev(unpacked_nodes.end()); node_iter++)
{
distance += computeEdgeDistance(facade, *node_iter);
}
}
return getPathDistance(facade, unpacked_path, source_phantom, target_phantom);
adjustPathDistanceToPhantomNodes(
unpacked_nodes, phantom_nodes.source_phantom, phantom_nodes.target_phantom, distance);
return distance / 10.;
}
} // namespace mld