Conversions for geohashes. More...
#include <Geohash.hpp>
Static Public Member Functions | |
static int | DecimalPrecision (int len) |
static void | Forward (real lat, real lon, int len, std::string &geohash) |
static int | GeohashLength (real res) |
static int | GeohashLength (real latres, real lonres) |
static Math::real | LatitudeResolution (int len) |
static Math::real | LongitudeResolution (int len) |
static void | Reverse (const std::string &geohash, real &lat, real &lon, int &len, bool centerp=true) |
Private Types | |
typedef Math::real | real |
Private Member Functions | |
Geohash () | |
Static Private Attributes | |
static const char *const | lcdigits_ = "0123456789bcdefghjkmnpqrstuvwxyz" |
static const unsigned long long | mask_ = 1ULL << 45 |
static const int | maxlen_ = 18 |
static const char *const | ucdigits_ = "0123456789BCDEFGHJKMNPQRSTUVWXYZ" |
Conversions for geohashes.
Geohashes are described in
They provide a compact string representation of a particular geographic location (expressed as latitude and longitude), with the property that if trailing characters are dropped from the string the geographic location remains nearby. The classes Georef and GARS implement similar compact representations.
Example of use:
Definition at line 40 of file Geohash.hpp.
|
private |
Definition at line 42 of file Geohash.hpp.
|
private |
The decimal geographic precision required to match a given geohash length. This is the number of digits needed after decimal point in a decimal degrees representation.
[in] | len | the length of the geohash. |
Internally, len is first put in the range [0, 18]. The returned decimal precision is in the range [−2, 12].
Definition at line 167 of file Geohash.hpp.
Convert from geographic coordinates to a geohash.
[in] | lat | latitude of point (degrees). |
[in] | lon | longitude of point (degrees). |
[in] | len | the length of the resulting geohash. |
[out] | geohash | the geohash. |
GeographicErr | if lat is not in [−90°, 90°]. |
std::bad_alloc | if memory for geohash can't be allocated. |
Internally, len is first put in the range [0, 18]. (len = 18 provides approximately 1μm precision.)
If lat or lon is NaN, the returned geohash is "invalid".
Definition at line 20 of file src/Geohash.cpp.
The geohash length required to meet a given geographic resolution.
[in] | res | the minimum of resolution in latitude and longitude (degrees). |
The returned length is in the range [0, 18].
Definition at line 128 of file Geohash.hpp.
The geohash length required to meet a given geographic resolution.
[in] | latres | the resolution in latitude (degrees). |
[in] | lonres | the resolution in longitude (degrees). |
The returned length is in the range [0, 18].
Definition at line 145 of file Geohash.hpp.
|
inlinestatic |
The latitude resolution of a geohash.
[in] | len | the length of the geohash. |
Internally, len is first put in the range [0, 18].
Definition at line 99 of file Geohash.hpp.
|
inlinestatic |
The longitude resolution of a geohash.
[in] | len | the length of the geohash. |
Internally, len is first put in the range [0, 18].
Definition at line 113 of file Geohash.hpp.
|
static |
Convert from a geohash to geographic coordinates.
[in] | geohash | the geohash. |
[out] | lat | latitude of point (degrees). |
[out] | lon | longitude of point (degrees). |
[out] | len | the length of the geohash. |
[in] | centerp | if true (the default) return the center of the geohash location, otherwise return the south-west corner. |
GeographicErr | if geohash contains illegal characters. |
Only the first 18 characters for geohash are considered. (18 characters provides approximately 1μm precision.) The case of the letters in geohash is ignored.
If the first 3 characters of geohash are "inv", then lat and lon are set to NaN and len is unchanged. ("nan" is treated similarly.)
Definition at line 59 of file src/Geohash.cpp.
|
staticprivate |
Definition at line 45 of file Geohash.hpp.
|
staticprivate |
Definition at line 44 of file Geohash.hpp.
|
staticprivate |
Definition at line 43 of file Geohash.hpp.
|
staticprivate |
Definition at line 46 of file Geohash.hpp.