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://www.mrpt.org/                                |
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                 /** \addtogroup mrpt_topography_grp
00044                   *  @{ */
00045 
00046         /** @name Data structures
00047            @{ */
00048 
00049                 /** 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.
00050                   */
00051                 struct TOPO_IMPEXP TCoords
00052                 {
00053                         // Only keep one of the possible representations:
00054                         double decimal_value; //!< Also obtained directly through the double(void) operator using a TCoords anywhere were a double is expected.
00055 
00056                         inline TCoords( const int _deg, const int _min, const double _sec ) { setDegMinSec(_deg,_min,_sec); }
00057                         inline TCoords( const double dec ) { setFromDecimal(dec); }
00058                         inline TCoords() { setFromDecimal(0); }
00059 
00060                         /** Automatic conversion to a double value (read-only) */
00061                         inline operator double(void) const { return decimal_value; }
00062 
00063                         /** Automatic conversion to a double value (read-only) */
00064                         inline operator double& (void) { return decimal_value; }
00065 
00066                         /** Set from a decimal value (XX.YYYYY) in degrees. */
00067                         inline void setFromDecimal( const double dec ) { decimal_value = dec; }
00068 
00069                         /** Get the decimal value (XX.YYYYY), in degrees - you can also use the automatic conversion between TCoords and a double.  */
00070                         inline double getDecimalValue() const { return decimal_value; }
00071 
00072                         /** Return the Deg Min' Sec'' representation of this value. */
00073                         inline void getDegMinSec( int &degrees, int &minutes, double &seconds) const
00074                         {
00075                                 double aux = std::abs(decimal_value);
00076                                 degrees = (int)aux;
00077                                 minutes = (int)((aux - degrees)*60.0f);
00078                                 seconds = ((aux - degrees)*60.0f - minutes)*60.0f;
00079                                 if( decimal_value<0 ) degrees = -degrees;
00080                         }
00081 
00082                         /** Set the coordinate from its Deg Min' Deg'' parts. */
00083                         inline void setDegMinSec(const int degrees, const int minutes, const double seconds)
00084                         {
00085                                 decimal_value = std::abs(degrees)+minutes/60.0+seconds/3600.0;
00086                                 if(degrees<0)  decimal_value  = - decimal_value;
00087                         }
00088 
00089                         /** Return a string in the format "DEGdeg MIN' SEC''" */
00090                         inline std::string getAsString() const
00091                         {
00092                                 int deg,min;
00093                                 double sec;
00094                                 getDegMinSec( deg,min,sec);
00095                                 return mrpt::format("%ddeg %d' %.010f''",deg,min,sec );
00096                         }
00097 
00098                 };
00099 
00100                 bool TOPO_IMPEXP operator ==(const TCoords &a, const TCoords &o);
00101                 bool TOPO_IMPEXP operator !=(const TCoords &a, const TCoords &o);
00102 
00103                 std::ostream TOPO_IMPEXP & operator<<( std::ostream& out, const TCoords &o );
00104 
00105                 struct TOPO_IMPEXP TEllipsoid
00106                 {
00107                         inline TEllipsoid() : sa( 6378137.0 ), sb( 6356752.314245 ), name("WGS84") {}
00108                         inline TEllipsoid( const double _sa, const double _sb, const string _name ) : sa(_sa), sb(_sb), name(_name) {}
00109 
00110                         double sa;              //!< largest semiaxis of the reference ellipsoid (in meters)
00111                         double sb;              //!< smallest semiaxis of the reference ellipsoid (in meters)
00112                         string name;    //!< the ellipsoid name
00113 
00114 
00115                         static inline TEllipsoid Ellipsoid_WGS84() {                                    return TEllipsoid( 6378137.000, 6356752.314245, "WGS84" ); }
00116                         static inline TEllipsoid Ellipsoid_WGS72() {                                    return TEllipsoid( 6378135.000, 6356750.519915, "WGS72"  ); }
00117                         static inline TEllipsoid Ellipsoid_WGS66() {                                    return TEllipsoid( 6378145.000, 6356759.769356, "WGS66"  ); }
00118                         static inline TEllipsoid Ellipsoid_Walbeck_1817() {                     return TEllipsoid( 6376896.000, 6355834.846700, "Walbeck_1817"  ); }
00119                         static inline TEllipsoid Ellipsoid_Sudamericano_1969() {                return TEllipsoid( 6378160.000, 6356774.720000, "Sudamericano_1969"  ); }
00120                         static inline TEllipsoid Ellipsoid_Nuevo_Internacional_1967() {return TEllipsoid( 6378157.500, 6356772.200000, "Nuevo_Internacional_1967"  ); }
00121                         static inline TEllipsoid Ellipsoid_Mercury_Modificado_1968() {  return TEllipsoid( 6378150.000, 6356768.337303, "Mercury_Modificado_1968" ); }
00122                         static inline TEllipsoid Ellipsoid_Mercury_1960() {                     return TEllipsoid( 6378166.000, 6356784.283666, "Mercury_1960"  ); }
00123                         static inline TEllipsoid Ellipsoid_Krasovsky_1940() {                   return TEllipsoid( 6378245.000, 6356863.018800, "Krasovsky_1940"  ); }
00124                         static inline TEllipsoid Ellipsoid_Internacional_1924() {               return TEllipsoid( 6378388.000, 6356911.946130, "Internacional_1924"  ); }
00125                         static inline TEllipsoid Ellipsoid_Internacional_1909() {               return TEllipsoid( 6378388.000, 6356911.946130, "Internacional_1909" ); }
00126                         static inline TEllipsoid Ellipsoid_Hough_1960() {                               return TEllipsoid( 6378270.000, 6356794.343479, "Hough_1960"  ); }
00127                         static inline TEllipsoid Ellipsoid_Helmert_1906() {                     return TEllipsoid( 6378200.000, 6356818.170000, "Helmert_1906"  ); }
00128                         static inline TEllipsoid Ellipsoid_Hayford_1909() {                     return TEllipsoid( 6378388.000, 6356911.946130, "Hayford_1909"  ); }
00129                         static inline TEllipsoid Ellipsoid_GRS80() {                                    return TEllipsoid( 6378137.000, 6356752.314140, "GRS80"  ); }
00130                         static inline TEllipsoid Ellipsoid_Fischer_1968() {                     return TEllipsoid( 6378150.000, 6356768.330000, "Fischer_1968"  ); }
00131                         static inline TEllipsoid Ellipsoid_Fischer_1960() {                     return TEllipsoid( 6378166.000, 6356784.280000, "Fischer_1960" ); }
00132                         static inline TEllipsoid Ellipsoid_Clarke_1880() {                              return TEllipsoid( 6378249.145, 6356514.869550, "Clarke_1880"  ); }
00133                         static inline TEllipsoid Ellipsoid_Clarke_1866() {                              return TEllipsoid( 6378206.400, 6356583.800000, "Clarke_1866"  ); }
00134                         static inline TEllipsoid Ellipsoid_Bessel_1841() {                              return TEllipsoid( 6377397.155, 6356078.962840, "Bessel_1841"  ); }
00135                         static inline TEllipsoid Ellipsoid_Airy_Modificado_1965() {     return TEllipsoid( 6377340.189, 6356034.447900, "Airy_Modificado_1965"  ); }
00136                         static inline TEllipsoid Ellipsoid_Airy_1830() {                                return TEllipsoid( 6377563.396, 6356256.910000, "Airy_1830"  ); }
00137                 };
00138 
00139 
00140                 typedef mrpt::math::TPoint3D TUTMCoords;
00141                 typedef mrpt::math::TPoint3D TGeocentricCoords;
00142 
00143                 /**  A set of geodetic coordinates: latitude, longitude and height, defined over a given geoid (typically, WGS84)  */
00144                 struct TOPO_IMPEXP TGeodeticCoords
00145                 {
00146                         TGeodeticCoords() : lat(0),lon(0),height(0) {}
00147                         TGeodeticCoords(const double _lat, const double _lon, const double _height) : lat(_lat),lon(_lon),height(_height) {}
00148 
00149                         inline bool isClear() const { return lat.getDecimalValue()==0 && lon.getDecimalValue()==0 && height==0; }
00150 
00151                         TCoords lat;    //!< Latitude (in degrees)
00152                         TCoords lon;    //!< Longitude (in degrees)
00153                         double  height; //!< Geodetic height (in meters)
00154 
00155                 };
00156 
00157                 bool TOPO_IMPEXP operator ==(const TGeodeticCoords &a, const TGeodeticCoords &o);
00158                 bool TOPO_IMPEXP operator !=(const TGeodeticCoords &a, const TGeodeticCoords &o);
00159 
00160                 /** Parameters for a topographic transfomation
00161                   * \sa TDatum10Params, transform7params
00162                   */
00163                 struct TOPO_IMPEXP TDatum7Params
00164                 {
00165                         double dX, dY, dZ;              //!< Deltas (X,Y,Z)
00166                         double Rx, Ry, Rz;              //!< Rotation components (in secs)
00167                         double dS;                              //!< Scale factor (in ppm) (Scale is 1+dS/1e6)
00168 
00169                         inline TDatum7Params(
00170                                 const double _dX, const double _dY, const double _dZ,
00171                                 const double _Rx, const double _Ry, const double _Rz,
00172                                 const double _dS ) :
00173                         dX(_dX), dY(_dY), dZ(_dZ)
00174                         {
00175                                 Rx = DEG2RAD(_Rx/60/60);
00176                                 Ry = DEG2RAD(_Ry/60/60);
00177                                 Rz = DEG2RAD(_Rz/60/60);
00178                                 dS = _dS*1e-6;
00179                         }
00180                 };
00181 
00182                 struct TOPO_IMPEXP TDatum7Params_TOPCON
00183                 {
00184                         double dX, dY, dZ;              //!< Deltas (X,Y,Z)
00185                         double m11, m12, m13, m21, m22, m23, m31, m32, m33;
00186                         double dS;                              //!< Scale factor (in ppm) (Scale is 1+dS/1e6)
00187 
00188                         inline TDatum7Params_TOPCON(
00189                                 const double _dX, const double _dY, const double _dZ,
00190                                 const double _m11, const double _m12, const double _m13,
00191                                 const double _m21, const double _m22, const double _m23,
00192                                 const double _m31, const double _m32, const double _m33,
00193                                 const double _dS ) :
00194                         dX(_dX), dY(_dY), dZ(_dZ), m11(_m11), m12(_m12), m13(_m13), m21(_m21), m22(_m22), m23(_m23), m31(_m31), m32(_m32), m33(_m33)
00195                         {
00196                                 dS = _dS*1e-6;
00197                         }
00198                 };
00199 
00200 
00201                 /** Parameters for a topographic transfomation
00202                   * \sa TDatum7Params, transform10params
00203                   */
00204                 struct TOPO_IMPEXP TDatum10Params
00205                 {
00206                         double dX, dY, dZ; //!< Deltas (X,Y,Z)
00207                         double Xp, Yp, Zp; //!< To be substracted to the input point
00208                         double Rx, Ry, Rz; //!< Rotation components
00209                         double dS; //!< Scale factor (Scale is 1+dS)
00210 
00211                         inline TDatum10Params(
00212                                 const double _dX, const double _dY, const double _dZ,
00213                                 const double _Xp, const double _Yp, const double _Zp,
00214                                 const double _Rx, const double _Ry, const double _Rz,
00215                                 const double _dS ) :
00216                         dX(_dX), dY(_dY), dZ(_dZ), Xp(_Xp), Yp(_Yp), Zp(_Zp)
00217                         {
00218                                 Rx = DEG2RAD(_Rx/60/60);
00219                                 Ry = DEG2RAD(_Ry/60/60);
00220                                 Rz = DEG2RAD(_Rz/60/60);
00221                                 dS = _dS*1e-6;
00222                         }
00223                 };
00224 
00225                 /** Parameters for a topographic transfomation
00226                   * \sa TDatumHelmert3D, transformHelmert2D
00227                   */
00228                 struct TOPO_IMPEXP TDatumHelmert2D
00229                 {
00230                         double dX, dY;          //!< Deltas [X,Y]
00231                         double alpha;           // The rotation about Z-axis (degrees)
00232                         double dS;                      // Scale factor (Scale is 1+dS)
00233                         double Xp, Yp;          // Coordinates of the rotation point
00234 
00235                         inline TDatumHelmert2D(
00236                                 const double _dX, const double _dY,
00237                                 const double _alpha, const double _dS,
00238                                 const double _Xp, const double _Yp ) :
00239                         dX(_dX), dY(_dY), Xp(_Xp), Yp(_Yp)
00240                         {
00241                                 alpha = DEG2RAD(_alpha);
00242                                 dS = _dS*1e-6;
00243                         }
00244                 };
00245 
00246                 struct TOPO_IMPEXP TDatumHelmert2D_TOPCON
00247                 {
00248                         double a,b,c,d;
00249 
00250                         inline TDatumHelmert2D_TOPCON(
00251                                 const double _a, const double _b,
00252                                 const double _c, const double _d ) :
00253                         a(_a), b(_b), c(_c), d(_d) {}
00254 
00255                 };
00256 
00257                 /** Parameters for a topographic transfomation
00258                   * \sa TDatumHelmert2D, transformHelmert3D
00259                   */
00260                 struct TOPO_IMPEXP TDatumHelmert3D
00261                 {
00262                         double dX, dY, dZ; //!< Deltas (X,Y,Z)
00263                         double Rx, Ry, Rz; //!< Rotation components
00264                         double dS; //!< Scale factor (Scale is 1+dS)
00265 
00266                         inline TDatumHelmert3D(
00267                                 const double _dX, const double _dY, const double _dZ,
00268                                 const double _Rx, const double _Ry, const double _Rz,
00269                                 const double _dS ) :
00270                         dX(_dX), dY(_dY), dZ(_dZ)
00271                         {
00272                                 Rx = DEG2RAD(_Rx/60/60);
00273                                 Ry = DEG2RAD(_Ry/60/60);
00274                                 Rz = DEG2RAD(_Rz/60/60);
00275                                 dS = _dS*1e-6;
00276                         }
00277                 };
00278 
00279                 /** Parameters for a topographic transfomation
00280                   * \sa TDatumHelmert2D, transformHelmert3D
00281                   */
00282                 struct TOPO_IMPEXP TDatumHelmert3D_TOPCON
00283                 {
00284                         double a,b,c,d,e,f,g;
00285 
00286                         inline TDatumHelmert3D_TOPCON(
00287                                 const double _a, const double _b, const double _c,
00288                                 const double _d, const double _e, const double _f, const double _g ) :
00289                         a(_a), b(_b), c(_c), d(_d), e(_e), f(_f), g(_g) { }
00290                 };
00291 
00292                 /** Parameters for a topographic transfomation
00293                   * \sa transform1D
00294                   */
00295                 struct TOPO_IMPEXP TDatum1DTransf
00296                 {
00297                         double dX, dY, DZ; //!< Deltas (X,Y,Z)
00298                         double dS; //!< Scale factor (Scale is 1+dS)
00299 
00300                         inline TDatum1DTransf(
00301                                 const double _dX, const double _dY, const double _DZ,
00302                                 const double _dS ) :
00303                         dX(_dX), dY(_dY), DZ(_DZ)
00304                         {
00305                                 dS = _dS*1e-6;
00306                         }
00307                 };
00308 
00309                 /** Parameters for a topographic transfomation
00310                   * \sa transform1D
00311                   */
00312                 struct TOPO_IMPEXP TDatumTransfInterpolation
00313                 {
00314                         double dX, dY;          //!< Deltas (X,Y,Z)
00315                         double dSx, dSy;        //!< Scale factor in X and Y
00316                         double beta;            //!< Distortion angle
00317 
00318                         inline TDatumTransfInterpolation(
00319                                 const double _dX, const double _dY,
00320                                 const double _dSx, const double _dSy, const double _beta ) :
00321                         dX(_dX), dY(_dY)
00322                         {
00323                                 dSx = _dSx*1e-6;
00324                                 dSy = _dSy*1e-6;
00325                                 beta = DEG2RAD(_beta/60/60);
00326                         }
00327                 };
00328 
00329                 /** @} */
00330         
00331                 /** @} */ // end of grouping
00332                 
00333         } // End of namespace
00334 
00335 } // End of namespace
00336 
00337 #endif



Page generated by Doxygen 1.7.5 for MRPT 0.9.5 SVN: at Thu Oct 13 21:25:36 UTC 2011