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