mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-25 02:05:43 +08:00
committed by
Mathew Sutcliffe
parent
229d7c6068
commit
978f3c88e5
@@ -12,195 +12,202 @@
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Geo
|
||||
{
|
||||
|
||||
/*!
|
||||
* Latitude and longitude interface
|
||||
* \brief Interface for geodetic ccordinates
|
||||
*/
|
||||
class ICoordinateGeodetic
|
||||
{
|
||||
/*!
|
||||
* \brief Latitude
|
||||
* \return
|
||||
*/
|
||||
virtual const CLatitude &latitude() const = 0;
|
||||
|
||||
/*!
|
||||
* \brief Longitude
|
||||
* \return
|
||||
*/
|
||||
virtual const CLongitude &longitude() const = 0;
|
||||
};
|
||||
|
||||
/*!
|
||||
* \brief Geodetic coordinate
|
||||
*/
|
||||
class CCoordinateGeodetic : public CStreamable, public ICoordinateGeodetic
|
||||
{
|
||||
private:
|
||||
BlackMisc::Geo::CLatitude m_latitude; //!< Latitude
|
||||
BlackMisc::Geo::CLongitude m_longitude; //!< Longitude
|
||||
BlackMisc::PhysicalQuantities::CLength m_height; //!< height
|
||||
|
||||
protected:
|
||||
/*!
|
||||
* \brief String for converter
|
||||
* \param i18n
|
||||
* \return
|
||||
*/
|
||||
virtual QString convertToQString(bool i18n = false) const;
|
||||
|
||||
/*!
|
||||
* \brief Stream to DBus
|
||||
* \param argument
|
||||
*/
|
||||
virtual void marshallToDbus(QDBusArgument &argument) const;
|
||||
|
||||
/*!
|
||||
* \brief Stream from DBus
|
||||
* \param argument
|
||||
*/
|
||||
virtual void unmarshallFromDbus(const QDBusArgument &argument);
|
||||
|
||||
public:
|
||||
/*!
|
||||
* \brief Default constructor
|
||||
*/
|
||||
CCoordinateGeodetic() : m_latitude(), m_longitude(), m_height() {}
|
||||
|
||||
/*!
|
||||
* \brief Copy constructor
|
||||
*/
|
||||
CCoordinateGeodetic(const CCoordinateGeodetic &geoCoordinate) :
|
||||
m_latitude(geoCoordinate.m_latitude), m_longitude(geoCoordinate.m_longitude), m_height(geoCoordinate.m_height) {}
|
||||
|
||||
/*!
|
||||
* \brief Constructor by values
|
||||
* \param latitude
|
||||
* \param longitude
|
||||
* \param height
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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()) {}
|
||||
|
||||
/*!
|
||||
* \brief Latitude
|
||||
* \return
|
||||
*/
|
||||
const CLatitude &latitude() const
|
||||
namespace Geo
|
||||
{
|
||||
return this->m_latitude;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Longitude
|
||||
* \return
|
||||
*/
|
||||
const CLongitude &longitude() const
|
||||
{
|
||||
return this->m_longitude;
|
||||
}
|
||||
/*!
|
||||
* Latitude and longitude interface
|
||||
* \brief Interface for geodetic ccordinates
|
||||
*/
|
||||
class ICoordinateGeodetic
|
||||
{
|
||||
public:
|
||||
|
||||
/*!
|
||||
* \brief Height
|
||||
* \return
|
||||
*/
|
||||
const BlackMisc::PhysicalQuantities::CLength &height() const
|
||||
{
|
||||
return this->m_height;
|
||||
}
|
||||
/*!
|
||||
* \brief Latitude
|
||||
* \return
|
||||
*/
|
||||
virtual const CLatitude &latitude() const = 0;
|
||||
|
||||
/*!
|
||||
* \brief Switch unit of latitude / longitude
|
||||
* \param unit
|
||||
* \return
|
||||
*/
|
||||
CCoordinateGeodetic &switchUnit(const BlackMisc::PhysicalQuantities::CAngleUnit &unit)
|
||||
{
|
||||
this->m_latitude.switchUnit(unit);
|
||||
this->m_longitude.switchUnit(unit);
|
||||
return *this;
|
||||
}
|
||||
/*!
|
||||
* \brief Longitude
|
||||
* \return
|
||||
*/
|
||||
virtual const CLongitude &longitude() const = 0;
|
||||
|
||||
/*!
|
||||
* \brief Switch unit of height
|
||||
* \param unit
|
||||
* \return
|
||||
*/
|
||||
CCoordinateGeodetic &switchUnit(const BlackMisc::PhysicalQuantities::CLengthUnit &unit)
|
||||
{
|
||||
this->m_height.switchUnit(unit);
|
||||
return *this;
|
||||
}
|
||||
/*!
|
||||
* \brief As string
|
||||
* \return
|
||||
*/
|
||||
QString latitudeAsString() const
|
||||
{
|
||||
return this->latitude().toQString(true);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Set latitude
|
||||
* \param latitude
|
||||
*/
|
||||
void setLatitude(const CLatitude &latitude)
|
||||
{
|
||||
this->m_latitude = latitude;
|
||||
}
|
||||
/*!
|
||||
* \brief As string
|
||||
* \return
|
||||
*/
|
||||
QString longitudeAsString() const
|
||||
{
|
||||
return this->longitude().toQString(true);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Set longitude
|
||||
* \param longitude
|
||||
*/
|
||||
void setLongitude(const CLongitude &longitude)
|
||||
{
|
||||
this->m_longitude = longitude;
|
||||
}
|
||||
};
|
||||
|
||||
/*!
|
||||
* \brief Set height
|
||||
* \param height
|
||||
*/
|
||||
void setHeight(const BlackMisc::PhysicalQuantities::CLength &height)
|
||||
{
|
||||
this->m_height = height;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Equal operator ==
|
||||
* \param other
|
||||
* \return
|
||||
*/
|
||||
bool operator ==(const CCoordinateGeodetic &other) const
|
||||
{
|
||||
if (this == &other) return true;
|
||||
return this->m_height == other.m_height &&
|
||||
this->m_latitude == other.m_latitude &&
|
||||
this->m_longitude == other.m_longitude;
|
||||
}
|
||||
/*!
|
||||
* \brief Geodetic coordinate
|
||||
*/
|
||||
class CCoordinateGeodetic : public CStreamable
|
||||
{
|
||||
private:
|
||||
BlackMisc::Geo::CLatitude m_latitude; //!< Latitude
|
||||
BlackMisc::Geo::CLongitude m_longitude; //!< Longitude
|
||||
BlackMisc::PhysicalQuantities::CLength m_height; //!< height
|
||||
|
||||
/*!
|
||||
* \brief Unequal operator !=
|
||||
* \param other
|
||||
* \return
|
||||
*/
|
||||
bool operator !=(const CCoordinateGeodetic &other) const
|
||||
{
|
||||
return !((*this) == other);
|
||||
}
|
||||
protected:
|
||||
/*!
|
||||
* \brief String for converter
|
||||
* \param i18n
|
||||
* \return
|
||||
*/
|
||||
virtual QString convertToQString(bool i18n = false) const;
|
||||
|
||||
/*
|
||||
* Register metadata
|
||||
*/
|
||||
static void registerMetadata();
|
||||
};
|
||||
/*!
|
||||
* \brief Stream to DBus
|
||||
* \param argument
|
||||
*/
|
||||
virtual void marshallToDbus(QDBusArgument &argument) const;
|
||||
|
||||
} // namespace
|
||||
/*!
|
||||
* \brief Stream from DBus
|
||||
* \param argument
|
||||
*/
|
||||
virtual void unmarshallFromDbus(const QDBusArgument &argument);
|
||||
|
||||
public:
|
||||
/*!
|
||||
* \brief Default constructor
|
||||
*/
|
||||
CCoordinateGeodetic() : m_latitude(), m_longitude(), m_height() {}
|
||||
|
||||
/*!
|
||||
* \brief Constructor by values
|
||||
* \param latitude
|
||||
* \param longitude
|
||||
* \param height
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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()) {}
|
||||
|
||||
/*!
|
||||
* \brief Latitude
|
||||
* \return
|
||||
*/
|
||||
const CLatitude &latitude() const
|
||||
{
|
||||
return this->m_latitude;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Longitude
|
||||
* \return
|
||||
*/
|
||||
const CLongitude &longitude() const
|
||||
{
|
||||
return this->m_longitude;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Height
|
||||
* \return
|
||||
*/
|
||||
const BlackMisc::PhysicalQuantities::CLength &height() const
|
||||
{
|
||||
return this->m_height;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Switch unit of latitude / longitude
|
||||
* \param unit
|
||||
* \return
|
||||
*/
|
||||
CCoordinateGeodetic &switchUnit(const BlackMisc::PhysicalQuantities::CAngleUnit &unit)
|
||||
{
|
||||
this->m_latitude.switchUnit(unit);
|
||||
this->m_longitude.switchUnit(unit);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Switch unit of height
|
||||
* \param unit
|
||||
* \return
|
||||
*/
|
||||
CCoordinateGeodetic &switchUnit(const BlackMisc::PhysicalQuantities::CLengthUnit &unit)
|
||||
{
|
||||
this->m_height.switchUnit(unit);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Set latitude
|
||||
* \param latitude
|
||||
*/
|
||||
void setLatitude(const CLatitude &latitude)
|
||||
{
|
||||
this->m_latitude = latitude;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Set longitude
|
||||
* \param longitude
|
||||
*/
|
||||
void setLongitude(const CLongitude &longitude)
|
||||
{
|
||||
this->m_longitude = longitude;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Set height
|
||||
* \param height
|
||||
*/
|
||||
void setHeight(const BlackMisc::PhysicalQuantities::CLength &height)
|
||||
{
|
||||
this->m_height = height;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Equal operator ==
|
||||
* \param other
|
||||
* \return
|
||||
*/
|
||||
bool operator ==(const CCoordinateGeodetic &other) const;
|
||||
|
||||
/*!
|
||||
* \brief Unequal operator !=
|
||||
* \param other
|
||||
* \return
|
||||
*/
|
||||
bool operator !=(const CCoordinateGeodetic &other) const;
|
||||
|
||||
/*!
|
||||
* Register metadata
|
||||
*/
|
||||
static void registerMetadata();
|
||||
};
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
Q_DECLARE_METATYPE(BlackMisc::Geo::CCoordinateGeodetic)
|
||||
|
||||
Reference in New Issue
Block a user