mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-03 07:35:48 +08:00
Handled some potentially "dangerous" parsing issues for VATSIM file (no coordinate)
https://discordapp.com/channels/539048679160676382/539486489977946112/593081121512751116
This commit is contained in:
committed by
Mat Sutcliffe
parent
b2b85795e0
commit
4ecd8a78ad
@@ -40,6 +40,12 @@ namespace BlackMisc
|
||||
return CCoordinateGeodetic(lat, lon, geodeticHeight);
|
||||
}
|
||||
|
||||
const CCoordinateGeodetic &CCoordinateGeodetic::null()
|
||||
{
|
||||
static const CCoordinateGeodetic n;
|
||||
return n;
|
||||
}
|
||||
|
||||
CLength calculateGreatCircleDistance(const ICoordinateGeodetic &coordinate1, const ICoordinateGeodetic &coordinate2)
|
||||
{
|
||||
if (coordinate1.isNull() || coordinate2.isNull()) { return CLength::null(); }
|
||||
@@ -177,10 +183,10 @@ namespace BlackMisc
|
||||
const CLatitude lat = this->latitude();
|
||||
const CLongitude lng = this->longitude();
|
||||
return QStringLiteral("Geodetic: {%1/%2, %3/%4, %5}").arg(lat.valueRoundedWithUnit(CAngleUnit::deg(), 6, i18n),
|
||||
lat.valueRoundedWithUnit(CAngleUnit::rad(), 6, i18n),
|
||||
lng.valueRoundedWithUnit(CAngleUnit::deg(), 6, i18n),
|
||||
lng.valueRoundedWithUnit(CAngleUnit::rad(), 6, i18n),
|
||||
this->geodeticHeight().valueRoundedWithUnit(CLengthUnit::ft(), 2, i18n));
|
||||
lat.valueRoundedWithUnit(CAngleUnit::rad(), 6, i18n),
|
||||
lng.valueRoundedWithUnit(CAngleUnit::deg(), 6, i18n),
|
||||
lng.valueRoundedWithUnit(CAngleUnit::rad(), 6, i18n),
|
||||
this->geodeticHeight().valueRoundedWithUnit(CLengthUnit::ft(), 2, i18n));
|
||||
}
|
||||
|
||||
bool ICoordinateGeodetic::isNaNVector() const
|
||||
|
||||
@@ -314,6 +314,9 @@ namespace BlackMisc
|
||||
//! Coordinate by WGS84 position data
|
||||
static CCoordinateGeodetic fromWgs84(const QString &latitudeWgs84, const QString &longitudeWgs84, const Aviation::CAltitude &geodeticHeight = {});
|
||||
|
||||
//! null coordinate
|
||||
static const CCoordinateGeodetic &null();
|
||||
|
||||
//! \copydoc Mixin::String::toQString
|
||||
QString convertToQString(bool i18n = false) const;
|
||||
|
||||
|
||||
@@ -251,9 +251,17 @@ namespace BlackMisc
|
||||
template <class MU, class PQ>
|
||||
PQ &CPhysicalQuantity<MU, PQ>::switchUnit(const MU &newUnit)
|
||||
{
|
||||
// NULL check: https://discordapp.com/channels/539048679160676382/539925070550794240/593151683698229258
|
||||
if (m_unit == newUnit || this->isNull()) { return *derived(); }
|
||||
m_value = newUnit.convertFrom(m_value, m_unit);
|
||||
m_unit = newUnit;
|
||||
if (newUnit.isNull())
|
||||
{
|
||||
this->setNull();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_value = newUnit.convertFrom(m_value, m_unit);
|
||||
m_unit = newUnit;
|
||||
}
|
||||
return *derived();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user