osrm-backend/include/util/mercator.hpp

27 lines
431 B
C++
Raw Normal View History

2015-01-27 11:44:46 -05:00
#ifndef MERCATOR_HPP
#define MERCATOR_HPP
#include <cmath>
2016-01-05 10:51:13 -05:00
namespace osrm
{
namespace util
{
namespace mercator
{
2016-01-05 10:51:13 -05:00
inline double yToLat(const double value) noexcept
2015-01-27 11:44:46 -05:00
{
return 180. * M_1_PI * (2. * std::atan(std::exp(value * M_PI / 180.)) - M_PI_2);
}
2015-01-27 11:44:46 -05:00
inline double latToY(const double latitude) noexcept
{
return 180. * M_1_PI * std::log(std::tan(M_PI_4 + latitude * (M_PI / 180.) / 2.));
}
}
2016-01-05 10:51:13 -05:00
}
}
2015-01-27 11:44:46 -05:00
#endif // MERCATOR_HPP