Enroute Flight Navigation
A navigation app for VFR pilots
|
Convenience class for distance computations. More...
#include <Distance.h>
Public Types | |
enum | DistanceUnit : quint8 |
Units of measurement for distances. | |
Public Member Functions | |
Q_INVOKABLE Units::Distance & | operator+= (Units::Distance other) |
Add distance to this distance. | |
Q_INVOKABLE bool | isFinite () const |
Checks if the distance is valid. | |
Q_INVOKABLE bool | isNegative () const |
Checks if the distance is negative. | |
Q_INVOKABLE Units::Distance | operator+ (Units::Distance rhs) const |
Addition. | |
Q_INVOKABLE Units::Distance | operator- (Units::Distance rhs) const |
Subtraction. | |
Q_INVOKABLE Units::Distance | subtract (Units::Distance rhs) const |
Subtraction. | |
Q_INVOKABLE Units::Distance | operator* (double factor) const |
Scaling. | |
Q_INVOKABLE std::partial_ordering | operator<=> (const Units::Distance &rhs) const =default |
Comparison. | |
Q_INVOKABLE double | toFeet () const |
Convert to feet. | |
Q_INVOKABLE double | toKM () const |
Convert to meters. | |
Q_INVOKABLE double | toM () const |
Convert to meters. | |
Q_INVOKABLE double | toMIL () const |
Convert to international miles. | |
Q_INVOKABLE double | toNM () const |
Convert to nautical miles. | |
Q_INVOKABLE QString | toString (Units::Distance::DistanceUnit units, bool roundBigNumbers=false, bool forceSign=false) const |
Convert to string. | |
Static Public Member Functions | |
static Q_INVOKABLE constexpr Units::Distance | fromM (double distanceInM) |
Constructs a distance. | |
static Q_INVOKABLE constexpr Units::Distance | fromKM (double distanceInKM) |
Constructs a distance. | |
static Q_INVOKABLE constexpr Units::Distance | fromNM (double distanceInNM) |
Constructs a distance. | |
static Q_INVOKABLE constexpr Units::Distance | fromMIL (double distanceInMIL) |
Constructs a distance. | |
static Q_INVOKABLE constexpr Units::Distance | fromFT (double distanceInFT) |
Constructs a distance. | |
static Q_INVOKABLE constexpr Units::Distance | nan () |
Constructs an invalid distance. | |
Convenience class for distance computations.
This extremely simple class allows computation with distances, without the need to worry about units. On construction, the distance is set to NaN.
Definition at line 35 of file Distance.h.
|
inlinestaticconstexpr |
Constructs a distance.
distanceInFT | distance in feet |
Definition at line 108 of file Distance.h.
|
inlinestaticconstexpr |
Constructs a distance.
distanceInKM | distance in kilometers |
Definition at line 69 of file Distance.h.
|
inlinestaticconstexpr |
Constructs a distance.
distanceInM | distance in meters |
Definition at line 56 of file Distance.h.
|
inlinestaticconstexpr |
Constructs a distance.
distanceInMIL | distance in international miles |
Definition at line 95 of file Distance.h.
|
inlinestaticconstexpr |
Constructs a distance.
distanceInNM | distance in nautical miles |
Definition at line 82 of file Distance.h.
|
inlinenodiscard |
Checks if the distance is valid.
Definition at line 140 of file Distance.h.
|
inlinenodiscard |
Checks if the distance is negative.
Definition at line 149 of file Distance.h.
|
inlinestaticconstexpr |
|
inlinenodiscard |
Scaling.
factor | Factor of scaling |
Definition at line 193 of file Distance.h.
|
inlinenodiscard |
Addition.
rhs | Right hand side of the addition |
Definition at line 160 of file Distance.h.
|
inline |
Add distance to this distance.
other | distance to be added |
Definition at line 130 of file Distance.h.
|
inlinenodiscard |
Subtraction.
rhs | Right hand side of the subtraction |
Definition at line 171 of file Distance.h.
|
nodiscarddefault |
Comparison.
rhs | Right hand side of the comparison |
|
inlinenodiscard |
Subtraction.
rhs | Right hand side of the subtraction |
Definition at line 182 of file Distance.h.
|
inlinenodiscard |
|
inlinenodiscard |
|
inlinenodiscard |
|
inlinenodiscard |
Convert to international miles.
Definition at line 237 of file Distance.h.
|
inlinenodiscard |
Convert to nautical miles.
Definition at line 246 of file Distance.h.
|
nodiscard |
Convert to string.
This method converts the distance to string that is fit for human consumption, of the form "10.9 nm", "130 ft" or "3500 m". The distance is rounded to reasonable precision.
units | Determines the units that are used. |
roundBigNumbers | If true, then round "1234" to "1200" and "117" to "120" |
forceSign | If 'true', then positive distances are prepended by a "+" sign. |