Turn Angles in OSRM were computed using a lookahead of 10 meters.

This PR adds more advanced coordinate extraction, analysing the road
to detect offsets due to OSM way modelling.

In addition it improves the handling of bearings. Right now OSM reports
bearings simply based on the very first coordinate along a way.
With this PR, we store the bearings for a turn correctly, making the
bearings for turns correct.
This commit is contained in:
Moritz Kobitzsch
2016-08-17 09:49:19 +02:00
parent 1f8ca2879f
commit 5e167b8745
62 changed files with 3451 additions and 679 deletions
+17
View File
@@ -30,6 +30,13 @@ double haversineDistance(const Coordinate first_coordinate, const Coordinate sec
double greatCircleDistance(const Coordinate first_coordinate, const Coordinate second_coordinate);
// Find the closest distance and location between coordinate and the line connecting source and
// target:
// coordinate
// |
// |
// source -------- x -------- target.
// returns x as well as the distance between source and x as ratio ([0,1])
inline std::pair<double, FloatCoordinate> projectPointOnSegment(const FloatCoordinate &source,
const FloatCoordinate &target,
const FloatCoordinate &coordinate)
@@ -99,6 +106,16 @@ double circleRadius(const Coordinate first_coordinate,
// returns to
Coordinate interpolateLinear(double factor, const Coordinate from, const Coordinate to);
// compute the signed area of a triangle
double signedArea(const Coordinate first_coordinate,
const Coordinate second_coordinate,
const Coordinate third_coordinate);
// check if a set of three coordinates is given in CCW order
bool isCCW(const Coordinate first_coordinate,
const Coordinate second_coordinate,
const Coordinate third_coordinate);
} // ns coordinate_calculation
} // ns util
} // ns osrm
+6 -1
View File
@@ -10,12 +10,15 @@
#include <iomanip>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
namespace osrm
{
namespace util
{
namespace guidance
{
inline void print(const engine::guidance::RouteStep &step)
@@ -30,7 +33,9 @@ inline void print(const engine::guidance::RouteStep &step)
for (const auto &intersection : step.intersections)
{
std::cout << "(Lanes: " << static_cast<int>(intersection.lanes.lanes_in_turn) << " "
<< static_cast<int>(intersection.lanes.first_lane_from_the_right) << " bearings:";
<< static_cast<int>(intersection.lanes.first_lane_from_the_right) << " ["
<< intersection.in << "," << intersection.out << "]"
<< " bearings:";
for (auto bearing : intersection.bearings)
std::cout << " " << bearing;
std::cout << ", entry: ";
+6
View File
@@ -32,6 +32,12 @@ inline double angularDeviation(const double angle, const double from)
return std::min(360 - deviation, deviation);
}
inline bool hasRampType(const extractor::guidance::TurnInstruction instruction)
{
return instruction.type == extractor::guidance::TurnType::OffRamp ||
instruction.type == extractor::guidance::TurnType::OnRamp;
}
inline extractor::guidance::DirectionModifier::Enum getTurnDirection(const double angle)
{
// An angle of zero is a u-turn
+30
View File
@@ -0,0 +1,30 @@
#ifndef OSRM_INCLUDE_UTIL_TURN_BEARING_HPP_
#define OSRM_INCLUDE_UTIL_TURN_BEARING_HPP_
#include <cstdint>
namespace osrm
{
namespace util
{
namespace guidance
{
#pragma pack(push, 1)
class TurnBearing
{
public:
TurnBearing(const double value = 0);
double Get() const;
private:
std::uint8_t bearing;
};
#pragma pack(pop)
} // namespace guidance
} // namespace util
} // namespace osrm
#endif /* OSRM_INCLUDE_UTIL_TURN_BEARING_HPP_ */
@@ -46,7 +46,8 @@ template <typename DataT> class ShMemIterator : public std::iterator<std::input_
DataT &operator*() { return *p; }
};
template <typename DataT> class ShMemReverseIterator : public std::iterator<std::input_iterator_tag, DataT>
template <typename DataT>
class ShMemReverseIterator : public std::iterator<std::input_iterator_tag, DataT>
{
DataT *p;
@@ -99,7 +100,10 @@ template <typename DataT> class SharedMemoryWrapper
ShMemIterator<DataT> end() const { return ShMemIterator<DataT>(m_ptr + m_size); }
ShMemReverseIterator<DataT> rbegin() const { return ShMemReverseIterator<DataT>(m_ptr + m_size - 1); }
ShMemReverseIterator<DataT> rbegin() const
{
return ShMemReverseIterator<DataT>(m_ptr + m_size - 1);
}
ShMemReverseIterator<DataT> rend() const { return ShMemReverseIterator<DataT>(m_ptr - 1); }
-1
View File
@@ -112,7 +112,6 @@ struct GeometryID
std::uint32_t forward : 1;
};
static_assert(sizeof(SegmentID) == 4, "SegmentID needs to be 4 bytes big");
#endif /* TYPEDEFS_H */