mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 11:55:35 +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(" gs: ").append(this->m_groundspeed.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;
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,11 @@ namespace BlackMisc
|
||||
}
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace BlackMisc
|
||||
QString CCoordinateGeodetic::convertToQString(bool i18n) const
|
||||
{
|
||||
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
|
||||
* \brief Interface for geodetic ccordinates
|
||||
* Interface for geodetic ccordinates
|
||||
*/
|
||||
class ICoordinateGeodetic
|
||||
{
|
||||
public:
|
||||
|
||||
/*!
|
||||
* \brief Latitude
|
||||
* \return
|
||||
*/
|
||||
//! Latitude
|
||||
virtual const CLatitude &latitude() const = 0;
|
||||
|
||||
/*!
|
||||
* \brief Longitude
|
||||
* \return
|
||||
*/
|
||||
//! Longitude
|
||||
virtual const CLongitude &longitude() const = 0;
|
||||
|
||||
/*!
|
||||
* \brief As string
|
||||
* \return
|
||||
*/
|
||||
//! Latitude as string
|
||||
QString latitudeAsString() const
|
||||
{
|
||||
return this->latitude().toQString(true);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief As string
|
||||
* \return
|
||||
*/
|
||||
//! Longitude as string
|
||||
QString longitudeAsString() const
|
||||
{
|
||||
return this->longitude().toQString(true);
|
||||
@@ -56,24 +44,20 @@ namespace BlackMisc
|
||||
|
||||
};
|
||||
|
||||
/*!
|
||||
* \brief Great circle distance between points
|
||||
* \param coordinate1
|
||||
* \param coordinate2
|
||||
* \return
|
||||
*/
|
||||
//! Great circle distance between points
|
||||
BlackMisc::PhysicalQuantities::CLength greatCircleDistance(const ICoordinateGeodetic &coordinate1, const ICoordinateGeodetic &coordinate2);
|
||||
|
||||
/*!
|
||||
* \brief Geodetic coordinate
|
||||
*/
|
||||
//! 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
|
||||
{
|
||||
private:
|
||||
BLACK_ENABLE_TUPLE_CONVERSION(CCoordinateGeodetic)
|
||||
BlackMisc::Geo::CLatitude m_latitude; //!< Latitude
|
||||
BlackMisc::Geo::CLongitude m_longitude; //!< Longitude
|
||||
BlackMisc::PhysicalQuantities::CLength m_height; //!< height
|
||||
BlackMisc::PhysicalQuantities::CLength m_height; //!< height, ellipsoidal or geodetic height
|
||||
|
||||
protected:
|
||||
//! \copydoc CValueObject::convertToQString
|
||||
@@ -95,54 +79,31 @@ namespace BlackMisc
|
||||
virtual void unmarshallFromDbus(const QDBusArgument &argument) override;
|
||||
|
||||
public:
|
||||
/*!
|
||||
* \brief Default constructor
|
||||
*/
|
||||
//! Default constructor
|
||||
CCoordinateGeodetic() : m_latitude(), m_longitude(), m_height() {}
|
||||
|
||||
/*!
|
||||
* \brief Constructor by values
|
||||
* \param latitude
|
||||
* \param longitude
|
||||
* \param height
|
||||
*/
|
||||
//! Constructor by values
|
||||
CCoordinateGeodetic(CLatitude latitude, CLongitude longitude, BlackMisc::PhysicalQuantities::CLength height) :
|
||||
m_latitude(latitude), m_longitude(longitude), m_height(height) {}
|
||||
|
||||
/*!
|
||||
* \brief Constructor by values
|
||||
* \param latitudeDegrees
|
||||
* \param longitudeDegrees
|
||||
* \param heightMeters
|
||||
*/
|
||||
//! Constructor by values
|
||||
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()) {}
|
||||
|
||||
//! \copydoc ICoordinateGeodetic::latitude
|
||||
virtual const CLatitude &latitude() const override
|
||||
{
|
||||
return this->m_latitude;
|
||||
}
|
||||
virtual const CLatitude &latitude() const override { return this->m_latitude; }
|
||||
|
||||
//! \copydoc ICoordinateGeodetic::longitude
|
||||
virtual const CLongitude &longitude() const override
|
||||
{
|
||||
return this->m_longitude;
|
||||
}
|
||||
virtual const CLongitude &longitude() const override { return this->m_longitude; }
|
||||
|
||||
//! \brief Height
|
||||
const BlackMisc::PhysicalQuantities::CLength &height() const
|
||||
{
|
||||
return this->m_height;
|
||||
}
|
||||
//! Height, ellipsoidal or geodetic height
|
||||
//! \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; }
|
||||
|
||||
//! \copydoc CValueObject::toQVariant
|
||||
virtual QVariant toQVariant() const override
|
||||
{
|
||||
return QVariant::fromValue(*this);
|
||||
}
|
||||
virtual QVariant toQVariant() const override { return QVariant::fromValue(*this); }
|
||||
|
||||
//! \brief Switch unit of latitude / longitude
|
||||
//! Switch unit of latitude / longitude
|
||||
CCoordinateGeodetic &switchUnit(const BlackMisc::PhysicalQuantities::CAngleUnit &unit)
|
||||
{
|
||||
this->m_latitude.switchUnit(unit);
|
||||
@@ -150,35 +111,26 @@ namespace BlackMisc
|
||||
return *this;
|
||||
}
|
||||
|
||||
//! \brief Switch unit of height
|
||||
//! Switch unit of height
|
||||
CCoordinateGeodetic &switchUnit(const BlackMisc::PhysicalQuantities::CLengthUnit &unit)
|
||||
{
|
||||
this->m_height.switchUnit(unit);
|
||||
return *this;
|
||||
}
|
||||
|
||||
//! \brief Set latitude
|
||||
void setLatitude(const CLatitude &latitude)
|
||||
{
|
||||
this->m_latitude = latitude;
|
||||
}
|
||||
//! Set latitude
|
||||
void setLatitude(const CLatitude &latitude) { this->m_latitude = latitude; }
|
||||
|
||||
//! \brief Set longitude
|
||||
void setLongitude(const CLongitude &longitude)
|
||||
{
|
||||
this->m_longitude = longitude;
|
||||
}
|
||||
//! Set longitude
|
||||
void setLongitude(const CLongitude &longitude) { this->m_longitude = longitude; }
|
||||
|
||||
//! \brief Set height
|
||||
void setHeight(const BlackMisc::PhysicalQuantities::CLength &height)
|
||||
{
|
||||
this->m_height = height;
|
||||
}
|
||||
//! Set height (ellipsoidal or geodetic height)
|
||||
void setHeight(const BlackMisc::PhysicalQuantities::CLength &height) { this->m_height = height; }
|
||||
|
||||
//! \brief Equal operator ==
|
||||
//! Equal operator ==
|
||||
bool operator ==(const CCoordinateGeodetic &other) const;
|
||||
|
||||
//! \brief Unequal operator !=
|
||||
//! Unequal operator !=
|
||||
bool operator !=(const CCoordinateGeodetic &other) const;
|
||||
|
||||
//! \copydoc CValueObject::getValueHash
|
||||
@@ -190,19 +142,13 @@ namespace BlackMisc
|
||||
//! \copydoc CValueObject::fromJson
|
||||
void fromJson(const QJsonObject &json) override;
|
||||
|
||||
//! \brief Register metadata
|
||||
//! Register metadata
|
||||
static void registerMetadata();
|
||||
|
||||
//! \brief Members
|
||||
//! Members
|
||||
static const QStringList &jsonMembers();
|
||||
|
||||
/*!
|
||||
* \brief Coordinate by WGS84 position data
|
||||
* \param latitudeWgs84
|
||||
* \param longitudeWgs84
|
||||
* \param height
|
||||
* \return
|
||||
*/
|
||||
//! Coordinate by WGS84 position data
|
||||
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
|
||||
{
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// --- Measurement unit --------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
/*
|
||||
* Equal operator
|
||||
*/
|
||||
@@ -109,7 +104,5 @@ namespace BlackMisc
|
||||
qDBusRegisterMetaType<CMeasurementUnit>();
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -37,6 +37,7 @@ namespace BlackMisc
|
||||
CMeasurementUnit(name, symbol, converter, displayDigits, epsilon)
|
||||
{}
|
||||
|
||||
//! null constructor
|
||||
CLengthUnit(const QString &name, const QString &symbol, std::nullptr_t) :
|
||||
CMeasurementUnit(name, symbol, nullptr)
|
||||
{}
|
||||
@@ -98,7 +99,7 @@ namespace BlackMisc
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user