gtsam
3rdparty
GeographicLib
examples
examples/example-Geohash.cpp
Go to the documentation of this file.
1
// Example of using the GeographicLib::Geohash class
2
3
#include <iostream>
4
#include <iomanip>
5
#include <exception>
6
#include <string>
7
#include <
GeographicLib/Geohash.hpp
>
8
9
using namespace
std
;
10
using namespace
GeographicLib
;
11
12
int
main
() {
13
try
{
14
{
15
// Sample forward calculation
16
double
lat
= 57.64911,
lon
= 10.40744;
// Jutland (the wikipedia example)
17
string
geohash;
18
int
maxlen = Geohash::GeohashLength(1.0
e
-5);
19
for
(
int
len
= 0;
len
<= maxlen; ++
len
) {
20
Geohash::Forward
(
lat
,
lon
,
len
, geohash);
21
cout <<
len
<<
" "
<< geohash <<
"\n"
;
22
}
23
}
24
{
25
// Sample reverse calculation
26
string
geohash =
"u4pruydqqvj"
;
27
double
lat
,
lon
;
28
cout << fixed;
29
for
(
unsigned
i
= 0;
i
<= geohash.length(); ++
i
) {
30
int
len
;
31
Geohash::Reverse(geohash.substr(0,
i
),
lat
,
lon
,
len
);
32
cout << setprecision(
max
(0, Geohash::DecimalPrecision(
len
)))
33
<<
len
<<
" "
<<
lat
<<
" "
<<
lon
<<
"\n"
;
34
}
35
}
36
}
37
catch
(
const
exception&
e
) {
38
cerr <<
"Caught exception: "
<<
e
.what() <<
"\n"
;
39
return
1;
40
}
41
}
Eigen::Forward
@ Forward
Definition:
NumericalDiff.h:19
e
Array< double, 1, 3 > e(1./3., 0.5, 2.)
GeographicLib
Namespace for GeographicLib.
Definition:
JacobiConformal.hpp:15
main
int main()
Definition:
examples/example-Geohash.cpp:12
Geohash.hpp
Header for GeographicLib::Geohash class.
std
Definition:
BFloat16.h:88
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
i
int i
Definition:
BiCGSTAB_step_by_step.cpp:9
lat
static const double lat
Definition:
testGeographicLib.cpp:34
gtsam
Author(s):
autogenerated on Sun Dec 22 2024 04:11:31