MRPT  1.9.9
data_types.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2018, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 #ifndef data_types_H
10 #define data_types_H
11 
13 
14 namespace mrpt::topography
15 {
16 /** \addtogroup mrpt_topography_grp
17  * @{ */
18 
19 /** @name Data structures
20  @{ */
21 
22 /** A coordinate that is stored as a simple "decimal" angle in degrees, but can
23  * be retrieved/set in the form of DEGREES + arc-MINUTES + arc-SECONDS.
24  */
25 struct TCoords
26 {
27  // Only keep one of the possible representations:
28  /** Also obtained directly through the double(void) operator using a TCoords
29  * anywhere were a double is expected. */
30  double decimal_value;
31 
32  inline TCoords(const int _deg, const int _min, const double _sec)
33  {
34  setDegMinSec(_deg, _min, _sec);
35  }
36  inline TCoords(const double dec) { setFromDecimal(dec); }
37  inline TCoords() { setFromDecimal(0); }
38  /** Automatic conversion to a double value (read-only) */
39  inline operator double(void) const { return decimal_value; }
40  /** Automatic conversion to a double value (read-only) */
41  inline operator double&(void) { return decimal_value; }
42  /** Set from a decimal value (XX.YYYYY) in degrees. */
43  inline void setFromDecimal(const double dec) { decimal_value = dec; }
44  /** Get the decimal value (XX.YYYYY), in degrees - you can also use the
45  * automatic conversion between TCoords and a double. */
46  inline double getDecimalValue() const { return decimal_value; }
47  /** Return the Deg Min' Sec'' representation of this value. */
48  inline void getDegMinSec(int& degrees, int& minutes, double& seconds) const
49  {
50  double aux = std::abs(decimal_value);
51  degrees = (int)aux;
52  minutes = (int)((aux - degrees) * 60.0f);
53  seconds = ((aux - degrees) * 60.0f - minutes) * 60.0f;
54  if (decimal_value < 0) degrees = -degrees;
55  }
56 
57  /** Set the coordinate from its Deg Min' Deg'' parts. */
58  inline void setDegMinSec(
59  const int degrees, const int minutes, const double seconds)
60  {
61  decimal_value = std::abs(degrees) + minutes / 60.0 + seconds / 3600.0;
62  if (degrees < 0) decimal_value = -decimal_value;
63  }
64 
65  /** Return a std::string in the format "DEGdeg MIN' SEC''" */
66  inline std::string getAsString() const
67  {
68  int deg, min;
69  double sec;
70  getDegMinSec(deg, min, sec);
71  return mrpt::format("%ddeg %d' %.04f''", deg, min, sec);
72  }
73 };
74 
75 bool operator==(const TCoords& a, const TCoords& o);
76 bool operator!=(const TCoords& a, const TCoords& o);
77 
78 std::ostream& operator<<(std::ostream& out, const TCoords& o);
79 
80 struct TEllipsoid
81 {
82  inline TEllipsoid() : sa(6378137.0), sb(6356752.314245), name("WGS84") {}
83  inline TEllipsoid(
84  const double _sa, const double _sb, const std::string& _name)
85  : sa(_sa), sb(_sb), name(_name)
86  {
87  }
88 
89  /** largest semiaxis of the reference ellipsoid (in meters) */
90  double sa;
91  /** smallest semiaxis of the reference ellipsoid (in meters) */
92  double sb;
93  /** the ellipsoid name */
95 
96  static inline TEllipsoid Ellipsoid_WGS84()
97  {
98  return TEllipsoid(6378137.000, 6356752.314245, "WGS84");
99  }
100  static inline TEllipsoid Ellipsoid_WGS72()
101  {
102  return TEllipsoid(6378135.000, 6356750.519915, "WGS72");
103  }
104  static inline TEllipsoid Ellipsoid_WGS66()
105  {
106  return TEllipsoid(6378145.000, 6356759.769356, "WGS66");
107  }
109  {
110  return TEllipsoid(6376896.000, 6355834.846700, "Walbeck_1817");
111  }
113  {
114  return TEllipsoid(6378160.000, 6356774.720000, "Sudamericano_1969");
115  }
117  {
118  return TEllipsoid(
119  6378157.500, 6356772.200000, "Nuevo_Internacional_1967");
120  }
122  {
123  return TEllipsoid(
124  6378150.000, 6356768.337303, "Mercury_Modificado_1968");
125  }
127  {
128  return TEllipsoid(6378166.000, 6356784.283666, "Mercury_1960");
129  }
131  {
132  return TEllipsoid(6378245.000, 6356863.018800, "Krasovsky_1940");
133  }
135  {
136  return TEllipsoid(6378388.000, 6356911.946130, "Internacional_1924");
137  }
139  {
140  return TEllipsoid(6378388.000, 6356911.946130, "Internacional_1909");
141  }
143  {
144  return TEllipsoid(6378270.000, 6356794.343479, "Hough_1960");
145  }
147  {
148  return TEllipsoid(6378200.000, 6356818.170000, "Helmert_1906");
149  }
151  {
152  return TEllipsoid(6378388.000, 6356911.946130, "Hayford_1909");
153  }
154  static inline TEllipsoid Ellipsoid_GRS80()
155  {
156  return TEllipsoid(6378137.000, 6356752.314140, "GRS80");
157  }
159  {
160  return TEllipsoid(6378150.000, 6356768.330000, "Fischer_1968");
161  }
163  {
164  return TEllipsoid(6378166.000, 6356784.280000, "Fischer_1960");
165  }
167  {
168  return TEllipsoid(6378249.145, 6356514.869550, "Clarke_1880");
169  }
171  {
172  return TEllipsoid(6378206.400, 6356583.800000, "Clarke_1866");
173  }
175  {
176  return TEllipsoid(6377397.155, 6356078.962840, "Bessel_1841");
177  }
179  {
180  return TEllipsoid(6377340.189, 6356034.447900, "Airy_Modificado_1965");
181  }
183  {
184  return TEllipsoid(6377563.396, 6356256.910000, "Airy_1830");
185  }
186 };
187 
190 
191 /** A set of geodetic coordinates: latitude, longitude and height, defined over
192  * a given geoid (typically, WGS84) */
194 {
195  TGeodeticCoords() : lat(0), lon(0), height(0) {}
196  TGeodeticCoords(const double _lat, const double _lon, const double _height)
197  : lat(_lat), lon(_lon), height(_height)
198  {
199  }
200 
201  inline bool isClear() const
202  {
203  return lat.getDecimalValue() == 0 && lon.getDecimalValue() == 0 &&
204  height == 0;
205  }
206 
207  /** Latitude (in degrees) */
209  /** Longitude (in degrees) */
211  /** Geodetic height (in meters) */
212  double height;
213 };
214 
215 bool operator==(const TGeodeticCoords& a, const TGeodeticCoords& o);
216 bool operator!=(const TGeodeticCoords& a, const TGeodeticCoords& o);
217 
218 /** Parameters for a topographic transfomation
219  * \sa TDatum10Params, transform7params
220  */
222 {
223  /** Deltas (X,Y,Z) */
224  double dX, dY, dZ;
225  /** Rotation components (in secs) */
226  double Rx, Ry, Rz;
227  /** Scale factor (in ppm) (Scale is 1+dS/1e6) */
228  double dS;
229 
231  const double _dX, const double _dY, const double _dZ, const double _Rx,
232  const double _Ry, const double _Rz, const double _dS)
233  : dX(_dX), dY(_dY), dZ(_dZ)
234  {
235  Rx = mrpt::DEG2RAD(_Rx / 60 / 60);
236  Ry = mrpt::DEG2RAD(_Ry / 60 / 60);
237  Rz = mrpt::DEG2RAD(_Rz / 60 / 60);
238  dS = _dS * 1e-6;
239  }
240 };
241 
243 {
244  /** Deltas (X,Y,Z) */
245  double dX, dY, dZ;
246  double m11, m12, m13, m21, m22, m23, m31, m32, m33;
247  /** Scale factor (in ppm) (Scale is 1+dS/1e6) */
248  double dS;
249 
251  const double _dX, const double _dY, const double _dZ, const double _m11,
252  const double _m12, const double _m13, const double _m21,
253  const double _m22, const double _m23, const double _m31,
254  const double _m32, const double _m33, const double _dS)
255  : dX(_dX),
256  dY(_dY),
257  dZ(_dZ),
258  m11(_m11),
259  m12(_m12),
260  m13(_m13),
261  m21(_m21),
262  m22(_m22),
263  m23(_m23),
264  m31(_m31),
265  m32(_m32),
266  m33(_m33)
267  {
268  dS = _dS * 1e-6;
269  }
270 };
271 
272 /** Parameters for a topographic transfomation
273  * \sa TDatum7Params, transform10params
274  */
276 {
277  /** Deltas (X,Y,Z) */
278  double dX, dY, dZ;
279  /** To be substracted to the input point */
280  double Xp, Yp, Zp;
281  /** Rotation components */
282  double Rx, Ry, Rz;
283  /** Scale factor (Scale is 1+dS) */
284  double dS;
285 
287  const double _dX, const double _dY, const double _dZ, const double _Xp,
288  const double _Yp, const double _Zp, const double _Rx, const double _Ry,
289  const double _Rz, const double _dS)
290  : dX(_dX), dY(_dY), dZ(_dZ), Xp(_Xp), Yp(_Yp), Zp(_Zp)
291  {
292  Rx = mrpt::DEG2RAD(_Rx / 60 / 60);
293  Ry = mrpt::DEG2RAD(_Ry / 60 / 60);
294  Rz = mrpt::DEG2RAD(_Rz / 60 / 60);
295  dS = _dS * 1e-6;
296  }
297 };
298 
299 /** Parameters for a topographic transfomation
300  * \sa TDatumHelmert3D, transformHelmert2D
301  */
303 {
304  /** Deltas [X,Y] */
305  double dX, dY;
306  double alpha; // The rotation about Z-axis (degrees)
307  double dS; // Scale factor (Scale is 1+dS)
308  double Xp, Yp; // Coordinates of the rotation point
309 
311  const double _dX, const double _dY, const double _alpha,
312  const double _dS, const double _Xp, const double _Yp)
313  : dX(_dX), dY(_dY), Xp(_Xp), Yp(_Yp)
314  {
315  alpha = mrpt::DEG2RAD(_alpha);
316  dS = _dS * 1e-6;
317  }
318 };
319 
321 {
322  double a, b, c, d;
323 
325  const double _a, const double _b, const double _c, const double _d)
326  : a(_a), b(_b), c(_c), d(_d)
327  {
328  }
329 };
330 
331 /** Parameters for a topographic transfomation
332  * \sa TDatumHelmert2D, transformHelmert3D
333  */
335 {
336  /** Deltas (X,Y,Z) */
337  double dX, dY, dZ;
338  /** Rotation components */
339  double Rx, Ry, Rz;
340  /** Scale factor (Scale is 1+dS) */
341  double dS;
342 
344  const double _dX, const double _dY, const double _dZ, const double _Rx,
345  const double _Ry, const double _Rz, const double _dS)
346  : dX(_dX), dY(_dY), dZ(_dZ)
347  {
348  Rx = mrpt::DEG2RAD(_Rx / 60 / 60);
349  Ry = mrpt::DEG2RAD(_Ry / 60 / 60);
350  Rz = mrpt::DEG2RAD(_Rz / 60 / 60);
351  dS = _dS * 1e-6;
352  }
353 };
354 
355 /** Parameters for a topographic transfomation
356  * \sa TDatumHelmert2D, transformHelmert3D
357  */
359 {
360  double a, b, c, d, e, f, g;
361 
363  const double _a, const double _b, const double _c, const double _d,
364  const double _e, const double _f, const double _g)
365  : a(_a), b(_b), c(_c), d(_d), e(_e), f(_f), g(_g)
366  {
367  }
368 };
369 
370 /** Parameters for a topographic transfomation
371  * \sa transform1D
372  */
374 {
375  /** Deltas (X,Y,Z) */
376  double dX, dY, DZ;
377  /** Scale factor (Scale is 1+dS) */
378  double dS;
379 
381  const double _dX, const double _dY, const double _DZ, const double _dS)
382  : dX(_dX), dY(_dY), DZ(_DZ)
383  {
384  dS = _dS * 1e-6;
385  }
386 };
387 
388 /** Parameters for a topographic transfomation
389  * \sa transform1D
390  */
392 {
393  /** Deltas (X,Y,Z) */
394  double dX, dY;
395  /** Scale factor in X and Y */
396  double dSx, dSy;
397  /** Distortion angle */
398  double beta;
399 
401  const double _dX, const double _dY, const double _dSx,
402  const double _dSy, const double _beta)
403  : dX(_dX), dY(_dY)
404  {
405  dSx = _dSx * 1e-6;
406  dSy = _dSy * 1e-6;
407  beta = mrpt::DEG2RAD(_beta / 60 / 60);
408  }
409 };
410 
411 /** @} */
412 
413 /** @} */ // end of grouping
414 
415 }
416 #endif
417 
418 
double sa
largest semiaxis of the reference ellipsoid (in meters)
Definition: data_types.h:90
GLclampf GLclampf GLclampf alpha
Definition: glext.h:3525
static TEllipsoid Ellipsoid_Fischer_1968()
Definition: data_types.h:158
double getDecimalValue() const
Get the decimal value (XX.YYYYY), in degrees - you can also use the automatic conversion between TCoo...
Definition: data_types.h:46
static TEllipsoid Ellipsoid_Fischer_1960()
Definition: data_types.h:162
double dX
Deltas (X,Y,Z)
Definition: data_types.h:224
double dX
Deltas (X,Y,Z)
Definition: data_types.h:278
static TEllipsoid Ellipsoid_Sudamericano_1969()
Definition: data_types.h:112
#define min(a, b)
static TEllipsoid Ellipsoid_Airy_1830()
Definition: data_types.h:182
TDatum1DTransf(const double _dX, const double _dY, const double _DZ, const double _dS)
Definition: data_types.h:380
double dS
Scale factor (in ppm) (Scale is 1+dS/1e6)
Definition: data_types.h:248
Parameters for a topographic transfomation.
Definition: data_types.h:334
TDatum7Params(const double _dX, const double _dY, const double _dZ, const double _Rx, const double _Ry, const double _Rz, const double _dS)
Definition: data_types.h:230
Parameters for a topographic transfomation.
Definition: data_types.h:302
double Rx
Rotation components.
Definition: data_types.h:282
double DEG2RAD(const double x)
Degrees to radians.
std::string name
the ellipsoid name
Definition: data_types.h:94
TDatumHelmert3D(const double _dX, const double _dY, const double _dZ, const double _Rx, const double _Ry, const double _Rz, const double _dS)
Definition: data_types.h:343
A set of geodetic coordinates: latitude, longitude and height, defined over a given geoid (typically...
Definition: data_types.h:193
double dS
Scale factor (in ppm) (Scale is 1+dS/1e6)
Definition: data_types.h:228
TEllipsoid(const double _sa, const double _sb, const std::string &_name)
Definition: data_types.h:83
bool operator!=(const TCoords &a, const TCoords &o)
Definition: conversions.cpp:27
bool operator==(const TCoords &a, const TCoords &o)
Definition: conversions.cpp:23
double dS
Scale factor (Scale is 1+dS)
Definition: data_types.h:378
static TEllipsoid Ellipsoid_Krasovsky_1940()
Definition: data_types.h:130
double Xp
To be substracted to the input point.
Definition: data_types.h:280
void getDegMinSec(int &degrees, int &minutes, double &seconds) const
Return the Deg Min&#39; Sec&#39;&#39; representation of this value.
Definition: data_types.h:48
double Rx
Rotation components.
Definition: data_types.h:339
void setFromDecimal(const double dec)
Set from a decimal value (XX.YYYYY) in degrees.
Definition: data_types.h:43
A coordinate that is stored as a simple "decimal" angle in degrees, but can be retrieved/set in the f...
Definition: data_types.h:25
double dSx
Scale factor in X and Y.
Definition: data_types.h:396
std::string getAsString() const
Return a std::string in the format "DEGdeg MIN&#39; SEC&#39;&#39;".
Definition: data_types.h:66
TDatumHelmert2D_TOPCON(const double _a, const double _b, const double _c, const double _d)
Definition: data_types.h:324
double Rx
Rotation components (in secs)
Definition: data_types.h:226
Parameters for a topographic transfomation.
Definition: data_types.h:358
static TEllipsoid Ellipsoid_WGS66()
Definition: data_types.h:104
double sb
smallest semiaxis of the reference ellipsoid (in meters)
Definition: data_types.h:92
Parameters for a topographic transfomation.
Definition: data_types.h:373
static TEllipsoid Ellipsoid_Nuevo_Internacional_1967()
Definition: data_types.h:116
TCoords lon
Longitude (in degrees)
Definition: data_types.h:210
static TEllipsoid Ellipsoid_Helmert_1906()
Definition: data_types.h:146
static TEllipsoid Ellipsoid_Internacional_1909()
Definition: data_types.h:138
const GLubyte * c
Definition: glext.h:6313
static TEllipsoid Ellipsoid_Mercury_1960()
Definition: data_types.h:126
static TEllipsoid Ellipsoid_Mercury_Modificado_1968()
Definition: data_types.h:121
static TEllipsoid Ellipsoid_WGS72()
Definition: data_types.h:100
GLubyte g
Definition: glext.h:6279
GLubyte GLubyte b
Definition: glext.h:6279
double dS
Scale factor (Scale is 1+dS)
Definition: data_types.h:284
static TEllipsoid Ellipsoid_Hough_1960()
Definition: data_types.h:142
static TEllipsoid Ellipsoid_Walbeck_1817()
Definition: data_types.h:108
static TEllipsoid Ellipsoid_Clarke_1880()
Definition: data_types.h:166
static TEllipsoid Ellipsoid_GRS80()
Definition: data_types.h:154
GLsizei const GLchar ** string
Definition: glext.h:4101
double dS
Scale factor (Scale is 1+dS)
Definition: data_types.h:341
static TEllipsoid Ellipsoid_WGS84()
Definition: data_types.h:96
TCoords(const int _deg, const int _min, const double _sec)
Definition: data_types.h:32
TDatum10Params(const double _dX, const double _dY, const double _dZ, const double _Xp, const double _Yp, const double _Zp, const double _Rx, const double _Ry, const double _Rz, const double _dS)
Definition: data_types.h:286
TCoords(const double dec)
Definition: data_types.h:36
TGeodeticCoords(const double _lat, const double _lon, const double _height)
Definition: data_types.h:196
TDatumTransfInterpolation(const double _dX, const double _dY, const double _dSx, const double _dSy, const double _beta)
Definition: data_types.h:400
static TEllipsoid Ellipsoid_Hayford_1909()
Definition: data_types.h:150
Parameters for a topographic transfomation.
Definition: data_types.h:275
TDatum7Params_TOPCON(const double _dX, const double _dY, const double _dZ, const double _m11, const double _m12, const double _m13, const double _m21, const double _m22, const double _m23, const double _m31, const double _m32, const double _m33, const double _dS)
Definition: data_types.h:250
TDatumHelmert2D(const double _dX, const double _dY, const double _alpha, const double _dS, const double _Xp, const double _Yp)
Definition: data_types.h:310
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
Definition: format.cpp:16
std::ostream & operator<<(std::ostream &out, const TCoords &o)
Definition: conversions.cpp:52
double dX
Deltas (X,Y,Z)
Definition: data_types.h:337
void setDegMinSec(const int degrees, const int minutes, const double seconds)
Set the coordinate from its Deg Min&#39; Deg&#39;&#39; parts.
Definition: data_types.h:58
GLuint const GLchar * name
Definition: glext.h:4054
double height
Geodetic height (in meters)
Definition: data_types.h:212
static TEllipsoid Ellipsoid_Clarke_1866()
Definition: data_types.h:170
static TEllipsoid Ellipsoid_Bessel_1841()
Definition: data_types.h:174
typedef void(APIENTRYP PFNGLBLENDCOLORPROC)(GLclampf red
TDatumHelmert3D_TOPCON(const double _a, const double _b, const double _c, const double _d, const double _e, const double _f, const double _g)
Definition: data_types.h:362
Lightweight 3D point.
This namespace provides topography helper functions, coordinate transformations.
Definition: conversions.h:22
double decimal_value
Also obtained directly through the double(void) operator using a TCoords anywhere were a double is ex...
Definition: data_types.h:30
static TEllipsoid Ellipsoid_Internacional_1924()
Definition: data_types.h:134
GLenum GLsizei GLsizei height
Definition: glext.h:3554
Parameters for a topographic transfomation.
Definition: data_types.h:221
Parameters for a topographic transfomation.
Definition: data_types.h:391
GLubyte GLubyte GLubyte a
Definition: glext.h:6279
TCoords lat
Latitude (in degrees)
Definition: data_types.h:208
static TEllipsoid Ellipsoid_Airy_Modificado_1965()
Definition: data_types.h:178
double dX
Deltas (X,Y,Z)
Definition: data_types.h:376



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020