[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
|
---|
[208] | 6 | /// @author Marek Kurdej <firstname.surname@utc.fr>
|
---|
[162] | 7 | /// @author Jean Laneurit <firstname.surname@utc.fr>
|
---|
| 8 | /// @date April, 2010
|
---|
[89] | 9 | /// @version $Id: geodesie.h 75 2013-01-10 17:04:19Z kurdejma $
|
---|
| 10 | /// @copyright Copyright (c) UTC/CNRS Heudiasyc 2006 - 2013. All rights reserved.
|
---|
| 11 | /// @brief Brief description.
|
---|
| 12 | ///
|
---|
| 13 | /// Detailed description.
|
---|
| 14 |
|
---|
| 15 | #ifndef GEODESIE_H
|
---|
| 16 | #define GEODESIE_H
|
---|
| 17 |
|
---|
[224] | 18 | #ifdef _MSC_VER
|
---|
| 19 | # pragma warning(push)
|
---|
| 20 | # pragma warning(disable: 4251 4275)
|
---|
| 21 | #endif // _MSC_VER
|
---|
| 22 |
|
---|
[198] | 23 | #include "PacpusToolsConfig.h"
|
---|
| 24 |
|
---|
[299] | 25 | #include <Pacpus/kernel/deprecated.h>
|
---|
[210] | 26 |
|
---|
[208] | 27 | #include <boost/math/constants/constants.hpp>
|
---|
[213] | 28 | #include <boost/operators.hpp>
|
---|
[89] | 29 | #include <cmath>
|
---|
| 30 | #include <iostream>
|
---|
| 31 | #include <vector>
|
---|
| 32 |
|
---|
[212] | 33 | class QMatrix4x4;
|
---|
| 34 | class QVector3D;
|
---|
[99] | 35 |
|
---|
[209] | 36 | namespace Geodesy
|
---|
[208] | 37 | {
|
---|
[89] | 38 |
|
---|
[211] | 39 | /// 3x3 matrix ???
|
---|
[89] | 40 | ///
|
---|
| 41 | /// @todo Documentation
|
---|
| 42 | /// @todo Rewrite!
|
---|
[162] | 43 | struct PACPUSTOOLS_API Matrice
|
---|
[213] | 44 | : boost::multipliable<Matrice>
|
---|
[89] | 45 | {
|
---|
| 46 | /// Copy ctor
|
---|
[210] | 47 | Matrice(Matrice const& A);
|
---|
[89] | 48 | /// Ctor
|
---|
| 49 | Matrice();
|
---|
[213] | 50 | /// Ctor
|
---|
| 51 | Matrice(
|
---|
| 52 | double l0c0, double l0c1, double l0c2,
|
---|
| 53 | double l1c0, double l1c1, double l1c2,
|
---|
| 54 | double l2c0, double l2c1, double l2c2
|
---|
| 55 | );
|
---|
| 56 |
|
---|
[89] | 57 | /// @todo Documentation
|
---|
[210] | 58 | void Apply(double v0, double v1, double v2, double& Mv0, double& Mv1, double& Mv2);
|
---|
[89] | 59 |
|
---|
[213] | 60 | Matrice& operator*=(Matrice const& other);
|
---|
| 61 |
|
---|
[89] | 62 | /// @todo Documentation
|
---|
| 63 | double c0_l0;
|
---|
| 64 | /// @todo Documentation
|
---|
| 65 | double c1_l0;
|
---|
| 66 | /// @todo Documentation
|
---|
| 67 | double c2_l0;
|
---|
| 68 |
|
---|
| 69 | /// @todo Documentation
|
---|
| 70 | double c0_l1;
|
---|
| 71 | /// @todo Documentation
|
---|
| 72 | double c1_l1;
|
---|
| 73 | /// @todo Documentation
|
---|
| 74 | double c2_l1;
|
---|
| 75 |
|
---|
| 76 | /// @todo Documentation
|
---|
| 77 | double c0_l2;
|
---|
| 78 | /// @todo Documentation
|
---|
| 79 | double c1_l2;
|
---|
| 80 | /// @todo Documentation
|
---|
| 81 | double c2_l2;
|
---|
| 82 | };
|
---|
| 83 |
|
---|
[210] | 84 | PACPUSTOOLS_API Matrice TransMat(Matrice const& A);
|
---|
[213] | 85 | PACPUSTOOLS_API PACPUS_DEPRECATED_MSG(Matrice ProdMat(Matrice const& A, Matrice const& B), "use Matrice::operator *");
|
---|
[210] | 86 | PACPUSTOOLS_API PACPUS_DEPRECATED_MSG(void Write(Matrice const& A, std::ostream& out), "use operator<<");
|
---|
| 87 | PACPUSTOOLS_API std::ostream& operator<<(std::ostream& os, Matrice const& A);
|
---|
[89] | 88 |
|
---|
| 89 | ////////////////////////////////////////////////////////////////////////
|
---|
| 90 | /// @todo Documentation
|
---|
[162] | 91 | class PACPUSTOOLS_API Raf98
|
---|
[89] | 92 | {
|
---|
| 93 | public:
|
---|
| 94 | /// Ctor of Raf98 class.
|
---|
[210] | 95 | Raf98();
|
---|
| 96 |
|
---|
[89] | 97 | /// Dtor of Raf98 class.
|
---|
| 98 | ~Raf98();
|
---|
[210] | 99 |
|
---|
[89] | 100 | /// @todo Documentation
|
---|
[211] | 101 | /// @param filepath Path to the input file with RAF98 data.
|
---|
| 102 | bool Load(const std::string& filepath);
|
---|
[210] | 103 |
|
---|
[89] | 104 | /// @todo Documentation
|
---|
| 105 | /// @param longitude [degrees]
|
---|
| 106 | /// @param latitude [degrees]
|
---|
| 107 | /// @param Hwgs84 Output: interpolated altitude using WGS84 geoid model [meters]
|
---|
[210] | 108 | bool Interpol(double longitude /*deg*/, double latitude /*deg*/, double* Hwgs84) const;
|
---|
| 109 |
|
---|
[89] | 110 | private:
|
---|
| 111 | std::vector<double> m_dvalues;
|
---|
[210] | 112 | double LitGrille(unsigned int c, unsigned int l) const;
|
---|
[89] | 113 | };
|
---|
| 114 |
|
---|
| 115 | ////////////////////////////////////////////////////////////////////////
|
---|
| 116 |
|
---|
| 117 | ////////////////////////////////////////////////////////////////////////
|
---|
[149] | 118 | inline double Deg2Rad(double deg)
|
---|
| 119 | {
|
---|
[211] | 120 | using ::boost::math::constants::pi;
|
---|
[208] | 121 | return deg * pi<double>() / 180.0;
|
---|
[149] | 122 | }
|
---|
| 123 |
|
---|
| 124 | inline double Rad2Deg(double rad)
|
---|
| 125 | {
|
---|
[211] | 126 | using ::boost::math::constants::pi;
|
---|
[208] | 127 | return rad * 180.0 / pi<double>();
|
---|
[149] | 128 | }
|
---|
| 129 |
|
---|
[89] | 130 | ////////////////////////////////////////////////////////////////////////
|
---|
| 131 |
|
---|
[210] | 132 | const double a_Lambert93 = 6378137;
|
---|
| 133 | const double f_Lambert93 = 1 / 298.257222101;
|
---|
| 134 | const double e_Lambert93 = sqrt(f_Lambert93 * (2 - f_Lambert93));
|
---|
| 135 | const double lambda0_Lambert93 = Deg2Rad(3.0); //degres
|
---|
| 136 | const double phi0_Lambert93 = Deg2Rad(46.5);
|
---|
| 137 | const double phi1_Lambert93 = Deg2Rad(44.0);
|
---|
| 138 | const double phi2_Lambert93 = Deg2Rad(49.0); //degres
|
---|
| 139 | const double X0_Lambert93 = 700000; //
|
---|
| 140 | const double Y0_Lambert93 = 6600000; //
|
---|
[89] | 141 | const double n_Lambert93 = 0.7256077650;
|
---|
| 142 | const double c_Lambert93 = 11754255.426;
|
---|
| 143 | const double xs_Lambert93 = 700000;
|
---|
| 144 | const double ys_Lambert93 = 12655612.050;
|
---|
| 145 |
|
---|
| 146 | const double GRS_a = 6378137;
|
---|
[210] | 147 | const double GRS_f = 1 / 298.257222101;
|
---|
| 148 | const double GRS_b = GRS_a * (1 - GRS_f);
|
---|
| 149 | const double GRS_e = sqrt((pow(GRS_a, 2) - pow(GRS_b, 2)) / pow(GRS_a, 2));
|
---|
[89] | 150 |
|
---|
| 151 | ////////////////////////////////////////////////////////////////////////
|
---|
[210] | 152 | PACPUSTOOLS_API void Geographique_2_Lambert93(const Raf98& raf98, double lambda, double phi, double he, Matrice in, double& E, double& N, double& h, Matrice& out);
|
---|
| 153 | PACPUSTOOLS_API void Geographique_2_Lambert93(const Raf98& raf98, double lambda, double phi, double he, double& E, double& N, double& h);
|
---|
| 154 | PACPUSTOOLS_API void Lambert93_2_Geographique(const Raf98& raf98, double E, double N, double h, double& lambda, double& phi, double& he);
|
---|
| 155 | PACPUSTOOLS_API void Lambert93_2_Geographique(const Raf98& raf98, double E, double N, double h, Matrice in, double& lambda, double& phi, double& he, Matrice& out);
|
---|
[89] | 156 | /** Convert from geographique to ECEF.
|
---|
| 157 | * @param[in] longitude Longitude in radian.
|
---|
| 158 | * @param[in] latitude Latitude in radian.
|
---|
| 159 | * @param[in] he Height in meter.
|
---|
| 160 | */
|
---|
[162] | 161 | PACPUSTOOLS_API void Geographique_2_ECEF(double longitude, double latitude, double he, double& x, double& y, double& z);
|
---|
[89] | 162 | /** Convert from ECEF two ENU.
|
---|
| 163 | * @param[in] lon0 Longitude of the origin in radian.
|
---|
| 164 | * @param[in] lat0 Latitude of the origin in radian.
|
---|
| 165 | * @param[in] he0 Height of the origin in radian.
|
---|
| 166 | */
|
---|
[210] | 167 | PACPUSTOOLS_API void ECEF_2_ENU(double x, double y, double z, double& e, double& n, double& u, double lon0, double lat0, double he0);
|
---|
[89] | 168 | ////////////////////////////////////////////////////////////////////////
|
---|
| 169 |
|
---|
| 170 | ///ALGO0001
|
---|
| 171 | /// @todo Rename
|
---|
[210] | 172 | PACPUSTOOLS_API double LatitueIsometrique(double latitude, double e);
|
---|
[89] | 173 | ///ALGO0002
|
---|
| 174 | /// @todo Rename
|
---|
[210] | 175 | PACPUSTOOLS_API double LatitueIsometrique2Lat(double latitude_iso, double e, double epsilon);
|
---|
[89] | 176 |
|
---|
| 177 | ///ALGO0003
|
---|
[162] | 178 | PACPUSTOOLS_API void Geo2ProjLambert(
|
---|
[210] | 179 | double lambda, double phi,
|
---|
| 180 | double n, double c, double e,
|
---|
| 181 | double lambdac, double xs, double ys,
|
---|
| 182 | double& X, double& Y);
|
---|
[89] | 183 | ///ALGO0004
|
---|
[162] | 184 | PACPUSTOOLS_API void Proj2GeoLambert(
|
---|
[210] | 185 | double X, double Y,
|
---|
| 186 | double n, double c, double e,
|
---|
| 187 | double lambdac, double xs, double ys,
|
---|
[89] | 188 | double epsilon,
|
---|
[210] | 189 | double& lambda, double& phi);
|
---|
[89] | 190 |
|
---|
[162] | 191 | PACPUSTOOLS_API double ConvMerApp(double longitude);
|
---|
[89] | 192 |
|
---|
[211] | 193 | /// Converts Cartesian (x, y) coordinates to polar coordinates (r, theta)
|
---|
[89] | 194 | template <typename _T1, typename _T2>
|
---|
[210] | 195 | void cartesianToPolar(const _T1 x, const _T1 y, _T2& r, _T2& theta)
|
---|
| 196 | {
|
---|
[220] | 197 | using ::std::atan2;
|
---|
| 198 | using ::std::sqrt;
|
---|
| 199 |
|
---|
| 200 | r = sqrt(x * x + y * y);
|
---|
| 201 | theta = atan2(x, y);
|
---|
[89] | 202 | }
|
---|
| 203 |
|
---|
[211] | 204 | /// Converts polar coordinates (r, theta) to Cartesian (x, y) coordinates
|
---|
[89] | 205 | template <typename _T1, typename _T2>
|
---|
[210] | 206 | void polarToCartesian(const _T1 r, const _T1 theta, _T2& x, _T2& y)
|
---|
| 207 | {
|
---|
[220] | 208 | using ::std::cos;
|
---|
| 209 | using ::std::sin;
|
---|
| 210 |
|
---|
[224] | 211 | x = _T2(r * cos(theta));
|
---|
| 212 | y = _T2(r * sin(theta));
|
---|
[89] | 213 | }
|
---|
| 214 |
|
---|
[211] | 215 | /// Converts Cartesian (x, y, z) coordinates to spherical coordinates (r, theta, phi)
|
---|
| 216 | /// Angles expressed in radians.
|
---|
[89] | 217 | template <typename _T1, typename _T2>
|
---|
[210] | 218 | void cartesianToSpherical(const _T1 x, const _T1 y, const _T1 z, _T2& r, _T2& theta, _T2& phi)
|
---|
| 219 | {
|
---|
[220] | 220 | using ::std::acos;
|
---|
| 221 | using ::std::atan2;
|
---|
| 222 | using ::std::sqrt;
|
---|
| 223 |
|
---|
| 224 | r = sqrt(x * x + y * y + z * z);
|
---|
| 225 | theta = acos(z / r);
|
---|
| 226 | phi = atan2(y, x);
|
---|
[89] | 227 | }
|
---|
| 228 |
|
---|
[211] | 229 | /// Converts spherical coordinates (r, theta, phi) to Cartesian (x, y, z) coordinates.
|
---|
| 230 | /// Angles expressed in radians.
|
---|
[89] | 231 | template <typename _T1, typename _T2>
|
---|
[210] | 232 | void sphericalToCartesian(const _T1 r, const _T1 theta, const _T1 phi, _T2& x, _T2& y, _T2& z)
|
---|
| 233 | {
|
---|
[220] | 234 | using ::std::cos;
|
---|
| 235 | using ::std::sin;
|
---|
| 236 |
|
---|
| 237 | x = r * sin(theta) * cos(phi);
|
---|
| 238 | y = r * sin(theta) * sin(phi);
|
---|
| 239 | z = r * cos(theta);
|
---|
[89] | 240 | }
|
---|
| 241 |
|
---|
[212] | 242 | PACPUSTOOLS_API QMatrix4x4 yprenuToMatrix(QVector3D angle, QVector3D position);
|
---|
[99] | 243 |
|
---|
[209] | 244 | } // namespace Geodesy
|
---|
| 245 |
|
---|
| 246 | namespace Geodesie
|
---|
| 247 | {
|
---|
[210] | 248 | using namespace Geodesy;
|
---|
[89] | 249 | } // namespace Geodesie
|
---|
| 250 |
|
---|
[224] | 251 | #ifdef _MSC_VER
|
---|
| 252 | # pragma warning(pop)
|
---|
| 253 | #endif // _MSC_VER
|
---|
| 254 |
|
---|
[89] | 255 | #endif // GEODESIE_H
|
---|