Main MRPT website > C++ reference
MRPT logo

data_types.h

Go to the documentation of this file.
00001 /* +---------------------------------------------------------------------------+
00002    |          The Mobile Robot Programming Toolkit (MRPT) C++ library          |
00003    |                                                                           |
00004    |                   http://mrpt.sourceforge.net/                            |
00005    |                                                                           |
00006    |   Copyright (C) 2005-2011  University of Malaga                           |
00007    |                                                                           |
00008    |    This software was written by the Machine Perception and Intelligent    |
00009    |      Robotics Lab, University of Malaga (Spain).                          |
00010    |    Contact: Jose-Luis Blanco  <jlblanco@ctima.uma.es>                     |
00011    |                                                                           |
00012    |  This file is part of the MRPT project.                                   |
00013    |                                                                           |
00014    |     MRPT is free software: you can redistribute it and/or modify          |
00015    |     it under the terms of the GNU General Public License as published by  |
00016    |     the Free Software Foundation, either version 3 of the License, or     |
00017    |     (at your option) any later version.                                   |
00018    |                                                                           |
00019    |   MRPT is distributed in the hope that it will be useful,                 |
00020    |     but WITHOUT ANY WARRANTY; without even the implied warranty of        |
00021    |     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         |
00022    |     GNU General Public License for more details.                          |
00023    |                                                                           |
00024    |     You should have received a copy of the GNU General Public License     |
00025    |     along with MRPT.  If not, see <http://www.gnu.org/licenses/>.         |
00026    |                                                                           |
00027    +---------------------------------------------------------------------------+ */
00028 #ifndef  data_types_H
00029 #define  data_types_H
00030 
00031 #include <mrpt/utils/utils_defs.h>
00032 #include <mrpt/math/lightweight_geom_data.h>
00033 
00034 #include <mrpt/topography/link_pragmas.h>
00035 
00036 namespace mrpt
00037 {
00038         namespace topography
00039         {
00040                 using namespace std;
00041                 using namespace mrpt::utils;
00042 
00043 
00044         /** =======================================================================
00045            @name Data structures
00046            @{ */
00047 
00048                 /** A coordinate that is stored as a simple "decimal" angle in degrees, but can be retrieved/set in the form of DEGREES + arc-MINUTES + arc-SECONDS.
00049                   */
00050                 struct TOPO_IMPEXP TCoords
00051                 {
00052                         // Only keep one of the possible representations:
00053                         double decimal_value; //!< Also obtained directly through the double(void) operator using a TCoords anywhere were a double is expected.
00054 
00055                         inline TCoords( const int _deg, const int _min, const double _sec ) { setDegMinSec(_deg,_min,_sec); }
00056                         inline TCoords( const double dec ) { setFromDecimal(dec); }
00057                         inline TCoords() { setFromDecimal(0); }
00058 
00059                         /** Automatic conversion to a double value (read-only) */
00060                         inline operator double(void) const { return decimal_value; }
00061 
00062                         /** Automatic conversion to a double value (read-only) */
00063                         inline operator double& (void) { return decimal_value; }
00064 
00065                         /** Set from a decimal value (XX.YYYYY) in degrees. */
00066                         inline void setFromDecimal( const double dec ) { decimal_value = dec; }
00067 
00068                         /** Get the decimal value (XX.YYYYY), in degrees - you can also use the automatic conversion between TCoords and a double.  */
00069                         inline double getDecimalValue() const { return decimal_value; }
00070 
00071                         /** Return the Deg Min' Sec'' representation of this value. */
00072                         inline void getDegMinSec( int &degrees, int &minutes, double &seconds) const
00073                         {
00074                                 double aux = std::abs(decimal_value);
00075                                 degrees = (int)aux;
00076                                 minutes = (int)((aux - degrees)*60.0f);
00077                                 seconds = ((aux - degrees)*60.0f - minutes)*60.0f;
00078                                 if( decimal_value<0 ) degrees = -degrees;
00079                         }
00080 
00081                         /** Set the coordinate from its Deg Min' Deg'' parts. */
00082                         inline void setDegMinSec(const int degrees, const int minutes, const double seconds)
00083                         {
00084                                 decimal_value = std::abs(degrees)+minutes/60.0+seconds/3600.0;
00085                                 if(degrees<0)  decimal_value  = - decimal_value;
00086                         }
00087 
00088                         /** Return a string in the format "DEGdeg MIN' SEC''" */
00089                         inline std::string getAsString() const
00090                         {
00091                                 int deg,min;
00092                                 double sec;
00093                                 getDegMinSec( deg,min,sec);
00094                                 return mrpt::format("%ddeg %d' %.010f''",deg,min,sec );
00095                         }
00096 
00097                 };
00098 
00099                 bool TOPO_IMPEXP operator ==(const TCoords &a, const TCoords &o);
00100                 bool TOPO_IMPEXP operator !=(const TCoords &a, const TCoords &o);
00101 
00102                 std::ostream TOPO_IMPEXP & operator<<( std::ostream& out, const TCoords &o );
00103 
00104                 struct TOPO_IMPEXP TEllipsoid
00105                 {
00106                         inline TEllipsoid() : sa( 6378137.0 ), sb( 6356752.314245 ), name("WGS84") {}
00107                         inline TEllipsoid( const double _sa, const double _sb, const string _name ) : sa(_sa), sb(_sb), name(_name) {}
00108 
00109                         double sa;              //!< largest semiaxis of the reference ellipsoid (in meters)
00110                         double sb;              //!< smallest semiaxis of the reference ellipsoid (in meters)
00111                         string name;    //!< the ellipsoid name
00112 
00113 
00114                         static inline TEllipsoid Ellipsoid_WGS84() {                                    return TEllipsoid( 6378137.000, 6356752.314245, "WGS84" ); }
00115                         static inline TEllipsoid Ellipsoid_WGS72() {                                    return TEllipsoid( 6378135.000, 6356750.519915, "WGS72"  ); }
00116                         static inline TEllipsoid Ellipsoid_WGS66() {                                    return TEllipsoid( 6378145.000, 6356759.769356, "WGS66"  ); }
00117                         static inline TEllipsoid Ellipsoid_Walbeck_1817() {                     return TEllipsoid( 6376896.000, 6355834.846700, "Walbeck_1817"  ); }
00118                         static inline TEllipsoid Ellipsoid_Sudamericano_1969() {                return TEllipsoid( 6378160.000, 6356774.720000, "Sudamericano_1969"  ); }
00119                         static inline TEllipsoid Ellipsoid_Nuevo_Internacional_1967() {return TEllipsoid( 6378157.500, 6356772.200000, "Nuevo_Internacional_1967"  ); }
00120                         static inline TEllipsoid Ellipsoid_Mercury_Modificado_1968() {  return TEllipsoid( 6378150.000, 6356768.337303, "Mercury_Modificado_1968" ); }
00121                         static inline TEllipsoid Ellipsoid_Mercury_1960() {                     return TEllipsoid( 6378166.000, 6356784.283666, "Mercury_1960"  ); }
00122                         static inline TEllipsoid Ellipsoid_Krasovsky_1940() {                   return TEllipsoid( 6378245.000, 6356863.018800, "Krasovsky_1940"  ); }
00123                         static inline TEllipsoid Ellipsoid_Internacional_1924() {               return TEllipsoid( 6378388.000, 6356911.946130, "Internacional_1924"  ); }
00124                         static inline TEllipsoid Ellipsoid_Internacional_1909() {               return TEllipsoid( 6378388.000, 6356911.946130, "Internacional_1909" ); }
00125                         static inline TEllipsoid Ellipsoid_Hough_1960() {                               return TEllipsoid( 6378270.000, 6356794.343479, "Hough_1960"  ); }
00126                         static inline TEllipsoid Ellipsoid_Helmert_1906() {                     return TEllipsoid( 6378200.000, 6356818.170000, "Helmert_1906"  ); }
00127                         static inline TEllipsoid Ellipsoid_Hayford_1909() {                     return TEllipsoid( 6378388.000, 6356911.946130, "Hayford_1909"  ); }
00128                         static inline TEllipsoid Ellipsoid_GRS80() {                                    return TEllipsoid( 6378137.000, 6356752.314140, "GRS80"  ); }
00129                         static inline TEllipsoid Ellipsoid_Fischer_1968() {                     return TEllipsoid( 6378150.000, 6356768.330000, "Fischer_1968"  ); }
00130                         static inline TEllipsoid Ellipsoid_Fischer_1960() {                     return TEllipsoid( 6378166.000, 6356784.280000, "Fischer_1960" ); }
00131                         static inline TEllipsoid Ellipsoid_Clarke_1880() {                              return TEllipsoid( 6378249.145, 6356514.869550, "Clarke_1880"  ); }
00132                         static inline TEllipsoid Ellipsoid_Clarke_1866() {                              return TEllipsoid( 6378206.400, 6356583.800000, "Clarke_1866"  ); }
00133                         static inline TEllipsoid Ellipsoid_Bessel_1841() {                              return TEllipsoid( 6377397.155, 6356078.962840, "Bessel_1841"  ); }
00134                         static inline TEllipsoid Ellipsoid_Airy_Modificado_1965() {     return TEllipsoid( 6377340.189, 6356034.447900, "Airy_Modificado_1965"  ); }
00135                         static inline TEllipsoid Ellipsoid_Airy_1830() {                                return TEllipsoid( 6377563.396, 6356256.910000, "Airy_1830"  ); }
00136                 };
00137 
00138 
00139                 typedef mrpt::math::TPoint3D TUTMCoords;
00140                 typedef mrpt::math::TPoint3D TGeocentricCoords;
00141 
00142                 /**  A set of geodetic coordinates: latitude, longitude and height, defined over a given geoid (typically, WGS84)  */
00143                 struct TOPO_IMPEXP TGeodeticCoords
00144                 {
00145                         TGeodeticCoords() : lat(0),lon(0),height(0) {}
00146                         TGeodeticCoords(const double _lat, const double _lon, const double _height) : lat(_lat),lon(_lon),height(_height) {}
00147 
00148                         inline bool isClear() const { return lat.getDecimalValue()==0 && lon.getDecimalValue()==0 && height==0; }
00149 
00150                         TCoords lat;    //!< Latitude (in degrees)
00151                         TCoords lon;    //!< Longitude (in degrees)
00152                         double  height; //!< Geodetic height (in meters)
00153 
00154                 };
00155 
00156                 bool TOPO_IMPEXP operator ==(const TGeodeticCoords &a, const TGeodeticCoords &o);
00157                 bool TOPO_IMPEXP operator !=(const TGeodeticCoords &a, const TGeodeticCoords &o);
00158 
00159                 /** Parameters for a topographic transfomation
00160                   * \sa TDatum10Params, transform7params
00161                   */
00162                 struct TOPO_IMPEXP TDatum7Params
00163                 {
00164                         double dX, dY, dZ;              //!< Deltas (X,Y,Z)
00165                         double Rx, Ry, Rz;              //!< Rotation components (in secs)
00166                         double dS;                              //!< Scale factor (in ppm) (Scale is 1+dS/1e6)
00167 
00168                         inline TDatum7Params(
00169                                 const double _dX, const double _dY, const double _dZ,
00170                                 const double _Rx, const double _Ry, const double _Rz,
00171                                 const double _dS ) :
00172                         dX(_dX), dY(_dY), dZ(_dZ)
00173                         {
00174                                 Rx = DEG2RAD(_Rx/60/60);
00175                                 Ry = DEG2RAD(_Ry/60/60);
00176                                 Rz = DEG2RAD(_Rz/60/60);
00177                                 dS = _dS*1e-6;
00178                         }
00179                 };
00180 
00181                 struct TOPO_IMPEXP TDatum7Params_TOPCON
00182                 {
00183                         double dX, dY, dZ;              //!< Deltas (X,Y,Z)
00184                         double m11, m12, m13, m21, m22, m23, m31, m32, m33;
00185                         double dS;                              //!< Scale factor (in ppm) (Scale is 1+dS/1e6)
00186 
00187                         inline TDatum7Params_TOPCON(
00188                                 const double _dX, const double _dY, const double _dZ,
00189                                 const double _m11, const double _m12, const double _m13,
00190                                 const double _m21, const double _m22, const double _m23,
00191                                 const double _m31, const double _m32, const double _m33,
00192                                 const double _dS ) :
00193                         dX(_dX), dY(_dY), dZ(_dZ), m11(_m11), m12(_m12), m13(_m13), m21(_m21), m22(_m22), m23(_m23), m31(_m31), m32(_m32), m33(_m33)
00194                         {
00195                                 dS = _dS*1e-6;
00196                         }
00197                 };
00198 
00199 
00200                 /** Parameters for a topographic transfomation
00201                   * \sa TDatum7Params, transform10params
00202                   */
00203                 struct TOPO_IMPEXP TDatum10Params
00204                 {
00205                         double dX, dY, dZ; //!< Deltas (X,Y,Z)
00206                         double Xp, Yp, Zp; //!< To be substracted to the input point
00207                         double Rx, Ry, Rz; //!< Rotation components
00208                         double dS; //!< Scale factor (Scale is 1+dS)
00209 
00210                         inline TDatum10Params(
00211                                 const double _dX, const double _dY, const double _dZ,
00212                                 const double _Xp, const double _Yp, const double _Zp,
00213                                 const double _Rx, const double _Ry, const double _Rz,
00214                                 const double _dS ) :
00215                         dX(_dX), dY(_dY), dZ(_dZ), Xp(_Xp), Yp(_Yp), Zp(_Zp)
00216                         {
00217                                 Rx = DEG2RAD(_Rx/60/60);
00218                                 Ry = DEG2RAD(_Ry/60/60);
00219                                 Rz = DEG2RAD(_Rz/60/60);
00220                                 dS = _dS*1e-6;
00221                         }
00222                 };
00223 
00224                 /** Parameters for a topographic transfomation
00225                   * \sa TDatumHelmert3D, transformHelmert2D
00226                   */
00227                 struct TOPO_IMPEXP TDatumHelmert2D
00228                 {
00229                         double dX, dY;          //!< Deltas [X,Y]
00230                         double alpha;           // The rotation about Z-axis (degrees)
00231                         double dS;                      // Scale factor (Scale is 1+dS)
00232                         double Xp, Yp;          // Coordinates of the rotation point
00233 
00234                         inline TDatumHelmert2D(
00235                                 const double _dX, const double _dY,
00236                                 const double _alpha, const double _dS,
00237                                 const double _Xp, const double _Yp ) :
00238                         dX(_dX), dY(_dY), Xp(_Xp), Yp(_Yp)
00239                         {
00240                                 alpha = DEG2RAD(_alpha);
00241                                 dS = _dS*1e-6;
00242                         }
00243                 };
00244 
00245                 struct TOPO_IMPEXP TDatumHelmert2D_TOPCON
00246                 {
00247                         double a,b,c,d;
00248 
00249                         inline TDatumHelmert2D_TOPCON(
00250                                 const double _a, const double _b,
00251                                 const double _c, const double _d ) :
00252                         a(_a), b(_b), c(_c), d(_d) {}
00253 
00254                 };
00255 
00256                 /** Parameters for a topographic transfomation
00257                   * \sa TDatumHelmert2D, transformHelmert3D
00258                   */
00259                 struct TOPO_IMPEXP TDatumHelmert3D
00260                 {
00261                         double dX, dY, dZ; //!< Deltas (X,Y,Z)
00262                         double Rx, Ry, Rz; //!< Rotation components
00263                         double dS; //!< Scale factor (Scale is 1+dS)
00264 
00265                         inline TDatumHelmert3D(
00266                                 const double _dX, const double _dY, const double _dZ,
00267                                 const double _Rx, const double _Ry, const double _Rz,
00268                                 const double _dS ) :
00269                         dX(_dX), dY(_dY), dZ(_dZ)
00270                         {
00271                                 Rx = DEG2RAD(_Rx/60/60);
00272                                 Ry = DEG2RAD(_Ry/60/60);
00273                                 Rz = DEG2RAD(_Rz/60/60);
00274                                 dS = _dS*1e-6;
00275                         }
00276                 };
00277 
00278                 /** Parameters for a topographic transfomation
00279                   * \sa TDatumHelmert2D, transformHelmert3D
00280                   */
00281                 struct TOPO_IMPEXP TDatumHelmert3D_TOPCON
00282                 {
00283                         double a,b,c,d,e,f,g;
00284 
00285                         inline TDatumHelmert3D_TOPCON(
00286                                 const double _a, const double _b, const double _c,
00287                                 const double _d, const double _e, const double _f, const double _g ) :
00288                         a(_a), b(_b), c(_c), d(_d), e(_e), f(_f), g(_g) { }
00289                 };
00290 
00291                 /** Parameters for a topographic transfomation
00292                   * \sa transform1D
00293                   */
00294                 struct TOPO_IMPEXP TDatum1DTransf
00295                 {
00296                         double dX, dY, DZ; //!< Deltas (X,Y,Z)
00297                         double dS; //!< Scale factor (Scale is 1+dS)
00298 
00299                         inline TDatum1DTransf(
00300                                 const double _dX, const double _dY, const double _DZ,
00301                                 const double _dS ) :
00302                         dX(_dX), dY(_dY), DZ(_DZ)
00303                         {
00304                                 dS = _dS*1e-6;
00305                         }
00306                 };
00307 
00308                 /** Parameters for a topographic transfomation
00309                   * \sa transform1D
00310                   */
00311                 struct TOPO_IMPEXP TDatumTransfInterpolation
00312                 {
00313                         double dX, dY;          //!< Deltas (X,Y,Z)
00314                         double dSx, dSy;        //!< Scale factor in X and Y
00315                         double beta;            //!< Distortion angle
00316 
00317                         inline TDatumTransfInterpolation(
00318                                 const double _dX, const double _dY,
00319                                 const double _dSx, const double _dSy, const double _beta ) :
00320                         dX(_dX), dY(_dY)
00321                         {
00322                                 dSx = _dSx*1e-6;
00323                                 dSy = _dSy*1e-6;
00324                                 beta = DEG2RAD(_beta/60/60);
00325                         }
00326                 };
00327 
00328                 /** @}
00329             ======================================================================= */
00330 
00331         } // End of namespace
00332 
00333 } // End of namespace
00334 
00335 #endif



Page generated by Doxygen 1.7.3 for MRPT 0.9.4 SVN: at Sat Mar 26 06:40:17 UTC 2011