Geohash.hpp
Go to the documentation of this file.
1 
10 #if !defined(GEOGRAPHICLIB_GEOHASH_HPP)
11 #define GEOGRAPHICLIB_GEOHASH_HPP 1
12 
14 
15 #if defined(_MSC_VER)
16 // Squelch warnings about dll vs string
17 # pragma warning (push)
18 # pragma warning (disable: 4251)
19 #endif
20 
21 namespace GeographicLib {
22 
41  private:
42  typedef Math::real real;
43  static const int maxlen_ = 18;
44  static const unsigned long long mask_ = 1ULL << 45;
45  static const char* const lcdigits_;
46  static const char* const ucdigits_;
47  Geohash(); // Disable constructor
48 
49  public:
50 
67  static void Forward(real lat, real lon, int len, std::string& geohash);
68 
88  static void Reverse(const std::string& geohash, real& lat, real& lon,
89  int& len, bool centerp = true);
90 
100  using std::ldexp;
101  len = (std::max)(0, (std::min)(int(maxlen_), len));
102  return ldexp(real(180), -(5 * len / 2));
103  }
104 
114  using std::ldexp;
115  len = (std::max)(0, (std::min)(int(maxlen_), len));
116  return ldexp(real(360), -(5 * len - 5 * len / 2));
117  }
118 
128  static int GeohashLength(real res) {
129  using std::abs; res = abs(res);
130  for (int len = 0; len < maxlen_; ++len)
131  if (LongitudeResolution(len) <= res)
132  return len;
133  return maxlen_;
134  }
135 
145  static int GeohashLength(real latres, real lonres) {
146  using std::abs;
147  latres = abs(latres);
148  lonres = abs(lonres);
149  for (int len = 0; len < maxlen_; ++len)
150  if (LatitudeResolution(len) <= latres &&
151  LongitudeResolution(len) <= lonres)
152  return len;
153  return maxlen_;
154  }
155 
167  static int DecimalPrecision(int len) {
168  using std::floor; using std::log;
169  return -int(floor(log(LatitudeResolution(len))/log(Math::real(10))));
170  }
171 
172  };
173 
174 } // namespace GeographicLib
175 
176 #if defined(_MSC_VER)
177 # pragma warning (pop)
178 #endif
179 
180 #endif // GEOGRAPHICLIB_GEOHASH_HPP
Eigen::Forward
@ Forward
Definition: NumericalDiff.h:19
gtsam.examples.DogLegOptimizerExample.int
int
Definition: DogLegOptimizerExample.py:111
GeographicLib::Geohash::GeohashLength
static int GeohashLength(real latres, real lonres)
Definition: Geohash.hpp:145
GeographicLib::Geohash::LongitudeResolution
static Math::real LongitudeResolution(int len)
Definition: Geohash.hpp:113
GeographicLib
Namespace for GeographicLib.
Definition: JacobiConformal.hpp:15
GeographicLib::Geohash
Conversions for geohashes.
Definition: Geohash.hpp:40
real
float real
Definition: datatypes.h:10
GeographicLib::Geohash::lcdigits_
static const char *const lcdigits_
Definition: Geohash.hpp:45
log
const EIGEN_DEVICE_FUNC LogReturnType log() const
Definition: ArrayCwiseUnaryOps.h:128
GEOGRAPHICLIB_EXPORT
#define GEOGRAPHICLIB_EXPORT
Definition: Constants.hpp:91
res
cout<< "Here is the matrix m:"<< endl<< m<< endl;Matrix< ptrdiff_t, 3, 1 > res
Definition: PartialRedux_count.cpp:3
GeographicLib::Geohash::DecimalPrecision
static int DecimalPrecision(int len)
Definition: Geohash.hpp:167
GeographicLib::Geohash::GeohashLength
static int GeohashLength(real res)
Definition: Geohash.hpp:128
GeographicLib::Math::real
double real
Definition: Math.hpp:129
GeographicLib::Geohash::ucdigits_
static const char *const ucdigits_
Definition: Geohash.hpp:46
GeographicLib::Geohash::LatitudeResolution
static Math::real LatitudeResolution(int len)
Definition: Geohash.hpp:99
Constants.hpp
Header for GeographicLib::Constants class.
GeographicLib::Geohash::real
Math::real real
Definition: Geohash.hpp:42
min
#define min(a, b)
Definition: datatypes.h:19
abs
#define abs(x)
Definition: datatypes.h:17
len
size_t len(handle h)
Get the length of a Python object.
Definition: pytypes.h:2446
lon
static const double lon
Definition: testGeographicLib.cpp:34
max
#define max(a, b)
Definition: datatypes.h:20
real
Definition: main.h:100
floor
const EIGEN_DEVICE_FUNC FloorReturnType floor() const
Definition: ArrayCwiseUnaryOps.h:481
lat
static const double lat
Definition: testGeographicLib.cpp:34


gtsam
Author(s):
autogenerated on Sun Dec 22 2024 04:11:37