2015-01-20 10:24:49 -05:00
|
|
|
#ifndef COORDINATE_CALCULATION
|
|
|
|
#define COORDINATE_CALCULATION
|
|
|
|
|
2016-01-21 07:07:24 -05:00
|
|
|
#include "osrm/coordinate.hpp"
|
|
|
|
|
2015-01-20 10:24:49 -05:00
|
|
|
#include <string>
|
|
|
|
#include <utility>
|
|
|
|
|
2016-01-05 10:51:13 -05:00
|
|
|
namespace osrm
|
|
|
|
{
|
|
|
|
namespace util
|
|
|
|
{
|
|
|
|
|
2016-01-12 09:41:30 -05:00
|
|
|
const constexpr long double RAD = 0.017453292519943295769236907684886;
|
|
|
|
// earth radius varies between 6,356.750-6,378.135 km (3,949.901-3,963.189mi)
|
|
|
|
// The IUGG value for the equatorial radius is 6378.137 km (3963.19 miles)
|
|
|
|
const constexpr long double EARTH_RADIUS = 6372797.560856;
|
|
|
|
|
2015-08-06 09:48:29 -04:00
|
|
|
namespace coordinate_calculation
|
2015-01-20 10:24:49 -05:00
|
|
|
{
|
2016-01-04 07:30:03 -05:00
|
|
|
double haversineDistance(const int lat1, const int lon1, const int lat2, const int lon2);
|
|
|
|
|
2016-01-21 07:07:24 -05:00
|
|
|
double haversineDistance(const FixedPointCoordinate first_coordinate,
|
|
|
|
const FixedPointCoordinate second_coordinate);
|
2016-01-04 07:30:03 -05:00
|
|
|
|
2016-01-21 07:07:24 -05:00
|
|
|
double greatCircleDistance(const FixedPointCoordinate first_coordinate,
|
|
|
|
const FixedPointCoordinate second_coordinate);
|
2016-01-04 07:30:03 -05:00
|
|
|
|
|
|
|
double greatCircleDistance(const int lat1, const int lon1, const int lat2, const int lon2);
|
|
|
|
|
2016-01-21 07:07:24 -05:00
|
|
|
double perpendicularDistance(const FixedPointCoordinate segment_source,
|
|
|
|
const FixedPointCoordinate segment_target,
|
|
|
|
const FixedPointCoordinate query_location);
|
2016-01-04 07:30:03 -05:00
|
|
|
|
2016-01-21 07:07:24 -05:00
|
|
|
double perpendicularDistance(const FixedPointCoordinate segment_source,
|
|
|
|
const FixedPointCoordinate segment_target,
|
|
|
|
const FixedPointCoordinate query_location,
|
2016-01-04 07:30:03 -05:00
|
|
|
FixedPointCoordinate &nearest_location,
|
|
|
|
double &ratio);
|
|
|
|
|
|
|
|
double
|
2016-01-21 07:07:24 -05:00
|
|
|
perpendicularDistanceFromProjectedCoordinate(const FixedPointCoordinate segment_source,
|
|
|
|
const FixedPointCoordinate segment_target,
|
|
|
|
const FixedPointCoordinate query_location,
|
|
|
|
const std::pair<double, double> projected_coordinate);
|
2016-01-04 07:30:03 -05:00
|
|
|
|
|
|
|
double
|
2016-01-21 07:07:24 -05:00
|
|
|
perpendicularDistanceFromProjectedCoordinate(const FixedPointCoordinate segment_source,
|
|
|
|
const FixedPointCoordinate segment_target,
|
|
|
|
const FixedPointCoordinate query_location,
|
|
|
|
const std::pair<double, double> projected_coordinate,
|
2016-01-04 07:30:03 -05:00
|
|
|
FixedPointCoordinate &nearest_location,
|
|
|
|
double &ratio);
|
|
|
|
|
|
|
|
double degToRad(const double degree);
|
|
|
|
double radToDeg(const double radian);
|
2015-01-22 10:48:53 -05:00
|
|
|
|
2016-01-21 07:07:24 -05:00
|
|
|
double bearing(const FixedPointCoordinate first_coordinate,
|
|
|
|
const FixedPointCoordinate second_coordinate);
|
2016-01-21 06:58:24 -05:00
|
|
|
|
|
|
|
// Get angle of line segment (A,C)->(C,B)
|
2016-01-21 07:07:24 -05:00
|
|
|
double computeAngle(const FixedPointCoordinate first,
|
|
|
|
const FixedPointCoordinate second,
|
|
|
|
const FixedPointCoordinate third);
|
2016-01-28 08:13:39 -05:00
|
|
|
|
|
|
|
namespace mercator
|
|
|
|
{
|
|
|
|
double yToLat(const double value);
|
|
|
|
double latToY(const double latitude);
|
|
|
|
} // ns mercator
|
|
|
|
} // ns coordinate_calculation
|
|
|
|
} // ns util
|
|
|
|
} // ns osrm
|
2016-01-05 10:51:13 -05:00
|
|
|
|
2015-01-22 10:33:27 -05:00
|
|
|
#endif // COORDINATE_CALCULATION
|