mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-26 02:35:38 +08:00
Tweaks
* formatting * default digits for PQs * improved toQString in altitude / aircraft situation / coordinate
This commit is contained in:
@@ -19,7 +19,7 @@ namespace BlackMisc
|
|||||||
s.append(" pitch: ").append(this->m_pitch.toQString(i18n));
|
s.append(" pitch: ").append(this->m_pitch.toQString(i18n));
|
||||||
s.append(" gs: ").append(this->m_groundspeed.toQString(i18n));
|
s.append(" gs: ").append(this->m_groundspeed.toQString(i18n));
|
||||||
s.append(" heading: ").append(this->m_heading.toQString(i18n));
|
s.append(" heading: ").append(this->m_heading.toQString(i18n));
|
||||||
s.append(" ts: ").append(this->m_timestamp.toString("dd hh:mm:ss"));
|
s.append(" timestamp: ").append(this->m_timestamp.toString("dd hh:mm:ss"));
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,11 @@ namespace BlackMisc
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QString s = this->CLength::valueRoundedWithUnit(CLengthUnit::ft(), i18n);
|
QString s = this->CLength::valueRoundedWithUnit(4, i18n);
|
||||||
|
if (this->getUnit() != CLengthUnit::ft())
|
||||||
|
{
|
||||||
|
s.append(" (").append(this->valueRoundedWithUnit(CLengthUnit::ft(), 4, i18n)).append(")");
|
||||||
|
}
|
||||||
return s.append(this->isMeanSeaLevel() ? " MSL" : " AGL");
|
return s.append(this->isMeanSeaLevel() ? " MSL" : " AGL");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ namespace BlackMisc
|
|||||||
QString CCoordinateGeodetic::convertToQString(bool i18n) const
|
QString CCoordinateGeodetic::convertToQString(bool i18n) const
|
||||||
{
|
{
|
||||||
QString s = "Geodetic: {%1, %2, %3}";
|
QString s = "Geodetic: {%1, %2, %3}";
|
||||||
return s.arg(this->m_latitude.valueRoundedWithUnit(6, i18n)).arg(this->m_longitude.valueRoundedWithUnit(6, i18n)).arg(this->m_height.valueRoundedWithUnit(i18n));
|
return s.arg(this->m_latitude.valueRoundedWithUnit(6, i18n)).arg(this->m_longitude.valueRoundedWithUnit(6, i18n)).arg(this->m_height.valueRoundedWithUnit(6, i18n));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -18,37 +18,25 @@ namespace BlackMisc
|
|||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Latitude and longitude interface
|
* Latitude and longitude interface
|
||||||
* \brief Interface for geodetic ccordinates
|
* Interface for geodetic ccordinates
|
||||||
*/
|
*/
|
||||||
class ICoordinateGeodetic
|
class ICoordinateGeodetic
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/*!
|
//! Latitude
|
||||||
* \brief Latitude
|
|
||||||
* \return
|
|
||||||
*/
|
|
||||||
virtual const CLatitude &latitude() const = 0;
|
virtual const CLatitude &latitude() const = 0;
|
||||||
|
|
||||||
/*!
|
//! Longitude
|
||||||
* \brief Longitude
|
|
||||||
* \return
|
|
||||||
*/
|
|
||||||
virtual const CLongitude &longitude() const = 0;
|
virtual const CLongitude &longitude() const = 0;
|
||||||
|
|
||||||
/*!
|
//! Latitude as string
|
||||||
* \brief As string
|
|
||||||
* \return
|
|
||||||
*/
|
|
||||||
QString latitudeAsString() const
|
QString latitudeAsString() const
|
||||||
{
|
{
|
||||||
return this->latitude().toQString(true);
|
return this->latitude().toQString(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
//! Longitude as string
|
||||||
* \brief As string
|
|
||||||
* \return
|
|
||||||
*/
|
|
||||||
QString longitudeAsString() const
|
QString longitudeAsString() const
|
||||||
{
|
{
|
||||||
return this->longitude().toQString(true);
|
return this->longitude().toQString(true);
|
||||||
@@ -56,24 +44,20 @@ namespace BlackMisc
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*!
|
//! Great circle distance between points
|
||||||
* \brief Great circle distance between points
|
|
||||||
* \param coordinate1
|
|
||||||
* \param coordinate2
|
|
||||||
* \return
|
|
||||||
*/
|
|
||||||
BlackMisc::PhysicalQuantities::CLength greatCircleDistance(const ICoordinateGeodetic &coordinate1, const ICoordinateGeodetic &coordinate2);
|
BlackMisc::PhysicalQuantities::CLength greatCircleDistance(const ICoordinateGeodetic &coordinate1, const ICoordinateGeodetic &coordinate2);
|
||||||
|
|
||||||
/*!
|
//! Geodetic coordinate
|
||||||
* \brief Geodetic coordinate
|
//! \sa http://www.esri.com/news/arcuser/0703/geoid1of3.html
|
||||||
*/
|
//! \sa http://http://www.gmat.unsw.edu.au/snap/gps/clynch_pdfs/coordcvt.pdf (page 5)
|
||||||
|
//! \sa http://en.wikipedia.org/wiki/Geodetic_datum#Vertical_datum
|
||||||
class CCoordinateGeodetic : public CValueObject, public ICoordinateGeodetic
|
class CCoordinateGeodetic : public CValueObject, public ICoordinateGeodetic
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
BLACK_ENABLE_TUPLE_CONVERSION(CCoordinateGeodetic)
|
BLACK_ENABLE_TUPLE_CONVERSION(CCoordinateGeodetic)
|
||||||
BlackMisc::Geo::CLatitude m_latitude; //!< Latitude
|
BlackMisc::Geo::CLatitude m_latitude; //!< Latitude
|
||||||
BlackMisc::Geo::CLongitude m_longitude; //!< Longitude
|
BlackMisc::Geo::CLongitude m_longitude; //!< Longitude
|
||||||
BlackMisc::PhysicalQuantities::CLength m_height; //!< height
|
BlackMisc::PhysicalQuantities::CLength m_height; //!< height, ellipsoidal or geodetic height
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
//! \copydoc CValueObject::convertToQString
|
//! \copydoc CValueObject::convertToQString
|
||||||
@@ -95,54 +79,31 @@ namespace BlackMisc
|
|||||||
virtual void unmarshallFromDbus(const QDBusArgument &argument) override;
|
virtual void unmarshallFromDbus(const QDBusArgument &argument) override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/*!
|
//! Default constructor
|
||||||
* \brief Default constructor
|
|
||||||
*/
|
|
||||||
CCoordinateGeodetic() : m_latitude(), m_longitude(), m_height() {}
|
CCoordinateGeodetic() : m_latitude(), m_longitude(), m_height() {}
|
||||||
|
|
||||||
/*!
|
//! Constructor by values
|
||||||
* \brief Constructor by values
|
|
||||||
* \param latitude
|
|
||||||
* \param longitude
|
|
||||||
* \param height
|
|
||||||
*/
|
|
||||||
CCoordinateGeodetic(CLatitude latitude, CLongitude longitude, BlackMisc::PhysicalQuantities::CLength height) :
|
CCoordinateGeodetic(CLatitude latitude, CLongitude longitude, BlackMisc::PhysicalQuantities::CLength height) :
|
||||||
m_latitude(latitude), m_longitude(longitude), m_height(height) {}
|
m_latitude(latitude), m_longitude(longitude), m_height(height) {}
|
||||||
|
|
||||||
/*!
|
//! Constructor by values
|
||||||
* \brief Constructor by values
|
|
||||||
* \param latitudeDegrees
|
|
||||||
* \param longitudeDegrees
|
|
||||||
* \param heightMeters
|
|
||||||
*/
|
|
||||||
CCoordinateGeodetic(double latitudeDegrees, double longitudeDegrees, double heightMeters) :
|
CCoordinateGeodetic(double latitudeDegrees, double longitudeDegrees, double 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()) {}
|
||||||
|
|
||||||
//! \copydoc ICoordinateGeodetic::latitude
|
//! \copydoc ICoordinateGeodetic::latitude
|
||||||
virtual const CLatitude &latitude() const override
|
virtual const CLatitude &latitude() const override { return this->m_latitude; }
|
||||||
{
|
|
||||||
return this->m_latitude;
|
|
||||||
}
|
|
||||||
|
|
||||||
//! \copydoc ICoordinateGeodetic::longitude
|
//! \copydoc ICoordinateGeodetic::longitude
|
||||||
virtual const CLongitude &longitude() const override
|
virtual const CLongitude &longitude() const override { return this->m_longitude; }
|
||||||
{
|
|
||||||
return this->m_longitude;
|
|
||||||
}
|
|
||||||
|
|
||||||
//! \brief Height
|
//! Height, ellipsoidal or geodetic height
|
||||||
const BlackMisc::PhysicalQuantities::CLength &height() const
|
//! \remarks see http://www.gmat.unsw.edu.au/snap/gps/clynch_pdfs/coordcvt.pdf page 5
|
||||||
{
|
const BlackMisc::PhysicalQuantities::CLength &height() const { return this->m_height; }
|
||||||
return this->m_height;
|
|
||||||
}
|
|
||||||
|
|
||||||
//! \copydoc CValueObject::toQVariant
|
//! \copydoc CValueObject::toQVariant
|
||||||
virtual QVariant toQVariant() const override
|
virtual QVariant toQVariant() const override { return QVariant::fromValue(*this); }
|
||||||
{
|
|
||||||
return QVariant::fromValue(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
//! \brief Switch unit of latitude / longitude
|
//! Switch unit of latitude / longitude
|
||||||
CCoordinateGeodetic &switchUnit(const BlackMisc::PhysicalQuantities::CAngleUnit &unit)
|
CCoordinateGeodetic &switchUnit(const BlackMisc::PhysicalQuantities::CAngleUnit &unit)
|
||||||
{
|
{
|
||||||
this->m_latitude.switchUnit(unit);
|
this->m_latitude.switchUnit(unit);
|
||||||
@@ -150,35 +111,26 @@ namespace BlackMisc
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! \brief Switch unit of height
|
//! Switch unit of height
|
||||||
CCoordinateGeodetic &switchUnit(const BlackMisc::PhysicalQuantities::CLengthUnit &unit)
|
CCoordinateGeodetic &switchUnit(const BlackMisc::PhysicalQuantities::CLengthUnit &unit)
|
||||||
{
|
{
|
||||||
this->m_height.switchUnit(unit);
|
this->m_height.switchUnit(unit);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! \brief Set latitude
|
//! Set latitude
|
||||||
void setLatitude(const CLatitude &latitude)
|
void setLatitude(const CLatitude &latitude) { this->m_latitude = latitude; }
|
||||||
{
|
|
||||||
this->m_latitude = latitude;
|
|
||||||
}
|
|
||||||
|
|
||||||
//! \brief Set longitude
|
//! Set longitude
|
||||||
void setLongitude(const CLongitude &longitude)
|
void setLongitude(const CLongitude &longitude) { this->m_longitude = longitude; }
|
||||||
{
|
|
||||||
this->m_longitude = longitude;
|
|
||||||
}
|
|
||||||
|
|
||||||
//! \brief Set height
|
//! Set height (ellipsoidal or geodetic height)
|
||||||
void setHeight(const BlackMisc::PhysicalQuantities::CLength &height)
|
void setHeight(const BlackMisc::PhysicalQuantities::CLength &height) { this->m_height = height; }
|
||||||
{
|
|
||||||
this->m_height = height;
|
|
||||||
}
|
|
||||||
|
|
||||||
//! \brief Equal operator ==
|
//! Equal operator ==
|
||||||
bool operator ==(const CCoordinateGeodetic &other) const;
|
bool operator ==(const CCoordinateGeodetic &other) const;
|
||||||
|
|
||||||
//! \brief Unequal operator !=
|
//! Unequal operator !=
|
||||||
bool operator !=(const CCoordinateGeodetic &other) const;
|
bool operator !=(const CCoordinateGeodetic &other) const;
|
||||||
|
|
||||||
//! \copydoc CValueObject::getValueHash
|
//! \copydoc CValueObject::getValueHash
|
||||||
@@ -190,19 +142,13 @@ namespace BlackMisc
|
|||||||
//! \copydoc CValueObject::fromJson
|
//! \copydoc CValueObject::fromJson
|
||||||
void fromJson(const QJsonObject &json) override;
|
void fromJson(const QJsonObject &json) override;
|
||||||
|
|
||||||
//! \brief Register metadata
|
//! Register metadata
|
||||||
static void registerMetadata();
|
static void registerMetadata();
|
||||||
|
|
||||||
//! \brief Members
|
//! Members
|
||||||
static const QStringList &jsonMembers();
|
static const QStringList &jsonMembers();
|
||||||
|
|
||||||
/*!
|
//! Coordinate by WGS84 position data
|
||||||
* \brief Coordinate by WGS84 position data
|
|
||||||
* \param latitudeWgs84
|
|
||||||
* \param longitudeWgs84
|
|
||||||
* \param height
|
|
||||||
* \return
|
|
||||||
*/
|
|
||||||
static CCoordinateGeodetic fromWgs84(const QString &latitudeWgs84, const QString &longitudeWgs84, const BlackMisc::PhysicalQuantities::CLength height = BlackMisc::PhysicalQuantities::CLength());
|
static CCoordinateGeodetic fromWgs84(const QString &latitudeWgs84, const QString &longitudeWgs84, const BlackMisc::PhysicalQuantities::CLength height = BlackMisc::PhysicalQuantities::CLength());
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -12,11 +12,6 @@ namespace BlackMisc
|
|||||||
{
|
{
|
||||||
namespace PhysicalQuantities
|
namespace PhysicalQuantities
|
||||||
{
|
{
|
||||||
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
// --- Measurement unit --------------------------------------------------
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Equal operator
|
* Equal operator
|
||||||
*/
|
*/
|
||||||
@@ -109,7 +104,5 @@ namespace BlackMisc
|
|||||||
qDBusRegisterMetaType<CMeasurementUnit>();
|
qDBusRegisterMetaType<CMeasurementUnit>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ namespace BlackMisc
|
|||||||
CMeasurementUnit(name, symbol, converter, displayDigits, epsilon)
|
CMeasurementUnit(name, symbol, converter, displayDigits, epsilon)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
//! null constructor
|
||||||
CLengthUnit(const QString &name, const QString &symbol, std::nullptr_t) :
|
CLengthUnit(const QString &name, const QString &symbol, std::nullptr_t) :
|
||||||
CMeasurementUnit(name, symbol, nullptr)
|
CMeasurementUnit(name, symbol, nullptr)
|
||||||
{}
|
{}
|
||||||
@@ -98,7 +99,7 @@ namespace BlackMisc
|
|||||||
*/
|
*/
|
||||||
static const CLengthUnit &ft()
|
static const CLengthUnit &ft()
|
||||||
{
|
{
|
||||||
static CLengthUnit ft(QT_TRANSLATE_NOOP("CMeasurementUnit", "foot"), "ft", LinearConverter<FeetToMeters>(), 0);
|
static CLengthUnit ft(QT_TRANSLATE_NOOP("CMeasurementUnit", "foot"), "ft", LinearConverter<FeetToMeters>(), 1);
|
||||||
return ft;
|
return ft;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user