18
18
#ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_HEADING_H_
19
19
#define LOCATION_SERVICE_COM_UBUNTU_LOCATION_HEADING_H_
21
#include "com/ubuntu/location/accuracy.h"
22
#include "com/ubuntu/location/units/units.h"
21
#include <com/ubuntu/location/units/units.h>
36
typedef units::PlaneAngle Unit;
37
typedef units::Quantity<Unit> Quantity;
39
static const Quantity& min()
41
static const auto instance = Heading::Quantity::from_value(0.);
44
static const Quantity& max()
46
static const auto instance = Heading::Quantity::from_value(360.);
50
Heading(const Quantity& value = Quantity()) : value(value)
53
throw std::out_of_range("");
55
throw std::out_of_range("");
58
bool operator==(const Heading& rhs) const
60
return value == rhs.value;
63
bool operator!=(const Heading& rhs) const
65
return value != rhs.value;
71
inline std::ostream& operator<<(std::ostream& out, const Heading& heading)
73
out << "Heading(" << heading.value << ")";
78
struct AccuracyTraits<Heading>
80
static AccuracyLevel classify(const Heading& h)
82
static const auto half = 0.5 * Heading::max();
84
return AccuracyLevel::worst;
87
return AccuracyLevel::best;
89
return AccuracyLevel::worst;
92
static Accuracy<Heading> best()
94
return Accuracy<Heading>{Heading{Heading::min()}};
97
static Accuracy<Heading> worst()
99
return Accuracy<Heading>{Heading{Heading::max()}};
29
/** Heading is measured in ° deviation from true north. */
30
typedef units::Quantity<units::PlaneAngle> Heading;