Georef.hpp
Go to the documentation of this file.
1 
10 #if !defined(GEOGRAPHICLIB_GEOREF_HPP)
11 #define GEOGRAPHICLIB_GEOREF_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 
39  private:
40  typedef Math::real real;
41  static const char* const digits_;
42  static const char* const lontile_;
43  static const char* const lattile_;
44  static const char* const degrees_;
45  enum {
46  tile_ = 15, // The size of tile in degrees
47  lonorig_ = -180, // Origin for longitude
48  latorig_ = -90, // Origin for latitude
49  base_ = 10, // Base for minutes
50  baselen_ = 4,
51  maxprec_ = 11, // approximately equivalent to MGRS class
52  maxlen_ = baselen_ + 2 * maxprec_,
53  };
54  Georef(); // Disable constructor
55 
56  public:
57 
82  static void Forward(real lat, real lon, int prec, std::string& georef);
83 
110  static void Reverse(const std::string& georef, real& lat, real& lon,
111  int& prec, bool centerp = true);
112 
121  static Math::real Resolution(int prec) {
122  if (prec < 1)
123  return real(prec < 0 ? 15 : 1);
124  else {
125  using std::pow;
126  // Treat prec = 1 as 2.
127  prec = (std::max)(2, (std::min)(int(maxprec_), prec));
128  // Need extra real because, since C++11, pow(float, int) returns double
129  return 1/(60 * real(pow(real(base_), prec - 2)));
130  }
131  }
132 
142  static int Precision(real res) {
143  using std::abs; res = abs(res);
144  for (int prec = 0; prec < maxprec_; ++prec) {
145  if (prec == 1)
146  continue;
147  if (Resolution(prec) <= res)
148  return prec;
149  }
150  return maxprec_;
151  }
152 
153  };
154 
155 } // namespace GeographicLib
156 
157 #if defined(_MSC_VER)
158 # pragma warning (pop)
159 #endif
160 
161 #endif // GEOGRAPHICLIB_GEOREF_HPP
static const char *const lattile_
Definition: Georef.hpp:43
#define max(a, b)
Definition: datatypes.h:20
#define GEOGRAPHICLIB_EXPORT
Definition: Constants.hpp:91
static Math::real Resolution(int prec)
Definition: Georef.hpp:121
float real
Definition: datatypes.h:10
static const double lat
#define min(a, b)
Definition: datatypes.h:19
static const char *const lontile_
Definition: Georef.hpp:42
static const char *const degrees_
Definition: Georef.hpp:44
cout<< "Here is the matrix m:"<< endl<< m<< endl;Matrix< ptrdiff_t, 3, 1 > res
Namespace for GeographicLib.
static const char *const digits_
Definition: Georef.hpp:41
Math::real real
Definition: Georef.hpp:40
Header for GeographicLib::Constants class.
static const double lon
static int Precision(real res)
Definition: Georef.hpp:142
Jet< T, N > pow(const Jet< T, N > &f, double g)
Definition: jet.h:570
#define abs(x)
Definition: datatypes.h:17
Conversions for the World Geographic Reference System (georef)
Definition: Georef.hpp:38


gtsam
Author(s):
autogenerated on Tue Jul 4 2023 02:34:18