18 #ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_VELOCITY_H_
19 #define LOCATION_SERVICE_COM_UBUNTU_LOCATION_VELOCITY_H_
21 #include "com/ubuntu/location/accuracy.h"
22 #include "com/ubuntu/location/units/units.h"
36 typedef units::Velocity Unit;
37 typedef units::Quantity<Unit> Quantity;
39 static inline const Quantity& min()
41 static const Quantity instance = Quantity::from_value(0.);
45 static inline const Quantity max()
47 static const Quantity instance = Quantity::from_value(std::numeric_limits<double>::max());
51 Velocity(
const Quantity& value = Quantity()) : value(value)
53 if (value < Velocity::min())
54 throw std::out_of_range(
"");
55 if (value > Velocity::max())
56 throw std::out_of_range(
"");
59 inline bool operator==(
const Velocity& rhs)
const
61 return value == rhs.value;
64 inline bool operator!=(
const Velocity& rhs)
const
66 return value != rhs.value;
72 inline std::ostream& operator<<(std::ostream& out,
const Velocity& velocity)
74 out <<
"Velocity(" << velocity.value <<
")";
81 static AccuracyLevel classify(
const Velocity& h)
83 if (h.value > (1.f * units::MetersPerSecond))
84 return AccuracyLevel::worst;
86 if (h.value <= (1.f * units::MetersPerSecond))
87 return AccuracyLevel::best;
89 return AccuracyLevel::worst;
106 #endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_VELOCITY_H_