20#ifdef WITH_GEOGRAPHICLIB
21#include <GeographicLib/MagneticModel.hpp>
28#ifdef WITH_GEOGRAPHICLIB
29 return QString::fromStdString( GeographicLib::MagneticModel::DefaultMagneticPath() );
37#ifdef WITH_GEOGRAPHICLIB
38 return QString::fromStdString( GeographicLib::MagneticModel::DefaultMagneticName() );
48#ifdef WITH_GEOGRAPHICLIB
51 mModel = std::make_unique< GeographicLib::MagneticModel >( mName.toStdString(), mPath.toStdString(), GeographicLib::Geocentric::WGS84(), nMax, mMax );
53 catch ( GeographicLib::GeographicErr &e )
55 mError = QString::fromStdString( e.what() );
57 catch ( std::bad_alloc &e )
59 mError = QString::fromStdString( e.what() );
71#ifdef WITH_GEOGRAPHICLIB
72 return static_cast< bool >( mModel );
80#ifdef WITH_GEOGRAPHICLIB
84 const QString desc = QString::fromStdString( mModel->Description() );
85 return desc ==
"UNKNOWN"_L1 ? QString() : desc;
93#ifdef WITH_GEOGRAPHICLIB
97 const QString dt = QString::fromStdString( mModel->DateTime() );
98 if ( dt ==
"UNKNOWN"_L1 )
101 return QDateTime::fromString( dt, Qt::ISODate );
109#ifdef WITH_GEOGRAPHICLIB
110 return mModel ? QString::fromStdString( mModel->MagneticFile() ) : QString();
118#ifdef WITH_GEOGRAPHICLIB
119 return mModel ? QString::fromStdString( mModel->MagneticModelDirectory() ) : QString();
127#ifdef WITH_GEOGRAPHICLIB
128 return mModel ? QString::fromStdString( mModel->MagneticModelName() ) : QString();
136#ifdef WITH_GEOGRAPHICLIB
137 return mModel ? mModel->MinHeight() : 0;
145#ifdef WITH_GEOGRAPHICLIB
146 return mModel ? mModel->MaxHeight() : 0;
154#ifdef WITH_GEOGRAPHICLIB
155 return mModel ? mModel->MinTime() : 0;
163#ifdef WITH_GEOGRAPHICLIB
164 return mModel ? mModel->MaxTime() : 0;
172#ifdef WITH_GEOGRAPHICLIB
173 return mModel ? mModel->Degree() : 0;
181#ifdef WITH_GEOGRAPHICLIB
182 return mModel ? mModel->Order() : 0;
191#ifdef WITH_GEOGRAPHICLIB
195 if ( !
getComponents( years, latitude, longitude, height, Bx, By, Bz ) )
217#ifdef WITH_GEOGRAPHICLIB
221 if ( !
getComponents( years, latitude, longitude, height, Bx, By, Bz ) )
245#ifdef WITH_GEOGRAPHICLIB
249 ( *mModel )( years, latitude, longitude, height, Bx, By, Bz );
268#ifdef WITH_GEOGRAPHICLIB
272 ( *mModel )( years, latitude, longitude, height, Bx, By, Bz, Bxt, Byt, Bzt );
289#ifdef WITH_GEOGRAPHICLIB
290 GeographicLib::MagneticModel::FieldComponents( Bx, By, Bz, H, F, D, I );
300bool QgsMagneticModel::fieldComponentsWithTimeDerivatives(
double Bx,
double By,
double Bz,
double Bxt,
double Byt,
double Bzt,
double &H,
double &F,
double &D,
double &I,
double &Ht,
double &Ft,
double &Dt,
double &It )
310#ifdef WITH_GEOGRAPHICLIB
311 GeographicLib::MagneticModel::FieldComponents( Bx, By, Bz, Bxt, Byt, Bzt, H, F, D, I, Ht, Ft, Dt, It );
bool getComponents(double years, double latitude, double longitude, double height, double &Bx, double &By, double &Bz) const
Evaluates the components of the geomagnetic field at a point.
static QString defaultFilePath()
Returns the default path used by GeographicLib to search for magnetic models.
int order() const
Returns the maximum order of the components of the model.
QString description() const
Returns the description of the magnetic model, if available.
double minimumHeight() const
Returns the minimum height above the ellipsoid (in meters) for which the model should be used.
QString file() const
Returns the full file name for the magnetic model.
bool isValid() const
Returns true if the model is valid and can be used.
bool declination(double years, double latitude, double longitude, double height, double &declination) const
Calculates the declination of the field at a point.
double maximumYear() const
Returns the maximum time (in decimal years) for which the model should be used.
QString name() const
Returns the name of the magnetic model.
static bool fieldComponentsWithTimeDerivatives(double Bx, double By, double Bz, double Bxt, double Byt, double Bzt, double &H, double &F, double &D, double &I, double &Ht, double &Ft, double &Dt, double &It)
Compute various quantities dependent on a magnetic field and their rates of change.
QString directory() const
Returns the full directory name containing the magnetic model file.
bool getComponentsWithTimeDerivatives(double years, double latitude, double longitude, double height, double &Bx, double &By, double &Bz, double &Bxt, double &Byt, double &Bzt) const
Evaluates the components of the geomagnetic field at a point, and their time derivatives.
int degree() const
Returns the maximum degree of the components of the model.
double minimumYear() const
Returns the minimum time (in decimal years) for which the model should be used.
QDateTime dateTime() const
Returns the date of the magnetic model, if available.
bool inclination(double years, double latitude, double longitude, double height, double &inclination) const
Calculates the inclination of the field at a point.
double maximumHeight() const
Returns the maximum height above the ellipsoid (in meters) for which the model should be used.
static QString defaultModelName()
Returns the name of the default magnetic model used by GeographicLib.
static bool fieldComponents(double Bx, double By, double Bz, double &H, double &F, double &D, double &I)
Compute various quantities dependent on a magnetic field.
QgsMagneticModel(const QString &name, const QString &path=QString(), int maxDegree=-1, int maxOrder=-1)
Constructor for QgsMagneticModel.
Custom exception class which is raised when an operation is not supported.