mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-06 02:16:04 +08:00
Completed transformation class and created samples for this class
This commit is contained in:
@@ -26,8 +26,18 @@ int CSamplesGeo::samples()
|
|||||||
// lat3 = lon1; //must not work
|
// lat3 = lon1; //must not work
|
||||||
// CGeoLongitude lonx(lat2); // must notwork
|
// CGeoLongitude lonx(lat2); // must notwork
|
||||||
|
|
||||||
CCoordinateGeodetic gc(10.0, 20.0, 1000);
|
CCoordinateGeodetic cg(10.0, 20.0, 1000);
|
||||||
qDebug() << gc;
|
CCoordinateEcef ce = CCoordinateTransformation::toEcef(cg);
|
||||||
|
CCoordinateGeodetic cg2 = CCoordinateTransformation::toGeodetic(ce);
|
||||||
|
cg2.switchUnit(CAngleUnit::deg());
|
||||||
|
qDebug() << cg << ce << cg2;
|
||||||
|
|
||||||
|
CCoordinateNed cned = CCoordinateTransformation::toNed(ce, cg);
|
||||||
|
CCoordinateEcef ce2 = CCoordinateTransformation::toEcef(cned);
|
||||||
|
qDebug() << ce << cned << ce2;
|
||||||
|
qDebug() << (cned + cned) << (ce + ce);
|
||||||
|
|
||||||
|
// cned += ce2; // must not work
|
||||||
|
|
||||||
// bye
|
// bye
|
||||||
qDebug() << "-----------------------------------------------";
|
qDebug() << "-----------------------------------------------";
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
/* Copyright (C) 2013 VATSIM Community / authors
|
/* Copyright (C) 2013 VATSIM Community / contributors
|
||||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
#ifndef BLACKMISCTEST_SAMPLESGEO_H
|
#ifndef BLACKMISCTEST_SAMPLESGEO_H
|
||||||
#define BLACKMISCTEST_SAMPLESGEO_H
|
#define BLACKMISCTEST_SAMPLESGEO_H
|
||||||
#include "blackmisc/coordinategeodetic.h"
|
#include "blackmisc/coordinatetransformation.h"
|
||||||
|
|
||||||
namespace BlackMiscTest
|
namespace BlackMiscTest
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -96,8 +96,20 @@ public:
|
|||||||
*/
|
*/
|
||||||
BlackMisc::Math::CVector3D toMathVector() const
|
BlackMisc::Math::CVector3D toMathVector() const
|
||||||
{
|
{
|
||||||
return BlackMisc::Math::CVector3D(this->z(), this->y(), this->x());
|
return BlackMisc::Math::CVector3D(this->x(), this->y(), this->z());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
/*!
|
||||||
|
* \brief String for converter
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
virtual QString stringForConverter() const
|
||||||
|
{
|
||||||
|
QString s = "ECEF: {x %1, y %2, z %3}";
|
||||||
|
return s.arg(this->x()).arg(this->y()).arg(this->z());
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2013 VATSIM Community / authors
|
/* Copyright (C) 2013 VATSIM Community / contributors
|
||||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
@@ -33,8 +33,8 @@ protected:
|
|||||||
*/
|
*/
|
||||||
virtual QString stringForConverter() const
|
virtual QString stringForConverter() const
|
||||||
{
|
{
|
||||||
QString s = "{%1, %2, %3}";
|
QString s = "Geodetic: {%1, %2, %3}";
|
||||||
return s.arg(this->m_latitude).arg(this->m_longitude).arg(this->height());
|
return s.arg(this->m_latitude.unitValueRoundedWithUnit()).arg(this->m_longitude.unitValueRoundedWithUnit()).arg(this->m_height.unitValueRoundedWithUnit());
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -67,7 +67,6 @@ public:
|
|||||||
CCoordinateGeodetic(qreal latitudeDegrees, qreal longitudeDegrees, qreal heightMeters) :
|
CCoordinateGeodetic(qreal latitudeDegrees, qreal longitudeDegrees, qreal heightMeters) :
|
||||||
m_latitude(latitudeDegrees, BlackMisc::PhysicalQuantities::CAngleUnit::deg()), m_longitude(longitudeDegrees, BlackMisc::PhysicalQuantities::CAngleUnit::deg()), m_height(heightMeters, BlackMisc::PhysicalQuantities::CLengthUnit::m()) {}
|
m_latitude(latitudeDegrees, BlackMisc::PhysicalQuantities::CAngleUnit::deg()), m_longitude(longitudeDegrees, BlackMisc::PhysicalQuantities::CAngleUnit::deg()), m_height(heightMeters, BlackMisc::PhysicalQuantities::CLengthUnit::m()) {}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Latitude
|
* \brief Latitude
|
||||||
* \return
|
* \return
|
||||||
@@ -95,6 +94,25 @@ public:
|
|||||||
return this->m_height;
|
return this->m_height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Switch unit of latitude / longitude
|
||||||
|
* \param unit
|
||||||
|
*/
|
||||||
|
void switchUnit(const BlackMisc::PhysicalQuantities::CAngleUnit &unit)
|
||||||
|
{
|
||||||
|
this->m_latitude.switchUnit(unit);
|
||||||
|
this->m_longitude.switchUnit(unit);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Switch unit of height
|
||||||
|
* \param unit
|
||||||
|
*/
|
||||||
|
void switchUnit(const BlackMisc::PhysicalQuantities::CLengthUnit &unit)
|
||||||
|
{
|
||||||
|
this->m_height.switchUnit(unit);
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Set latitude
|
* \brief Set latitude
|
||||||
* \param latitude
|
* \param latitude
|
||||||
|
|||||||
@@ -23,6 +23,17 @@ private:
|
|||||||
CCoordinateGeodetic m_referencePosition; //!< geodetic reference position
|
CCoordinateGeodetic m_referencePosition; //!< geodetic reference position
|
||||||
bool m_hasReferencePosition; //!< valid reference position?
|
bool m_hasReferencePosition; //!< valid reference position?
|
||||||
|
|
||||||
|
protected:
|
||||||
|
/*!
|
||||||
|
* \brief String for converter
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
virtual QString stringForConverter() const
|
||||||
|
{
|
||||||
|
QString s = "NED: {N %1, E %2, D %3}";
|
||||||
|
return s.arg(this->north()).arg(this->east()).arg(this->down());
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/*!
|
/*!
|
||||||
* \brief Default constructor
|
* \brief Default constructor
|
||||||
|
|||||||
@@ -60,13 +60,49 @@ CCoordinateEcef CCoordinateTransformation::toEcef(const CCoordinateNed &ned)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Convert to NED
|
* Geodetic to ECEF
|
||||||
*/
|
*/
|
||||||
CCoordinateNed toNed(const CCoordinateEcef &ecef, const CCoordinateGeodetic &geo)
|
CCoordinateEcef CCoordinateTransformation::toEcef(const CCoordinateGeodetic &geo)
|
||||||
{
|
{
|
||||||
|
// TODO: Clarify the comparions with fixed angles (==90, ==180) -> what happens here
|
||||||
|
|
||||||
CLatitude lat = geo.latitude();
|
CLatitude lat = geo.latitude();
|
||||||
CLongitude lon = geo.longitude();
|
CLongitude lon = geo.longitude();
|
||||||
|
qreal latDeg = lat.value(CAngleUnit::deg());
|
||||||
|
qreal lonDeg = lon.value(CAngleUnit::deg());
|
||||||
|
|
||||||
|
double phi = lat.value(CAngleUnit::rad());
|
||||||
|
double lambdaRad = lon.value(CAngleUnit::rad());
|
||||||
|
double sphi = sin(phi);
|
||||||
|
double cphi = 0;
|
||||||
|
if (abs(latDeg) != 90) cphi = cos(phi);
|
||||||
|
|
||||||
|
double n = EarthRadiusMeters() / sqrt(1 - e2() * CMath::square(sphi));
|
||||||
|
|
||||||
|
double slambda = 0;
|
||||||
|
if (lonDeg != -180) slambda = sin(lambdaRad);
|
||||||
|
|
||||||
|
double clambda = 0;
|
||||||
|
if (abs(lonDeg) != 90) clambda = cos(lambdaRad);
|
||||||
|
|
||||||
|
double h = geo.height().convertedSiValueToDouble();
|
||||||
|
double X = (n + h) * cphi;
|
||||||
|
double Y = X * slambda;
|
||||||
|
X *= clambda;
|
||||||
|
double Z = (e2m() * n + h) * sphi;
|
||||||
|
|
||||||
|
CCoordinateEcef result(X, Y, Z);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Convert to NED
|
||||||
|
*/
|
||||||
|
CCoordinateNed CCoordinateTransformation::toNed(const CCoordinateEcef &ecef, const CCoordinateGeodetic &referencePosition)
|
||||||
|
{
|
||||||
|
|
||||||
|
CLatitude lat = referencePosition.latitude();
|
||||||
|
CLongitude lon = referencePosition.longitude();
|
||||||
double angleRad = - (lat.value(CAngleUnit::rad())) - BlackMisc::Math::PI / 2;
|
double angleRad = - (lat.value(CAngleUnit::rad())) - BlackMisc::Math::PI / 2;
|
||||||
|
|
||||||
CMatrix3x3 dcm1;
|
CMatrix3x3 dcm1;
|
||||||
@@ -91,7 +127,7 @@ CCoordinateNed toNed(const CCoordinateEcef &ecef, const CCoordinateGeodetic &geo
|
|||||||
dcm = dcm1 * dcm2 * dcm3;
|
dcm = dcm1 * dcm2 * dcm3;
|
||||||
|
|
||||||
CVector3D tempResult = dcm * ecef.toMathVector(); // to generic vector
|
CVector3D tempResult = dcm * ecef.toMathVector(); // to generic vector
|
||||||
CCoordinateNed result(geo, tempResult);
|
CCoordinateNed result(referencePosition, tempResult);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -105,11 +105,19 @@ public:
|
|||||||
static CCoordinateEcef toEcef(const CCoordinateNed &ned);
|
static CCoordinateEcef toEcef(const CCoordinateNed &ned);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief ECEF via Geodetic to NED
|
* \brief Geodetic to ECEF
|
||||||
* \param geo
|
* \param geo
|
||||||
* \return
|
* \return
|
||||||
*/
|
*/
|
||||||
static CCoordinateNed toNed(const CCoordinateEcef &ecef, const CCoordinateGeodetic &geo);
|
static CCoordinateEcef toEcef(const CCoordinateGeodetic &geo);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief ECEF via Geodetic to NED
|
||||||
|
* \param ecef
|
||||||
|
* \param referencePosition
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
static CCoordinateNed toNed(const CCoordinateEcef &ecef, const CCoordinateGeodetic &referencePosition);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief ECEF to Geodetic
|
* \brief ECEF to Geodetic
|
||||||
|
|||||||
@@ -164,7 +164,7 @@ public:
|
|||||||
QString valueRoundedWithUnit(const MU &unit, int digits = -1) const;
|
QString valueRoundedWithUnit(const MU &unit, int digits = -1) const;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Value a int
|
* \brief Value as int
|
||||||
* \return
|
* \return
|
||||||
*/
|
*/
|
||||||
qint32 unitValueToInteger() const
|
qint32 unitValueToInteger() const
|
||||||
@@ -173,7 +173,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Value a double
|
* \brief Value as double
|
||||||
* \return
|
* \return
|
||||||
*/
|
*/
|
||||||
double unitValueToDouble() const
|
double unitValueToDouble() const
|
||||||
@@ -188,24 +188,6 @@ public:
|
|||||||
*/
|
*/
|
||||||
QString unitValueRoundedWithUnit(int digits = -1) const;
|
QString unitValueRoundedWithUnit(int digits = -1) const;
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief SI value to integer
|
|
||||||
* \return
|
|
||||||
*/
|
|
||||||
qint32 siBaseUnitValueToInteger() const
|
|
||||||
{
|
|
||||||
return CMeasurementUnit::round(this->m_convertedSiUnitValueD, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief SI value to double
|
|
||||||
* \return
|
|
||||||
*/
|
|
||||||
double siBaseUnitValueToDouble() const
|
|
||||||
{
|
|
||||||
return this->m_convertedSiUnitValueD;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Rounded value by n digits
|
* \brief Rounded value by n digits
|
||||||
* \param digits
|
* \param digits
|
||||||
@@ -221,7 +203,7 @@ public:
|
|||||||
QString unitValueToQStringRounded(int digits = -1) const;
|
QString unitValueToQStringRounded(int digits = -1) const;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief SI value as double
|
* \brief Conversion SI value as double
|
||||||
* \return
|
* \return
|
||||||
*/
|
*/
|
||||||
double convertedSiValueToDouble() const
|
double convertedSiValueToDouble() const
|
||||||
@@ -391,4 +373,4 @@ public:
|
|||||||
} // namespace
|
} // namespace
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
#endif // BLACKMISC_PQPHYSICALQUANTITY_H
|
#endif // guard
|
||||||
|
|||||||
@@ -27,15 +27,15 @@ private:
|
|||||||
* \brief Constructor Distance unit
|
* \brief Constructor Distance unit
|
||||||
* \param name
|
* \param name
|
||||||
* \param unitName
|
* \param unitName
|
||||||
* \param isSIUnit
|
* \param isSiUnit
|
||||||
* \param isSIBaseUnit
|
* \param isSIBaseUnit
|
||||||
* \param conversionFactorToSI
|
* \param conversionFactorToSI
|
||||||
* \param mulitplier
|
* \param mulitplier
|
||||||
* \param displayDigits
|
* \param displayDigits
|
||||||
* \param epsilon
|
* \param epsilon
|
||||||
*/
|
*/
|
||||||
CLengthUnit(const QString &name, const QString &unitName, bool isSIUnit, bool isSIBaseUnit, double conversionFactorToSI = 1.0, const CMeasurementPrefix &mulitplier = CMeasurementPrefix::One(), qint32 displayDigits = 2, double epsilon = 1E-9) :
|
CLengthUnit(const QString &name, const QString &unitName, bool isSiUnit, bool isSIBaseUnit, double conversionFactorToSI = 1.0, const CMeasurementPrefix &mulitplier = CMeasurementPrefix::One(), qint32 displayDigits = 2, double epsilon = 1E-9) :
|
||||||
CMeasurementUnit(name, unitName, "distance", isSIUnit, isSIBaseUnit, conversionFactorToSI, mulitplier, displayDigits, epsilon)
|
CMeasurementUnit(name, unitName, "distance", isSiUnit, isSIBaseUnit, conversionFactorToSI, mulitplier, displayDigits, epsilon)
|
||||||
{
|
{
|
||||||
// void
|
// void
|
||||||
}
|
}
|
||||||
@@ -111,17 +111,17 @@ private:
|
|||||||
* \brief Constructor angle units: Radian, degree
|
* \brief Constructor angle units: Radian, degree
|
||||||
* \param name
|
* \param name
|
||||||
* \param unitName
|
* \param unitName
|
||||||
* \param isSIUnit
|
* \param isSiUnit
|
||||||
* \param conversionFactorToSI
|
* \param conversionFactorToSI
|
||||||
* \param mulitplier
|
* \param multiplier
|
||||||
* \param displayDigits
|
* \param displayDigits
|
||||||
* \param epsilon
|
* \param epsilon
|
||||||
*/
|
*/
|
||||||
CAngleUnit(const QString &name, const QString &unitName, bool isSIUnit, double conversionFactorToSI = 1.0,
|
CAngleUnit(const QString &name, const QString &unitName, bool isSiUnit, double conversionFactorToSI = 1.0,
|
||||||
const CMeasurementPrefix &mulitplier = CMeasurementPrefix::One(), qint32 displayDigits = 2,
|
const CMeasurementPrefix &multiplier = CMeasurementPrefix::One(), qint32 displayDigits = 2,
|
||||||
double epsilon = 1E-9, UnitConverter converterToSi = nullptr, UnitConverter converterFromSi = nullptr) :
|
double epsilon = 1E-9, UnitConverter converterToSi = nullptr, UnitConverter converterFromSi = nullptr) :
|
||||||
CMeasurementUnit(name, unitName, "angle", isSIUnit, false, conversionFactorToSI,
|
CMeasurementUnit(name, unitName, "angle", isSiUnit, false, conversionFactorToSI,
|
||||||
mulitplier, displayDigits, epsilon, converterToSi, converterFromSi)
|
multiplier, displayDigits, epsilon, converterToSi, converterFromSi)
|
||||||
{
|
{
|
||||||
// void
|
// void
|
||||||
}
|
}
|
||||||
@@ -192,14 +192,14 @@ private:
|
|||||||
* \brief CFrequencyUnit
|
* \brief CFrequencyUnit
|
||||||
* \param name
|
* \param name
|
||||||
* \param unitName
|
* \param unitName
|
||||||
* \param isSIUnit
|
* \param isSiUnit
|
||||||
* \param conversionFactorToSI
|
* \param conversionFactorToSI
|
||||||
* \param mulitplier
|
* \param mulitplier
|
||||||
* \param displayDigits
|
* \param displayDigits
|
||||||
* \param epsilon
|
* \param epsilon
|
||||||
*/
|
*/
|
||||||
CFrequencyUnit(const QString &name, const QString &unitName, bool isSIUnit, double conversionFactorToSI = 1.0, const CMeasurementPrefix &mulitplier = CMeasurementPrefix::One(), qint32 displayDigits = 2, double epsilon = 1E-9) :
|
CFrequencyUnit(const QString &name, const QString &unitName, bool isSiUnit, double conversionFactorToSI = 1.0, const CMeasurementPrefix &mulitplier = CMeasurementPrefix::One(), qint32 displayDigits = 2, double epsilon = 1E-9) :
|
||||||
CMeasurementUnit(name, unitName, "frequency", isSIUnit, false, conversionFactorToSI, mulitplier, displayDigits, epsilon) {}
|
CMeasurementUnit(name, unitName, "frequency", isSiUnit, false, conversionFactorToSI, mulitplier, displayDigits, epsilon) {}
|
||||||
public:
|
public:
|
||||||
/*!
|
/*!
|
||||||
* \brief Copy constructor
|
* \brief Copy constructor
|
||||||
@@ -258,15 +258,15 @@ private:
|
|||||||
* \brief Constructor mass units
|
* \brief Constructor mass units
|
||||||
* \param name
|
* \param name
|
||||||
* \param unitName
|
* \param unitName
|
||||||
* \param isSIUnit
|
* \param isSiUnit
|
||||||
* \param isSIBaseUnit
|
* \param isSIBaseUnit
|
||||||
* \param conversionFactorToSI
|
* \param conversionFactorToSI
|
||||||
* \param mulitplier
|
* \param mulitplier
|
||||||
* \param displayDigits
|
* \param displayDigits
|
||||||
* \param epsilon
|
* \param epsilon
|
||||||
*/
|
*/
|
||||||
CMassUnit(const QString &name, const QString &unitName, bool isSIUnit, bool isSIBaseUnit, double conversionFactorToSI = 1.0, const CMeasurementPrefix &mulitplier = CMeasurementPrefix::One(), qint32 displayDigits = 2, double epsilon = 1E-9) :
|
CMassUnit(const QString &name, const QString &unitName, bool isSiUnit, bool isSIBaseUnit, double conversionFactorToSI = 1.0, const CMeasurementPrefix &mulitplier = CMeasurementPrefix::One(), qint32 displayDigits = 2, double epsilon = 1E-9) :
|
||||||
CMeasurementUnit(name, unitName, "mass", isSIUnit, isSIBaseUnit, conversionFactorToSI, mulitplier, displayDigits, epsilon) {}
|
CMeasurementUnit(name, unitName, "mass", isSiUnit, isSIBaseUnit, conversionFactorToSI, mulitplier, displayDigits, epsilon) {}
|
||||||
public:
|
public:
|
||||||
/*!
|
/*!
|
||||||
* \brief Copy constructor
|
* \brief Copy constructor
|
||||||
@@ -326,14 +326,14 @@ private:
|
|||||||
* \brief Pressure unit
|
* \brief Pressure unit
|
||||||
* \param name
|
* \param name
|
||||||
* \param unitName
|
* \param unitName
|
||||||
* \param isSIUnit
|
* \param isSiUnit
|
||||||
* \param conversionFactorToSI
|
* \param conversionFactorToSI
|
||||||
* \param mulitplier
|
* \param mulitplier
|
||||||
* \param displayDigits
|
* \param displayDigits
|
||||||
* \param epsilon
|
* \param epsilon
|
||||||
*/
|
*/
|
||||||
CPressureUnit(const QString &name, const QString &unitName, bool isSIUnit, double conversionFactorToSI = 1.0, const CMeasurementPrefix &mulitplier = CMeasurementPrefix::One(), qint32 displayDigits = 2, double epsilon = 1E-9) :
|
CPressureUnit(const QString &name, const QString &unitName, bool isSiUnit, double conversionFactorToSI = 1.0, const CMeasurementPrefix &mulitplier = CMeasurementPrefix::One(), qint32 displayDigits = 2, double epsilon = 1E-9) :
|
||||||
CMeasurementUnit(name, unitName, "frequency", isSIUnit, false, conversionFactorToSI, mulitplier, displayDigits, epsilon) {}
|
CMeasurementUnit(name, unitName, "frequency", isSiUnit, false, conversionFactorToSI, mulitplier, displayDigits, epsilon) {}
|
||||||
public:
|
public:
|
||||||
/*!
|
/*!
|
||||||
* \brief Copy constructor
|
* \brief Copy constructor
|
||||||
@@ -421,7 +421,7 @@ private:
|
|||||||
* Constructor temperature unit
|
* Constructor temperature unit
|
||||||
* \param name
|
* \param name
|
||||||
* \param unitName
|
* \param unitName
|
||||||
* \param isSIUnit
|
* \param isSiUnit
|
||||||
* \param isSIBaseUnit
|
* \param isSIBaseUnit
|
||||||
* \param conversionFactorToSI
|
* \param conversionFactorToSI
|
||||||
* \param temperatureOffsetToSI
|
* \param temperatureOffsetToSI
|
||||||
@@ -429,8 +429,8 @@ private:
|
|||||||
* \param displayDigits
|
* \param displayDigits
|
||||||
* \param epsilon
|
* \param epsilon
|
||||||
*/
|
*/
|
||||||
CTemperatureUnit(const QString &name, const QString &unitName, bool isSIUnit, bool isSIBaseUnit, double conversionFactorToSI = 1.0, double temperatureOffsetToSI = 0, const CMeasurementPrefix &mulitplier = CMeasurementPrefix::One(), qint32 displayDigits = 2, double epsilon = 1E-9) :
|
CTemperatureUnit(const QString &name, const QString &unitName, bool isSiUnit, bool isSIBaseUnit, double conversionFactorToSI = 1.0, double temperatureOffsetToSI = 0, const CMeasurementPrefix &mulitplier = CMeasurementPrefix::One(), qint32 displayDigits = 2, double epsilon = 1E-9) :
|
||||||
CMeasurementUnit(name, unitName, "temperature", isSIUnit, isSIBaseUnit, conversionFactorToSI, mulitplier, displayDigits, epsilon), m_conversionOffsetToSi(temperatureOffsetToSI) {}
|
CMeasurementUnit(name, unitName, "temperature", isSiUnit, isSIBaseUnit, conversionFactorToSI, mulitplier, displayDigits, epsilon), m_conversionOffsetToSi(temperatureOffsetToSI) {}
|
||||||
protected:
|
protected:
|
||||||
/*!
|
/*!
|
||||||
* \brief Convert to SI conversion unit, specific for temperature
|
* \brief Convert to SI conversion unit, specific for temperature
|
||||||
@@ -501,15 +501,15 @@ private:
|
|||||||
* \brief Speed unit constructor
|
* \brief Speed unit constructor
|
||||||
* \param name
|
* \param name
|
||||||
* \param unitName
|
* \param unitName
|
||||||
* \param isSIUnit
|
* \param isSiUnit
|
||||||
* \param isSIBaseUnit
|
* \param isSIBaseUnit
|
||||||
* \param conversionFactorToSI
|
* \param conversionFactorToSI
|
||||||
* \param mulitplier
|
* \param mulitplier
|
||||||
* \param displayDigits
|
* \param displayDigits
|
||||||
* \param epsilon
|
* \param epsilon
|
||||||
*/
|
*/
|
||||||
CSpeedUnit(const QString &name, const QString &unitName, bool isSIUnit, bool isSIBaseUnit, double conversionFactorToSI = 1.0, const CMeasurementPrefix &mulitplier = CMeasurementPrefix::One(), qint32 displayDigits = 2, double epsilon = 1E-9) :
|
CSpeedUnit(const QString &name, const QString &unitName, bool isSiUnit, bool isSIBaseUnit, double conversionFactorToSI = 1.0, const CMeasurementPrefix &mulitplier = CMeasurementPrefix::One(), qint32 displayDigits = 2, double epsilon = 1E-9) :
|
||||||
CMeasurementUnit(name, unitName, "speed", isSIUnit, isSIBaseUnit, conversionFactorToSI, mulitplier, displayDigits, epsilon) {}
|
CMeasurementUnit(name, unitName, "speed", isSiUnit, isSIBaseUnit, conversionFactorToSI, mulitplier, displayDigits, epsilon) {}
|
||||||
public:
|
public:
|
||||||
/*!
|
/*!
|
||||||
* Constructor, allows to implement methods in base class
|
* Constructor, allows to implement methods in base class
|
||||||
@@ -584,15 +584,15 @@ private:
|
|||||||
* \brief Time unit constructor
|
* \brief Time unit constructor
|
||||||
* \param name
|
* \param name
|
||||||
* \param unitName
|
* \param unitName
|
||||||
* \param isSIUnit
|
* \param isSiUnit
|
||||||
* \param isSIBaseUnit
|
* \param isSIBaseUnit
|
||||||
* \param conversionFactorToSI
|
* \param conversionFactorToSI
|
||||||
* \param mulitplier
|
* \param mulitplier
|
||||||
* \param displayDigits
|
* \param displayDigits
|
||||||
* \param epsilon
|
* \param epsilon
|
||||||
*/
|
*/
|
||||||
CTimeUnit(const QString &name, const QString &unitName, bool isSIUnit, bool isSIBaseUnit, double conversionFactorToSI = 1.0, const CMeasurementPrefix &mulitplier = CMeasurementPrefix::One(), qint32 displayDigits = 2, double epsilon = 1E-9) :
|
CTimeUnit(const QString &name, const QString &unitName, bool isSiUnit, bool isSIBaseUnit, double conversionFactorToSI = 1.0, const CMeasurementPrefix &mulitplier = CMeasurementPrefix::One(), qint32 displayDigits = 2, double epsilon = 1E-9) :
|
||||||
CMeasurementUnit(name, unitName, "time", isSIUnit, isSIBaseUnit, conversionFactorToSI, mulitplier, displayDigits, epsilon) {}
|
CMeasurementUnit(name, unitName, "time", isSiUnit, isSIBaseUnit, conversionFactorToSI, mulitplier, displayDigits, epsilon) {}
|
||||||
public:
|
public:
|
||||||
/*!
|
/*!
|
||||||
* Constructor, allows to implement methods in base class
|
* Constructor, allows to implement methods in base class
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2013 VATSIM Community / authors
|
/* Copyright (C) 2013 VATSIM Community / contributors
|
||||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
@@ -7,7 +7,8 @@
|
|||||||
|
|
||||||
using namespace BlackMisc::PhysicalQuantities;
|
using namespace BlackMisc::PhysicalQuantities;
|
||||||
|
|
||||||
namespace BlackMiscTest {
|
namespace BlackMiscTest
|
||||||
|
{
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Constructor
|
* Constructor
|
||||||
@@ -88,7 +89,7 @@ void CTestPhysicalQuantitiesBase::frequencyTests()
|
|||||||
CFrequency f1(1, CFrequencyUnit::MHz());
|
CFrequency f1(1, CFrequencyUnit::MHz());
|
||||||
QVERIFY2(f1.valueRounded(CFrequencyUnit::kHz(), 2) == 1000, "Mega is 1000kHz");
|
QVERIFY2(f1.valueRounded(CFrequencyUnit::kHz(), 2) == 1000, "Mega is 1000kHz");
|
||||||
QVERIFY2(f1.unitValueToDouble() == 1 , "1MHz");
|
QVERIFY2(f1.unitValueToDouble() == 1 , "1MHz");
|
||||||
QVERIFY2(f1.siBaseUnitValueToDouble() == 1000000 , "1E6 Hz");
|
QVERIFY2(f1.convertedSiValueToDouble() == 1000000 , "1E6 Hz");
|
||||||
CFrequency f2(CMeasurementPrefix::M(), CFrequencyUnit::Hz()) ; // 1 Megahertz
|
CFrequency f2(CMeasurementPrefix::M(), CFrequencyUnit::Hz()) ; // 1 Megahertz
|
||||||
QVERIFY2(f1 == f2 , "MHz is 1E6 Hz");
|
QVERIFY2(f1 == f2 , "MHz is 1E6 Hz");
|
||||||
}
|
}
|
||||||
@@ -159,7 +160,7 @@ void CTestPhysicalQuantitiesBase::temperatureTests()
|
|||||||
void CTestPhysicalQuantitiesBase::timeTests()
|
void CTestPhysicalQuantitiesBase::timeTests()
|
||||||
{
|
{
|
||||||
CTime t1(1, CTimeUnit::h());
|
CTime t1(1, CTimeUnit::h());
|
||||||
QVERIFY2(t1.siBaseUnitValueToInteger() == 3600, "1hour shall be 3600s");
|
QVERIFY2(t1.convertedSiValueToInteger() == 3600, "1hour shall be 3600s");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
Reference in New Issue
Block a user