10 #if !defined(GEOGRAPHICLIB_GEOHASH_HPP)
11 #define GEOGRAPHICLIB_GEOHASH_HPP 1
17 # pragma warning (push)
18 # pragma warning (disable: 4251)
21 namespace GeographicLib {
42 static const int maxlen_ = 18;
43 static const unsigned long long mask_ = 1ULL << 45;
44 static const int decprec_[];
45 static inline real shift() {
46 using std::pow;
static const real shift = pow(
real(2), 45);
49 static inline real loneps() {
50 static const real loneps = 180 / shift();
53 static inline real lateps() {
54 static const real lateps = 90 / shift();
57 static const real lateps_;
58 static const std::string lcdigits_;
59 static const std::string ucdigits_;
81 static void Forward(real lat, real lon,
int len, std::string& geohash);
100 static void Reverse(
const std::string& geohash, real& lat, real& lon,
101 int& len,
bool centerp =
true);
112 len = (std::max)(0, (std::min)(int(maxlen_), len));
113 return 180 * std::pow(0.5, 5 * len / 2);
125 len = (std::max)(0, (std::min)(int(maxlen_), len));
126 return 360 * std::pow(0.5, 5 * len - 5 * len / 2);
141 for (
int len = 0; len < maxlen_; ++len)
142 if (LongitudeResolution(len) <= res)
158 latres = abs(latres);
159 lonres = abs(lonres);
160 for (
int len = 0; len < maxlen_; ++len)
161 if (LatitudeResolution(len) <= latres &&
162 LongitudeResolution(len) <= lonres)
179 using std::floor;
using std::log;
180 return -int(floor(log(LatitudeResolution(len))/log(
Math::real(10))));
187 #if defined(_MSC_VER)
188 # pragma warning (pop)
191 #endif // GEOGRAPHICLIB_GEOHASH_HPP