actually calculate distance instead of using .distance which is a timing value
This commit is contained in:
@@ -40,6 +40,11 @@ class CoordinateExtractor
|
||||
const bool traversed_in_reverse,
|
||||
const NodeID to_node) const;
|
||||
|
||||
// wrapper in case of normal forward edges (traversed_in_reverse = false, to_node =
|
||||
// node_based_graph.GetTarget(turn_edge)
|
||||
std::vector<util::Coordinate> GetForwardCoordinatesAlongRoad(const NodeID from,
|
||||
const EdgeID turn_edge) const;
|
||||
|
||||
/* When extracting the coordinates, we first extract all coordinates. We don't care about most
|
||||
* of them, though.
|
||||
*
|
||||
|
||||
@@ -47,6 +47,9 @@ class IntersectionGenerator
|
||||
NodeID *resulting_from_node,
|
||||
EdgeID *resulting_via_edge) const;
|
||||
|
||||
// Allow access to the coordinate extractor for all owners
|
||||
const CoordinateExtractor &GetCoordinateExtractor() const;
|
||||
|
||||
private:
|
||||
const util::NodeBasedDynamicGraph &node_based_graph;
|
||||
const RestrictionMap &restriction_map;
|
||||
|
||||
@@ -5,7 +5,9 @@
|
||||
|
||||
#include <boost/optional.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
@@ -30,6 +32,24 @@ double haversineDistance(const Coordinate first_coordinate, const Coordinate sec
|
||||
|
||||
double greatCircleDistance(const Coordinate first_coordinate, const Coordinate second_coordinate);
|
||||
|
||||
// get the length of a full coordinate vector, using one of our basic functions to compute distances
|
||||
template <class BinaryOperation>
|
||||
double getLength(const std::vector<Coordinate> &coordinates, BinaryOperation op)
|
||||
{
|
||||
if (coordinates.empty())
|
||||
return 0.;
|
||||
|
||||
double result = 0;
|
||||
const auto functor = [&result, op](const Coordinate lhs, const Coordinate rhs) {
|
||||
result += op(lhs, rhs);
|
||||
return false;
|
||||
};
|
||||
// side-effect find adding up distances
|
||||
std::adjacent_find(coordinates.begin(), coordinates.end(), functor);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Find the closest distance and location between coordinate and the line connecting source and
|
||||
// target:
|
||||
// coordinate
|
||||
|
||||
Reference in New Issue
Block a user