Folds mercator projections into coordinate_calculation

This commit is contained in:
Daniel J. Hofmann
2016-01-28 14:13:39 +01:00
parent d1c4a26791
commit 5de8f1803c
5 changed files with 32 additions and 45 deletions
+9 -3
View File
@@ -62,8 +62,14 @@ double bearing(const FixedPointCoordinate first_coordinate,
double computeAngle(const FixedPointCoordinate first,
const FixedPointCoordinate second,
const FixedPointCoordinate third);
}
}
}
namespace mercator
{
double yToLat(const double value);
double latToY(const double latitude);
} // ns mercator
} // ns coordinate_calculation
} // ns util
} // ns osrm
#endif // COORDINATE_CALCULATION
-26
View File
@@ -1,26 +0,0 @@
#ifndef MERCATOR_HPP
#define MERCATOR_HPP
#include <cmath>
namespace osrm
{
namespace util
{
namespace mercator
{
inline double yToLat(const double value) noexcept
{
return 180. * M_1_PI * (2. * std::atan(std::exp(value * M_PI / 180.)) - M_PI_2);
}
inline double latToY(const double latitude) noexcept
{
return 180. * M_1_PI * std::log(std::tan(M_PI_4 + latitude * (M_PI / 180.) / 2.));
}
}
}
}
#endif // MERCATOR_HPP
+3 -4
View File
@@ -8,7 +8,6 @@
#include "util/bearing.hpp"
#include "util/integer_range.hpp"
#include "util/mercator.hpp"
#include "util/osrm_exception.hpp"
#include "util/typedefs.hpp"
@@ -140,8 +139,8 @@ class StaticRTree
FixedPointCoordinate(coordinate_list.at(current_element.v).lat,
coordinate_list.at(current_element.v).lon));
current_centroid.lat =
COORDINATE_PRECISION *
mercator::latToY(current_centroid.lat / COORDINATE_PRECISION);
COORDINATE_PRECISION * coordinate_calculation::mercator::latToY(
current_centroid.lat / COORDINATE_PRECISION);
current_wrapper.m_hilbert_value = hilbertCode(current_centroid);
}
@@ -342,7 +341,7 @@ class StaticRTree
{
std::vector<EdgeDataT> results;
std::pair<double, double> projected_coordinate = {
mercator::latToY(input_coordinate.lat / COORDINATE_PRECISION),
coordinate_calculation::mercator::latToY(input_coordinate.lat / COORDINATE_PRECISION),
input_coordinate.lon / COORDINATE_PRECISION};
// initialize queue with root element