[89] | 1 | // %pacpus:license{
|
---|
| 2 | // This file is part of the PACPUS framework distributed under the
|
---|
| 3 | // CECILL-C License, Version 1.0.
|
---|
| 4 | // %}
|
---|
| 5 | /// @file
|
---|
[162] | 6 | /// @author Jean Laneurit <firstname.surname@utc.fr>
|
---|
| 7 | /// @date April, 2010
|
---|
[311] | 8 | /// @version $Id: geodesie.h 116 2013-06-25 11:44:25Z kurdejma $
|
---|
[89] | 9 | /// @copyright Copyright (c) UTC/CNRS Heudiasyc 2006 - 2013. All rights reserved.
|
---|
| 10 | /// @brief Brief description.
|
---|
| 11 | ///
|
---|
| 12 | /// Detailed description.
|
---|
| 13 |
|
---|
| 14 | #ifndef GEODESIE_H
|
---|
| 15 | #define GEODESIE_H
|
---|
| 16 |
|
---|
| 17 | #include <cmath>
|
---|
| 18 | #include <iostream>
|
---|
| 19 | #include <vector>
|
---|
| 20 |
|
---|
[318] | 21 | #include "Pacpus\PacpusTools\PacpusToolsConfig.h"
|
---|
[99] | 22 |
|
---|
[126] | 23 |
|
---|
[318] | 24 | class QMatrix4x4;
|
---|
| 25 | class QVector3D;
|
---|
| 26 |
|
---|
[89] | 27 | namespace Geodesie {
|
---|
| 28 |
|
---|
| 29 | #ifndef M_PI
|
---|
| 30 | # define M_PI 3.14159265358979323846
|
---|
| 31 | #endif
|
---|
| 32 | #ifndef M_PI_2
|
---|
| 33 | # define M_PI_2 1.57079632679489661923
|
---|
| 34 | #endif
|
---|
| 35 | #ifndef M_PI_4
|
---|
| 36 | # define M_PI_4 0.78539816339744830962
|
---|
| 37 | #endif
|
---|
| 38 |
|
---|
| 39 | /// 9x9 matrix ???
|
---|
| 40 | ///
|
---|
| 41 | /// @todo Documentation
|
---|
| 42 | /// @todo Rewrite!
|
---|
[162] | 43 | struct PACPUSTOOLS_API Matrice
|
---|
[89] | 44 | {
|
---|
| 45 | /// Copy ctor
|
---|
| 46 | Matrice(const Matrice & A);
|
---|
| 47 | /// Ctor
|
---|
| 48 | Matrice();
|
---|
| 49 | /// @todo Documentation
|
---|
| 50 | void Apply(double v0, double v1, double v2, double & Mv0, double & Mv1, double & Mv2);
|
---|
| 51 |
|
---|
| 52 | /// @todo Documentation
|
---|
| 53 | double c0_l0;
|
---|
| 54 | /// @todo Documentation
|
---|
| 55 | double c1_l0;
|
---|
| 56 | /// @todo Documentation
|
---|
| 57 | double c2_l0;
|
---|
| 58 |
|
---|
| 59 | /// @todo Documentation
|
---|
| 60 | double c0_l1;
|
---|
| 61 | /// @todo Documentation
|
---|
| 62 | double c1_l1;
|
---|
| 63 | /// @todo Documentation
|
---|
| 64 | double c2_l1;
|
---|
| 65 |
|
---|
| 66 | /// @todo Documentation
|
---|
| 67 | double c0_l2;
|
---|
| 68 | /// @todo Documentation
|
---|
| 69 | double c1_l2;
|
---|
| 70 | /// @todo Documentation
|
---|
| 71 | double c2_l2;
|
---|
| 72 | };
|
---|
| 73 |
|
---|
[311] | 74 | Matrice PACPUSTOOLS_API TransMat(const Matrice A);
|
---|
[89] | 75 |
|
---|
[311] | 76 | Matrice PACPUSTOOLS_API ProdMat(const Matrice A,const Matrice B);
|
---|
| 77 | void Write(const Matrice A,std::ostream& out);
|
---|
| 78 |
|
---|
[89] | 79 | ////////////////////////////////////////////////////////////////////////
|
---|
| 80 | /// @todo Documentation
|
---|
[162] | 81 | class PACPUSTOOLS_API Raf98
|
---|
[89] | 82 | {
|
---|
| 83 | public:
|
---|
| 84 | /// Ctor of Raf98 class.
|
---|
| 85 | Raf98() {}
|
---|
| 86 | /// Dtor of Raf98 class.
|
---|
| 87 | ~Raf98();
|
---|
| 88 |
|
---|
| 89 | /// @todo Documentation
|
---|
| 90 | /// @param s filepath
|
---|
| 91 | bool Load(const std::string & s);
|
---|
| 92 |
|
---|
| 93 | /// @todo Documentation
|
---|
| 94 | /// @param longitude [degrees]
|
---|
| 95 | /// @param latitude [degrees]
|
---|
| 96 | /// @param Hwgs84 Output: interpolated altitude using WGS84 geoid model [meters]
|
---|
[311] | 97 | bool Interpol(double longitudeDegrees, double latitudeDegrees, double * heightMetersWgs84) const;
|
---|
[89] | 98 |
|
---|
| 99 | private:
|
---|
| 100 | std::vector<double> m_dvalues;
|
---|
| 101 | double LitGrille(unsigned int c,unsigned int l) const;
|
---|
| 102 | };
|
---|
| 103 |
|
---|
| 104 | ////////////////////////////////////////////////////////////////////////
|
---|
| 105 |
|
---|
| 106 | ////////////////////////////////////////////////////////////////////////
|
---|
[311] | 107 | inline double PACPUSTOOLS_API Deg2Rad(double deg) {return deg*M_PI/180.0;}
|
---|
| 108 | inline double PACPUSTOOLS_API Rad2Deg(double rad) {return rad*180.0/M_PI;}
|
---|
[89] | 109 | ////////////////////////////////////////////////////////////////////////
|
---|
| 110 |
|
---|
| 111 | const double a_Lambert93=6378137;
|
---|
| 112 | const double f_Lambert93=1 / 298.257222101;
|
---|
| 113 | const double e_Lambert93=sqrt(f_Lambert93*(2-f_Lambert93));
|
---|
| 114 | const double lambda0_Lambert93=Deg2Rad(3.0);//degres
|
---|
| 115 | const double phi0_Lambert93=Deg2Rad(46.5);
|
---|
| 116 | const double phi1_Lambert93=Deg2Rad(44.0);
|
---|
| 117 | const double phi2_Lambert93=Deg2Rad(49.0);//degres
|
---|
| 118 | const double X0_Lambert93=700000;//
|
---|
| 119 | const double Y0_Lambert93=6600000;//
|
---|
| 120 | const double n_Lambert93 = 0.7256077650;
|
---|
| 121 | const double c_Lambert93 = 11754255.426;
|
---|
| 122 | const double xs_Lambert93 = 700000;
|
---|
| 123 | const double ys_Lambert93 = 12655612.050;
|
---|
| 124 |
|
---|
| 125 | const double GRS_a = 6378137;
|
---|
| 126 | const double GRS_f = 1/298.257222101;
|
---|
| 127 | const double GRS_b = GRS_a*(1-GRS_f);
|
---|
| 128 | const double GRS_e = sqrt((pow(GRS_a,2) - pow(GRS_b,2)) / pow(GRS_a,2));
|
---|
| 129 |
|
---|
| 130 | ////////////////////////////////////////////////////////////////////////
|
---|
[311] | 131 | void PACPUSTOOLS_API Geographique_2_Lambert93(const Raf98& raf98,double lambda,double phi,double he,Matrice in,double& E,double& N,double& h,Matrice& out);
|
---|
| 132 | void PACPUSTOOLS_API Geographique_2_Lambert93(const Raf98& raf98,double lambda,double phi,double he,double& E,double& N,double& h);
|
---|
| 133 | void PACPUSTOOLS_API Lambert93_2_Geographique(const Raf98& raf98,double E,double N,double h,double& lambda,double& phi,double& he);
|
---|
| 134 | void PACPUSTOOLS_API Lambert93_2_Geographique(const Raf98& raf98,double E,double N,double h,Matrice in,double& lambda,double& phi,double& he,Matrice& out);
|
---|
| 135 | /// Convert from geographique to ECEF.
|
---|
| 136 | /// @param[in] longitude Longitude in radian.
|
---|
| 137 | /// @param[in] latitude Latitude in radian.
|
---|
| 138 | /// @param[in] he Height in meter.
|
---|
| 139 | void PACPUSTOOLS_API Geographique_2_ECEF(double longitude, double latitude, double he, double& x, double& y, double& z);
|
---|
| 140 | /// Convert from ECEF two ENU.
|
---|
| 141 | /// @param[in] lon0 Longitude of the origin in radian.
|
---|
| 142 | /// @param[in] lat0 Latitude of the origin in radian.
|
---|
| 143 | /// @param[in] he0 Height of the origin in radian.
|
---|
| 144 | void PACPUSTOOLS_API ECEF_2_ENU(double x,double y,double z,double& e,double& n,double& u,double lon0,double lat0,double he0);
|
---|
[318] | 145 |
|
---|
| 146 | QMatrix4x4 yprenuToMatrix(QVector3D angle, QVector3D position);
|
---|
[89] | 147 | ////////////////////////////////////////////////////////////////////////
|
---|
| 148 |
|
---|
| 149 | ///ALGO0001
|
---|
| 150 | /// @todo Rename
|
---|
[311] | 151 | double PACPUSTOOLS_API LatitueIsometrique(double latitude,double e);
|
---|
[89] | 152 | ///ALGO0002
|
---|
| 153 | /// @todo Rename
|
---|
[311] | 154 | double PACPUSTOOLS_API LatitueIsometrique2Lat(double latitude_iso,double e,double epsilon);
|
---|
[89] | 155 |
|
---|
| 156 | ///ALGO0003
|
---|
[311] | 157 | void PACPUSTOOLS_API Geo2ProjLambert(
|
---|
[89] | 158 | double lambda,double phi,
|
---|
| 159 | double n, double c,double e,
|
---|
| 160 | double lambdac,double xs,double ys,
|
---|
| 161 | double& X,double& Y);
|
---|
| 162 | ///ALGO0004
|
---|
[311] | 163 | void PACPUSTOOLS_API Proj2GeoLambert(
|
---|
[89] | 164 | double X,double Y,
|
---|
| 165 | double n, double c,double e,
|
---|
| 166 | double lambdac,double xs,double ys,
|
---|
| 167 | double epsilon,
|
---|
| 168 | double& lambda,double& phi);
|
---|
| 169 |
|
---|
[311] | 170 | double PACPUSTOOLS_API ConvMerApp(double longitude);
|
---|
[89] | 171 |
|
---|
[311] | 172 | /// Converts Cartesian (x, y) coordinates to polar coordinates (r, theta)
|
---|
[89] | 173 | template <typename _T1, typename _T2>
|
---|
| 174 | void cartesianToPolar(const _T1 x, const _T1 y, _T2 & r, _T2 & theta) {
|
---|
| 175 | r = std::sqrt(x*x + y*y);
|
---|
| 176 | theta = std::atan2(x, y);
|
---|
| 177 | }
|
---|
| 178 |
|
---|
[311] | 179 | /// Converts polar coordinates (r, theta) to Cartesian (x, y) coordinates
|
---|
[89] | 180 | template <typename _T1, typename _T2>
|
---|
| 181 | void polarToCartesian(const _T1 r, const _T1 theta, _T2 & x, _T2 & y) {
|
---|
| 182 | x = r * std::cos(theta);
|
---|
| 183 | y = r * std::sin(theta);
|
---|
| 184 | }
|
---|
| 185 |
|
---|
[311] | 186 | /// Converts Cartesian (x, y, z) coordinates to spherical coordinates (r, theta, phi)
|
---|
| 187 | /// Angles expressed in radians.
|
---|
[89] | 188 | template <typename _T1, typename _T2>
|
---|
| 189 | void cartesianToSpherical(const _T1 x, const _T1 y, const _T1 z, _T2 & r, _T2 & theta, _T2 & phi) {
|
---|
| 190 | r = std::sqrt(x*x + y*y + z*z);
|
---|
| 191 | theta = std::acos(z / r);
|
---|
| 192 | phi = std::atan2(y, x);
|
---|
| 193 | }
|
---|
| 194 |
|
---|
[311] | 195 | /// Converts spherical coordinates (r, theta, phi) to Cartesian (x, y, z) coordinates.
|
---|
| 196 | /// Angles expressed in radians.
|
---|
[89] | 197 | template <typename _T1, typename _T2>
|
---|
| 198 | void sphericalToCartesian(const _T1 r, const _T1 theta, const _T1 phi, _T2 & x, _T2 & y, _T2 & z) {
|
---|
| 199 | x = r * std::sin(theta) * std::cos(phi);
|
---|
| 200 | y = r * std::sin(theta) * std::sin(phi);
|
---|
| 201 | z = r * std::cos(theta);
|
---|
| 202 | }
|
---|
| 203 |
|
---|
| 204 | } // namespace Geodesie
|
---|
| 205 |
|
---|
| 206 | #endif // GEODESIE_H
|
---|