mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-01 13:36:48 +08:00
Ref T180, formatting / const
This commit is contained in:
@@ -95,9 +95,10 @@ namespace BlackMisc
|
||||
{
|
||||
if (name.isEmpty() || m_name.isEmpty()) { return false; }
|
||||
if (caseInsensitiveStringCompare(name, this->getDbKey())) { return true; } // exact ISO match
|
||||
if (caseInsensitiveStringCompare(name, this->getIso3Code())) { return true; } // exact ISO match
|
||||
if (caseInsensitiveStringCompare(name, this->getIso3Code())) { return true; } // exact ISO3 match
|
||||
if (name.length() < 5)
|
||||
{
|
||||
// contains would be too fuzzy for short names
|
||||
return caseInsensitiveStringCompare(name, m_name) || caseInsensitiveStringCompare(name, m_simplifiedName);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace BlackMisc
|
||||
thread_local const QRegularExpression reg("^[a-z]+", QRegularExpression::CaseInsensitiveOption);
|
||||
QRegularExpressionMatch match = reg.match(countryName);
|
||||
const QString cn(match.hasMatch() ? match.captured(0) : countryName);
|
||||
CCountryList countries = this->findBy([&](const CCountry & country)
|
||||
const CCountryList countries = this->findBy([&](const CCountry & country)
|
||||
{
|
||||
return country.matchesCountryName(cn);
|
||||
});
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace BlackMisc
|
||||
QString CCoordinateGeodetic::convertToQString(bool i18n) const
|
||||
{
|
||||
static const QString s = "Geodetic: {%1, %2, %3}";
|
||||
return s.arg(this->latitude().valueRoundedWithUnit(6, i18n), this->longitude().valueRoundedWithUnit(6, i18n), this->m_geodeticHeight.valueRoundedWithUnit(6, i18n));
|
||||
return s.arg(this->latitude().valueRoundedWithUnit(6, i18n), this->longitude().valueRoundedWithUnit(6, i18n), m_geodeticHeight.valueRoundedWithUnit(6, i18n));
|
||||
}
|
||||
|
||||
CCoordinateGeodetic CCoordinateGeodetic::fromWgs84(const QString &latitudeWgs84, const QString &longitudeWgs84, const CAltitude &geodeticHeight)
|
||||
@@ -81,7 +81,7 @@ namespace BlackMisc
|
||||
|
||||
bool ICoordinateGeodetic::canHandleIndex(const CPropertyIndex &index)
|
||||
{
|
||||
int i = index.frontCasted<int>();
|
||||
const int i = index.frontCasted<int>();
|
||||
return (i >= static_cast<int>(IndexLatitude)) && (i <= static_cast<int>(IndexNormalVector));
|
||||
}
|
||||
|
||||
@@ -92,22 +92,14 @@ namespace BlackMisc
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexLatitude:
|
||||
return this->latitude().propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexLongitude:
|
||||
return this->longitude().propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexLatitudeAsString:
|
||||
return CVariant(this->latitudeAsString());
|
||||
case IndexLongitudeAsString:
|
||||
return CVariant(this->longitudeAsString());
|
||||
case IndexGeodeticHeight:
|
||||
return this->geodeticHeight().propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexGeodeticHeightAsString:
|
||||
return CVariant(this->geodeticHeightAsString());
|
||||
case IndexNormalVector:
|
||||
return CVariant::fromValue(this->normalVector());
|
||||
default:
|
||||
break;
|
||||
case IndexLatitude: return this->latitude().propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexLongitude: return this->longitude().propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexLatitudeAsString: return CVariant(this->latitudeAsString());
|
||||
case IndexLongitudeAsString: return CVariant(this->longitudeAsString());
|
||||
case IndexGeodeticHeight: return this->geodeticHeight().propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexGeodeticHeightAsString: return CVariant(this->geodeticHeightAsString());
|
||||
case IndexNormalVector: return CVariant::fromValue(this->normalVector());
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,20 +115,13 @@ namespace BlackMisc
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexLatitude:
|
||||
return this->latitude().comparePropertyByIndex(index.copyFrontRemoved(), compareValue.latitude());
|
||||
case IndexLongitude:
|
||||
return this->longitude().comparePropertyByIndex(index.copyFrontRemoved(), compareValue.longitude());
|
||||
case IndexLatitudeAsString:
|
||||
return this->latitudeAsString().compare(compareValue.latitudeAsString());
|
||||
case IndexLongitudeAsString:
|
||||
return this->longitudeAsString().compare(compareValue.longitudeAsString());
|
||||
case IndexGeodeticHeight:
|
||||
return this->geodeticHeight().comparePropertyByIndex(index.copyFrontRemoved(), compareValue.geodeticHeight());
|
||||
case IndexGeodeticHeightAsString:
|
||||
return this->geodeticHeightAsString().compare(compareValue.geodeticHeightAsString());
|
||||
default:
|
||||
break;
|
||||
case IndexLatitude: return this->latitude().comparePropertyByIndex(index.copyFrontRemoved(), compareValue.latitude());
|
||||
case IndexLongitude: return this->longitude().comparePropertyByIndex(index.copyFrontRemoved(), compareValue.longitude());
|
||||
case IndexLatitudeAsString: return this->latitudeAsString().compare(compareValue.latitudeAsString());
|
||||
case IndexLongitudeAsString: return this->longitudeAsString().compare(compareValue.longitudeAsString());
|
||||
case IndexGeodeticHeight: return this->geodeticHeight().comparePropertyByIndex(index.copyFrontRemoved(), compareValue.geodeticHeight());
|
||||
case IndexGeodeticHeightAsString: return this->geodeticHeightAsString().compare(compareValue.geodeticHeightAsString());
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -173,7 +158,7 @@ namespace BlackMisc
|
||||
switch (i)
|
||||
{
|
||||
case IndexGeodeticHeight:
|
||||
this->m_geodeticHeight.setPropertyByIndex(index.copyFrontRemoved(), variant);
|
||||
m_geodeticHeight.setPropertyByIndex(index.copyFrontRemoved(), variant);
|
||||
break;
|
||||
case IndexLatitude:
|
||||
this->setLatitude(variant.value<CLatitude>());
|
||||
@@ -188,7 +173,7 @@ namespace BlackMisc
|
||||
this->setLongitude(CLongitude::fromWgs84(variant.toQString()));
|
||||
break;
|
||||
case IndexGeodeticHeightAsString:
|
||||
this->m_geodeticHeight.parseFromString(variant.toQString());
|
||||
m_geodeticHeight.parseFromString(variant.toQString());
|
||||
break;
|
||||
case IndexNormalVector:
|
||||
this->setNormalVector(variant.value<QVector3D>());
|
||||
@@ -226,6 +211,7 @@ namespace BlackMisc
|
||||
|
||||
CLongitude CCoordinateGeodetic::longitude() const
|
||||
{
|
||||
// in mathematics atan2 of 0,0 is undefined, with IEEE floating-point atan2(0,0) is either 0 or ±180°
|
||||
return { std::atan2(m_y, m_x), PhysicalQuantities::CAngleUnit::rad() };
|
||||
}
|
||||
|
||||
@@ -233,15 +219,15 @@ namespace BlackMisc
|
||||
{
|
||||
return
|
||||
{
|
||||
static_cast<float>(this->m_x),
|
||||
static_cast<float>(this->m_y),
|
||||
static_cast<float>(this->m_z)
|
||||
static_cast<float>(m_x),
|
||||
static_cast<float>(m_y),
|
||||
static_cast<float>(m_z)
|
||||
};
|
||||
}
|
||||
|
||||
std::array<double, 3> CCoordinateGeodetic::normalVectorDouble() const
|
||||
{
|
||||
return { { this->m_x, this->m_y, this->m_z } };
|
||||
return { { m_x, m_y, m_z } };
|
||||
}
|
||||
|
||||
void CCoordinateGeodetic::setLatitude(const CLatitude &latitude)
|
||||
@@ -256,28 +242,28 @@ namespace BlackMisc
|
||||
|
||||
void CCoordinateGeodetic::setLatLong(const CLatitude &latitude, const CLongitude &longitude)
|
||||
{
|
||||
this->m_x = latitude.cos() * longitude.cos();
|
||||
this->m_y = latitude.cos() * longitude.sin();
|
||||
this->m_z = latitude.sin();
|
||||
m_x = latitude.cos() * longitude.cos();
|
||||
m_y = latitude.cos() * longitude.sin();
|
||||
m_z = latitude.sin();
|
||||
}
|
||||
|
||||
CCoordinateGeodetic &CCoordinateGeodetic::switchUnit(const CLengthUnit &unit)
|
||||
{
|
||||
this->m_geodeticHeight.switchUnit(unit);
|
||||
m_geodeticHeight.switchUnit(unit);
|
||||
return *this;
|
||||
}
|
||||
|
||||
CLength ICoordinateWithRelativePosition::calculcateAndUpdateRelativeDistance(const ICoordinateGeodetic &position)
|
||||
{
|
||||
this->m_relativeDistance = Geo::calculateGreatCircleDistance(*this, position);
|
||||
return this->m_relativeDistance;
|
||||
m_relativeDistance = Geo::calculateGreatCircleDistance(*this, position);
|
||||
return m_relativeDistance;
|
||||
}
|
||||
|
||||
CLength ICoordinateWithRelativePosition::calculcateAndUpdateRelativeDistanceAndBearing(const ICoordinateGeodetic &position)
|
||||
{
|
||||
this->m_relativeDistance = Geo::calculateGreatCircleDistance(*this, position);
|
||||
this->m_relativeBearing = Geo::calculateBearing(*this, position);
|
||||
return this->m_relativeDistance;
|
||||
m_relativeDistance = Geo::calculateGreatCircleDistance(*this, position);
|
||||
m_relativeBearing = Geo::calculateBearing(*this, position);
|
||||
return m_relativeDistance;
|
||||
}
|
||||
|
||||
CVariant ICoordinateWithRelativePosition::propertyByIndex(const CPropertyIndex &index) const
|
||||
@@ -288,12 +274,9 @@ namespace BlackMisc
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexRelativeBearing:
|
||||
return this->getRelativeBearing().propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexRelativeDistance:
|
||||
return this->getRelativeDistance().propertyByIndex(index.copyFrontRemoved());
|
||||
default:
|
||||
break;
|
||||
case IndexRelativeBearing: return this->getRelativeBearing().propertyByIndex(index.copyFrontRemoved());
|
||||
case IndexRelativeDistance: return this->getRelativeDistance().propertyByIndex(index.copyFrontRemoved());
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
const QString m = QString("no property, index ").append(index.toQString());
|
||||
@@ -310,10 +293,10 @@ namespace BlackMisc
|
||||
switch (i)
|
||||
{
|
||||
case IndexRelativeBearing:
|
||||
this->m_relativeBearing.setPropertyByIndex(index.copyFrontRemoved(), variant);
|
||||
m_relativeBearing.setPropertyByIndex(index.copyFrontRemoved(), variant);
|
||||
break;
|
||||
case IndexRelativeDistance:
|
||||
this->m_relativeDistance.setPropertyByIndex(index.copyFrontRemoved(), variant);
|
||||
m_relativeDistance.setPropertyByIndex(index.copyFrontRemoved(), variant);
|
||||
break;
|
||||
default:
|
||||
const QString m = QString("no property, index ").append(index.toQString());
|
||||
@@ -331,10 +314,8 @@ namespace BlackMisc
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexRelativeBearing:
|
||||
return this->m_relativeBearing.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getRelativeBearing());
|
||||
case IndexRelativeDistance:
|
||||
return this->m_relativeDistance.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getRelativeDistance());
|
||||
case IndexRelativeBearing: return m_relativeBearing.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getRelativeBearing());
|
||||
case IndexRelativeDistance: return m_relativeDistance.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getRelativeDistance());
|
||||
default:
|
||||
const QString m = QString("no property, index ").append(index.toQString());
|
||||
Q_ASSERT_X(false, Q_FUNC_INFO, m.toLocal8Bit().constData());
|
||||
@@ -357,7 +338,7 @@ namespace BlackMisc
|
||||
bool ICoordinateWithRelativePosition::canHandleIndex(const CPropertyIndex &index)
|
||||
{
|
||||
if (ICoordinateGeodetic::canHandleIndex(index)) { return true; }
|
||||
int i = index.frontCasted<int>();
|
||||
const int i = index.frontCasted<int>();
|
||||
return (i >= static_cast<int>(IndexRelativeDistance)) && (i <= static_cast<int>(IndexRelativeBearing));
|
||||
}
|
||||
} // namespace
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace BlackMisc
|
||||
//! Properties by index
|
||||
enum ColumnIndex
|
||||
{
|
||||
IndexLatitude = BlackMisc::CPropertyIndex::GlobalIndexICoordinateGeodetic,
|
||||
IndexLatitude = CPropertyIndex::GlobalIndexICoordinateGeodetic,
|
||||
IndexLongitude,
|
||||
IndexLatitudeAsString,
|
||||
IndexLongitudeAsString,
|
||||
@@ -72,7 +72,7 @@ namespace BlackMisc
|
||||
//! By a similar convention, "elevation" is commonly used for objects that are fixed to the ground.
|
||||
//! \sa see http://www.gmat.unsw.edu.au/snap/gps/clynch_pdfs/coordcvt.pdf page 5
|
||||
//! \sa http://www.esri.com/news/arcuser/0703/geoid1of3.html
|
||||
virtual const BlackMisc::Aviation::CAltitude &geodeticHeight() const = 0;
|
||||
virtual const Aviation::CAltitude &geodeticHeight() const = 0;
|
||||
|
||||
//! Normal vector
|
||||
//! \note QVector3D uses floats, so don't use if double precision is needed
|
||||
@@ -92,31 +92,34 @@ namespace BlackMisc
|
||||
//! Height as string
|
||||
QString geodeticHeightAsString() const { return this->geodeticHeight().toQString(true); }
|
||||
|
||||
//! Geodetic height null?
|
||||
bool isGeodeticHeightNull() { return this->geodeticHeight().isNull(); }
|
||||
|
||||
//! Great circle distance
|
||||
BlackMisc::PhysicalQuantities::CLength calculateGreatCircleDistance(const ICoordinateGeodetic &otherCoordinate) const;
|
||||
PhysicalQuantities::CLength calculateGreatCircleDistance(const ICoordinateGeodetic &otherCoordinate) const;
|
||||
|
||||
//! Initial bearing
|
||||
BlackMisc::PhysicalQuantities::CAngle calculateBearing(const ICoordinateGeodetic &otherCoordinate) const;
|
||||
PhysicalQuantities::CAngle calculateBearing(const ICoordinateGeodetic &otherCoordinate) const;
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::Index::propertyByIndex
|
||||
CVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const;
|
||||
//! \copydoc Mixin::Index::propertyByIndex
|
||||
CVariant propertyByIndex(const CPropertyIndex &index) const;
|
||||
|
||||
//! Compare by index
|
||||
int comparePropertyByIndex(const CPropertyIndex &index, const ICoordinateGeodetic &compareValue) const;
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::String::toQString
|
||||
//! \copydoc Mixin::String::toQString
|
||||
QString convertToQString(bool i18n = false) const;
|
||||
|
||||
protected:
|
||||
//! Can given index be handled?
|
||||
static bool canHandleIndex(const BlackMisc::CPropertyIndex &index);
|
||||
static bool canHandleIndex(const CPropertyIndex &index);
|
||||
};
|
||||
|
||||
//! Great circle distance between points
|
||||
BLACKMISC_EXPORT BlackMisc::PhysicalQuantities::CLength calculateGreatCircleDistance(const ICoordinateGeodetic &coordinate1, const ICoordinateGeodetic &coordinate2);
|
||||
BLACKMISC_EXPORT PhysicalQuantities::CLength calculateGreatCircleDistance(const ICoordinateGeodetic &coordinate1, const ICoordinateGeodetic &coordinate2);
|
||||
|
||||
//! Initial bearing
|
||||
BLACKMISC_EXPORT BlackMisc::PhysicalQuantities::CAngle calculateBearing(const ICoordinateGeodetic &coordinate1, const ICoordinateGeodetic &coordinate2);
|
||||
BLACKMISC_EXPORT PhysicalQuantities::CAngle calculateBearing(const ICoordinateGeodetic &coordinate1, const ICoordinateGeodetic &coordinate2);
|
||||
|
||||
//! Euclidean distance between normal vectors
|
||||
BLACKMISC_EXPORT double calculateEuclideanDistance(const ICoordinateGeodetic &coordinate1, const ICoordinateGeodetic &coordinate2);
|
||||
@@ -131,44 +134,44 @@ namespace BlackMisc
|
||||
//! Properties by index
|
||||
enum ColumnIndex
|
||||
{
|
||||
IndexRelativeDistance = BlackMisc::CPropertyIndex::GlobalIndexICoordinateWithRelativePosition,
|
||||
IndexRelativeDistance = CPropertyIndex::GlobalIndexICoordinateWithRelativePosition,
|
||||
IndexRelativeBearing
|
||||
};
|
||||
|
||||
//! Get the distance
|
||||
const BlackMisc::PhysicalQuantities::CLength &getRelativeDistance() const { return m_relativeDistance; }
|
||||
const PhysicalQuantities::CLength &getRelativeDistance() const { return m_relativeDistance; }
|
||||
|
||||
//! Set relative distance
|
||||
void setRelativeDistance(const BlackMisc::PhysicalQuantities::CLength &distance) { this->m_relativeDistance = distance; }
|
||||
void setRelativeDistance(const PhysicalQuantities::CLength &distance) { m_relativeDistance = distance; }
|
||||
|
||||
//! Get the relative bearing
|
||||
const BlackMisc::PhysicalQuantities::CAngle &getRelativeBearing() const { return m_relativeBearing; }
|
||||
const PhysicalQuantities::CAngle &getRelativeBearing() const { return m_relativeBearing; }
|
||||
|
||||
//! Set bearing to own plane
|
||||
void setRelativeBearing(const BlackMisc::PhysicalQuantities::CAngle &angle) { this->m_relativeBearing = angle; }
|
||||
void setRelativeBearing(const PhysicalQuantities::CAngle &angle) { m_relativeBearing = angle; }
|
||||
|
||||
//! Valid distance?
|
||||
bool hasValidRelativeDistance() const { return !this->m_relativeDistance.isNull();}
|
||||
bool hasValidRelativeDistance() const { return !m_relativeDistance.isNull();}
|
||||
|
||||
//! Valid bearing?
|
||||
bool hasValidRelativeBearing() const { return !this->m_relativeBearing.isNull();}
|
||||
bool hasValidRelativeBearing() const { return !m_relativeBearing.isNull();}
|
||||
|
||||
//! Calculcate distance, set it, and return distance
|
||||
BlackMisc::PhysicalQuantities::CLength calculcateAndUpdateRelativeDistance(const BlackMisc::Geo::ICoordinateGeodetic &position);
|
||||
PhysicalQuantities::CLength calculcateAndUpdateRelativeDistance(const Geo::ICoordinateGeodetic &position);
|
||||
|
||||
//! Calculcate distance and bearing to plane, set it, and return distance
|
||||
BlackMisc::PhysicalQuantities::CLength calculcateAndUpdateRelativeDistanceAndBearing(const BlackMisc::Geo::ICoordinateGeodetic &position);
|
||||
PhysicalQuantities::CLength calculcateAndUpdateRelativeDistanceAndBearing(const Geo::ICoordinateGeodetic &position);
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::Index::propertyByIndex
|
||||
CVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const;
|
||||
//! \copydoc Mixin::Index::propertyByIndex
|
||||
CVariant propertyByIndex(const CPropertyIndex &index) const;
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::Index::setPropertyByIndex
|
||||
void setPropertyByIndex(const BlackMisc::CPropertyIndex &index, const CVariant &variant);
|
||||
//! \copydoc Mixin::Index::setPropertyByIndex
|
||||
void setPropertyByIndex(const CPropertyIndex &index, const CVariant &variant);
|
||||
|
||||
//! Compare by index
|
||||
int comparePropertyByIndex(const CPropertyIndex &index, const ICoordinateWithRelativePosition &compareValue) const;
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::String::toQString
|
||||
//! \copydoc Mixin::String::toQString
|
||||
QString convertToQString(bool i18n = false) const;
|
||||
|
||||
protected:
|
||||
@@ -176,10 +179,10 @@ namespace BlackMisc
|
||||
ICoordinateWithRelativePosition();
|
||||
|
||||
//! Can given index be handled?
|
||||
static bool canHandleIndex(const BlackMisc::CPropertyIndex &index);
|
||||
static bool canHandleIndex(const CPropertyIndex &index);
|
||||
|
||||
BlackMisc::PhysicalQuantities::CAngle m_relativeBearing { 0, nullptr }; //!< temporary stored value
|
||||
BlackMisc::PhysicalQuantities::CLength m_relativeDistance { 0, nullptr }; //!< temporary stored value
|
||||
PhysicalQuantities::CAngle m_relativeBearing { 0, nullptr }; //!< temporary stored value
|
||||
PhysicalQuantities::CLength m_relativeDistance { 0, nullptr }; //!< temporary stored value
|
||||
};
|
||||
|
||||
//! Geodetic coordinate
|
||||
@@ -193,7 +196,7 @@ namespace BlackMisc
|
||||
CCoordinateGeodetic(const QVector3D &normal) : m_x(normal.x()), m_y(normal.y()), m_z(normal.z()) {}
|
||||
|
||||
//! Constructor by values
|
||||
CCoordinateGeodetic(const CLatitude &latitude, const CLongitude &longitude, const BlackMisc::Aviation::CAltitude &geodeticHeight);
|
||||
CCoordinateGeodetic(const CLatitude &latitude, const CLongitude &longitude, const Aviation::CAltitude &geodeticHeight);
|
||||
|
||||
//! Constructor by double values, but no geodetic height
|
||||
CCoordinateGeodetic(double latitudeDegrees, double longitudeDegrees);
|
||||
@@ -211,7 +214,7 @@ namespace BlackMisc
|
||||
virtual CLongitude longitude() const override;
|
||||
|
||||
//! \copydoc ICoordinateGeodetic::geodeticHeight
|
||||
virtual const BlackMisc::Aviation::CAltitude &geodeticHeight() const override { return this->m_geodeticHeight; }
|
||||
virtual const Aviation::CAltitude &geodeticHeight() const override { return m_geodeticHeight; }
|
||||
|
||||
//! \copydoc ICoordinateGeodetic::normalVector
|
||||
virtual QVector3D normalVector() const override;
|
||||
@@ -219,14 +222,14 @@ namespace BlackMisc
|
||||
//! \copydoc ICoordinateGeodetic::normalVectorDouble
|
||||
virtual std::array<double, 3> normalVectorDouble() const override;
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::Index::propertyByIndex
|
||||
CVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const;
|
||||
//! \copydoc Mixin::Index::propertyByIndex
|
||||
CVariant propertyByIndex(const CPropertyIndex &index) const;
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::Index::setPropertyByIndex
|
||||
void setPropertyByIndex(const BlackMisc::CPropertyIndex &index, const CVariant &variant);
|
||||
//! \copydoc Mixin::Index::setPropertyByIndex
|
||||
void setPropertyByIndex(const CPropertyIndex &index, const CVariant &variant);
|
||||
|
||||
//! Switch unit of height
|
||||
CCoordinateGeodetic &switchUnit(const BlackMisc::PhysicalQuantities::CLengthUnit &unit);
|
||||
CCoordinateGeodetic &switchUnit(const PhysicalQuantities::CLengthUnit &unit);
|
||||
|
||||
//! Set latitude
|
||||
void setLatitude(const CLatitude &latitude);
|
||||
@@ -238,25 +241,28 @@ namespace BlackMisc
|
||||
void setLatLong(const CLatitude &latitude, const CLongitude &longitude);
|
||||
|
||||
//! Set height (ellipsoidal or geodetic height)
|
||||
void setGeodeticHeight(const BlackMisc::Aviation::CAltitude &height) { this->m_geodeticHeight = height; }
|
||||
void setGeodeticHeight(const Aviation::CAltitude &height) { m_geodeticHeight = height; }
|
||||
|
||||
//! Set normal vector
|
||||
void setNormalVector(const QVector3D &normal) { this->m_x = normal.x(); this->m_y = normal.y(); this->m_z = normal.z(); }
|
||||
void setNormalVector(const QVector3D &normal) { m_x = normal.x(); m_y = normal.y(); m_z = normal.z(); }
|
||||
|
||||
//! Set normal vector
|
||||
void setNormalVector(double x, double y, double z) { this->m_x = x; this->m_y = y; this->m_z = z; }
|
||||
void setNormalVector(double x, double y, double z) { m_x = x; m_y = y; m_z = z; }
|
||||
|
||||
//! Coordinate by WGS84 position data
|
||||
static CCoordinateGeodetic fromWgs84(const QString &latitudeWgs84, const QString &longitudeWgs84, const BlackMisc::Aviation::CAltitude &geodeticHeight = {});
|
||||
static CCoordinateGeodetic fromWgs84(const QString &latitudeWgs84, const QString &longitudeWgs84, const Aviation::CAltitude &geodeticHeight = {});
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::String::toQString
|
||||
//! \copydoc Mixin::String::toQString
|
||||
QString convertToQString(bool i18n = false) const;
|
||||
|
||||
private:
|
||||
double m_x = 0; //!< normal vector
|
||||
double m_y = 0; //!< normal vector
|
||||
double m_z = 0; //!< normal vector
|
||||
BlackMisc::Aviation::CAltitude m_geodeticHeight { 0, nullptr }; //!< height, ellipsoidal or geodetic height
|
||||
// Coordinates are stored using `double` internally and use `double` for most calculations.
|
||||
// They use `double` when converting to and from lat/lon representation.
|
||||
// `QVector3D` is only used for calculating distance and bearing.
|
||||
double m_x = 0; //!< normal vector [-1,1]
|
||||
double m_y = 0; //!< normal vector [-1,1]
|
||||
double m_z = 0; //!< normal vector [-1,1]
|
||||
Aviation::CAltitude m_geodeticHeight { 0, nullptr }; //!< height, ellipsoidal or geodetic height
|
||||
|
||||
BLACK_METACLASS(
|
||||
CCoordinateGeodetic,
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "blackmisc/pq/units.h"
|
||||
#include "blackmisc/sequence.h"
|
||||
|
||||
#include <QStringBuilder>
|
||||
#include <QtGlobal>
|
||||
|
||||
namespace BlackMisc
|
||||
@@ -30,7 +31,7 @@ namespace BlackMisc
|
||||
|
||||
CIcons::IconIndex CIcon::getIndex() const
|
||||
{
|
||||
return this->m_index;
|
||||
return m_index;
|
||||
}
|
||||
|
||||
bool CIcon::isIndexBased() const
|
||||
@@ -40,17 +41,17 @@ namespace BlackMisc
|
||||
|
||||
bool CIcon::isGenerated() const
|
||||
{
|
||||
return getIndex() == CIcons::IconIsGenerated;
|
||||
return this->getIndex() == CIcons::IconIsGenerated;
|
||||
}
|
||||
|
||||
bool CIcon::isFileBased() const
|
||||
{
|
||||
return getIndex() == CIcons::IconIsFile;
|
||||
return this->getIndex() == CIcons::IconIsFile;
|
||||
}
|
||||
|
||||
bool CIcon::isSet() const
|
||||
{
|
||||
return (this->m_index != CIcons::NotSet);
|
||||
return (m_index != CIcons::NotSet);
|
||||
}
|
||||
|
||||
QPixmap CIcon::toPixmap() const
|
||||
@@ -59,7 +60,7 @@ namespace BlackMisc
|
||||
{
|
||||
if (this->isGenerated()) { return m_pixmap; }
|
||||
if (this->isFileBased()) { return m_pixmap; }
|
||||
return CIcons::pixmapByIndex(getIndex(), this->m_rotateDegrees);
|
||||
return CIcons::pixmapByIndex(getIndex(), m_rotateDegrees);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -74,13 +75,13 @@ namespace BlackMisc
|
||||
|
||||
void CIcon::setRotation(const PhysicalQuantities::CAngle &rotate)
|
||||
{
|
||||
this->m_rotateDegrees = static_cast<int>(rotate.valueRounded(PhysicalQuantities::CAngleUnit::deg(), 0));
|
||||
m_rotateDegrees = static_cast<int>(rotate.valueRounded(PhysicalQuantities::CAngleUnit::deg(), 0));
|
||||
}
|
||||
|
||||
QString CIcon::convertToQString(bool i18n) const
|
||||
{
|
||||
Q_UNUSED(i18n);
|
||||
QString s = QString(this->m_descriptiveText).append(" ").append(this->m_index);
|
||||
const QString s = m_descriptiveText % QStringLiteral(" ") % QString::number(m_index);
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
@@ -180,23 +180,16 @@ namespace BlackMisc
|
||||
CVariant CInterpolationAndRenderingSetup::propertyByIndex(const BlackMisc::CPropertyIndex &index) const
|
||||
{
|
||||
if (index.isMyself()) { return CVariant::from(*this); }
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexInterpolatorDebugMessages:
|
||||
return CVariant::fromValue(m_interpolatorDebugMessage);
|
||||
case IndexSimulatorDebugMessages:
|
||||
return CVariant::fromValue(m_simulatorDebugMessages);
|
||||
case IndexForceFullInterpolation:
|
||||
return CVariant::fromValue(m_forceFullInterpolation);
|
||||
case IndexMaxRenderedAircraft:
|
||||
return CVariant::fromValue(m_maxRenderedAircraft);
|
||||
case IndexMaxRenderedDistance:
|
||||
return CVariant::fromValue(m_maxRenderedDistance);
|
||||
case IndexEnabledAircraftParts:
|
||||
return CVariant::fromValue(m_enabledAircraftParts);
|
||||
default:
|
||||
return CValueObject::propertyByIndex(index);
|
||||
case IndexInterpolatorDebugMessages: return CVariant::fromValue(m_interpolatorDebugMessage);
|
||||
case IndexSimulatorDebugMessages: return CVariant::fromValue(m_simulatorDebugMessages);
|
||||
case IndexForceFullInterpolation: return CVariant::fromValue(m_forceFullInterpolation);
|
||||
case IndexMaxRenderedAircraft: return CVariant::fromValue(m_maxRenderedAircraft);
|
||||
case IndexMaxRenderedDistance: return CVariant::fromValue(m_maxRenderedDistance);
|
||||
case IndexEnabledAircraftParts: return CVariant::fromValue(m_enabledAircraftParts);
|
||||
default: return CValueObject::propertyByIndex(index);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -207,30 +200,16 @@ namespace BlackMisc
|
||||
*this = variant.value<CInterpolationAndRenderingSetup>();
|
||||
return;
|
||||
}
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexInterpolatorDebugMessages:
|
||||
m_interpolatorDebugMessage = variant.toBool();
|
||||
break;
|
||||
case IndexSimulatorDebugMessages:
|
||||
m_simulatorDebugMessages = variant.toBool();
|
||||
break;
|
||||
case IndexForceFullInterpolation:
|
||||
m_forceFullInterpolation = variant.toBool();
|
||||
break;
|
||||
case IndexMaxRenderedAircraft:
|
||||
m_maxRenderedAircraft = variant.toInt();
|
||||
break;
|
||||
case IndexMaxRenderedDistance:
|
||||
m_maxRenderedDistance = variant.value<CLength>();
|
||||
break;
|
||||
case IndexEnabledAircraftParts:
|
||||
m_enabledAircraftParts = variant.toBool();
|
||||
break;
|
||||
default:
|
||||
CValueObject::setPropertyByIndex(index, variant);
|
||||
break;
|
||||
case IndexInterpolatorDebugMessages: m_interpolatorDebugMessage = variant.toBool(); break;
|
||||
case IndexSimulatorDebugMessages: m_simulatorDebugMessages = variant.toBool(); break;
|
||||
case IndexForceFullInterpolation: m_forceFullInterpolation = variant.toBool(); break;
|
||||
case IndexMaxRenderedAircraft: m_maxRenderedAircraft = variant.toInt(); break;
|
||||
case IndexMaxRenderedDistance: m_maxRenderedDistance = variant.value<CLength>(); break;
|
||||
case IndexEnabledAircraftParts: m_enabledAircraftParts = variant.toBool(); break;
|
||||
default: CValueObject::setPropertyByIndex(index, variant); break;
|
||||
}
|
||||
}
|
||||
} // ns
|
||||
|
||||
@@ -127,9 +127,9 @@ namespace BlackMisc
|
||||
|
||||
private:
|
||||
bool m_interpolatorDebugMessage = false; //! Debug messages in interpolator
|
||||
bool m_simulatorDebugMessages = false; //! Debug messages of simulator (aka plugin)
|
||||
bool m_forceFullInterpolation = false; //! always do a full interpolation, even if aircraft is not moving
|
||||
bool m_enabledAircraftParts = true; //! Update aircraft parts
|
||||
bool m_simulatorDebugMessages = false; //! Debug messages of simulator (aka plugin)
|
||||
bool m_forceFullInterpolation = false; //! always do a full interpolation, even if aircraft is not moving
|
||||
bool m_enabledAircraftParts = true; //! Update aircraft parts
|
||||
int m_maxRenderedAircraft = InfiniteAircraft(); //!< max.rendered aircraft
|
||||
BlackMisc::PhysicalQuantities::CLength m_maxRenderedDistance { 0, nullptr }; //!< max.distance for rendering
|
||||
BlackMisc::Aviation::CCallsignSet m_callsignsToLog;
|
||||
|
||||
@@ -24,7 +24,9 @@ namespace BlackMisc
|
||||
{}
|
||||
|
||||
BlackMisc::Aviation::CAircraftSituation CInterpolatorMulti::getInterpolatedSituation(
|
||||
qint64 currentTimeSinceEpoc, const CInterpolationAndRenderingSetup &setup, const CInterpolationHints &hints, CInterpolationStatus &status)
|
||||
qint64 currentTimeSinceEpoc,
|
||||
const CInterpolationAndRenderingSetup &setup,
|
||||
const CInterpolationHints &hints, CInterpolationStatus &status)
|
||||
{
|
||||
switch (m_mode)
|
||||
{
|
||||
|
||||
@@ -32,12 +32,14 @@ namespace BlackMisc
|
||||
|
||||
//! \copydoc CInterpolator::getInterpolatedSituation
|
||||
BlackMisc::Aviation::CAircraftSituation getInterpolatedSituation(
|
||||
qint64 currentTimeSinceEpoc, const CInterpolationAndRenderingSetup &setup,
|
||||
qint64 currentTimeSinceEpoc,
|
||||
const CInterpolationAndRenderingSetup &setup,
|
||||
const CInterpolationHints &hints, CInterpolationStatus &status);
|
||||
|
||||
//! \copydoc CInterpolator::getInterpolatedParts
|
||||
BlackMisc::Aviation::CAircraftParts getInterpolatedParts(
|
||||
qint64 currentTimeSinceEpoc, const CInterpolationAndRenderingSetup &setup,
|
||||
qint64 currentTimeSinceEpoc,
|
||||
const CInterpolationAndRenderingSetup &setup,
|
||||
CPartsStatus &partsStatus, bool log = false);
|
||||
|
||||
//! \copydoc CInterpolator::addAircraftSituation
|
||||
|
||||
Reference in New Issue
Block a user