1
#ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_HEADING_H_
2
#define LOCATION_SERVICE_COM_UBUNTU_LOCATION_HEADING_H_
4
#include "com/ubuntu/location/accuracy.h"
5
#include "com/ubuntu/location/units/units.h"
19
typedef units::PlaneAngle Unit;
20
typedef units::Quantity<Unit> Quantity;
22
static const Quantity& min()
24
static const auto instance = Heading::Quantity::from_value(0.);
27
static const Quantity& max()
29
static const auto instance = Heading::Quantity::from_value(360.);
33
Heading(const Quantity& value = Quantity()) : value(value)
36
throw std::out_of_range("");
38
throw std::out_of_range("");
41
bool operator==(const Heading& rhs) const
43
return value == rhs.value;
46
bool operator!=(const Heading& rhs) const
48
return value != rhs.value;
54
inline std::ostream& operator<<(std::ostream& out, const Heading& heading)
56
out << "Heading(" << heading.value << ")";
61
struct AccuracyTraits<Heading>
63
static AccuracyLevel classify(const Heading& h)
65
static const auto half = 0.5 * Heading::max();
67
return AccuracyLevel::worst;
70
return AccuracyLevel::best;
72
return AccuracyLevel::worst;
75
static Accuracy<Heading> best()
77
return Accuracy<Heading>{Heading{Heading::min()}};
80
static Accuracy<Heading> worst()
82
return Accuracy<Heading>{Heading{Heading::max()}};
89
#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_HEADING_H_