lomiri-location-service  ..
An aggregating location service providing positioning and geocoding capabilities to applications.
units.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2012-2013 Canonical Ltd.
3  *
4  * This program is free software: you can redistribute it and/or modify it
5  * under the terms of the GNU Lesser General Public License version 3,
6  * as published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * Authored by: Thomas Voß <thomas.voss@canonical.com>
17  */
18 #ifndef LOCATION_SERVICE_COM_LOMIRI_LOCATION_UNITS_UNITS_H_
19 #define LOCATION_SERVICE_COM_LOMIRI_LOCATION_UNITS_UNITS_H_
20 
21 #include <boost/units/cmath.hpp>
22 #include <boost/units/io.hpp>
23 #include <boost/units/quantity.hpp>
24 #include <boost/units/systems/angle/degrees.hpp>
25 #include <boost/units/systems/angle/gradians.hpp>
26 #include <boost/units/systems/si.hpp>
27 #include <boost/units/systems/si/prefixes.hpp>
28 
29 // std::optional doesn't support operator<< so core::Optional users shouldn't
30 // expect it to be available. However, consumers (e.g. GoogleTest) can
31 // auto-detect this operator using "ADL", so without including
32 // boost/optional/optional_io.hpp they will detect the non-working one which
33 // breaks the build.
34 #include <boost/optional/optional_io.hpp>
35 
36 namespace com
37 {
38 namespace lomiri
39 {
40 namespace location
41 {
42 namespace units
43 {
44 typedef boost::units::degree::plane_angle PlaneAngle;
45 static const PlaneAngle Degree;
46 static const PlaneAngle Degrees;
47 typedef boost::units::gradian::plane_angle Gradians;
48 
49 typedef boost::units::si::length Length;
50 static const Length Meter;
51 static const Length Meters;
52 
53 using boost::units::si::kilo;
54 
55 typedef boost::units::si::velocity Velocity;
56 static const Velocity MeterPerSecond;
58 
59 template<typename Unit>
60 using Quantity = boost::units::quantity<Unit, double>;
61 
62 typedef boost::units::si::dimensionless Dimensionless;
63 
64 using boost::units::sin;
65 using boost::units::cos;
66 using boost::units::atan2;
67 
68 template<typename Unit>
69 inline bool roughly_equals(const Quantity<Unit>& lhs, const Quantity<Unit>& rhs)
70 {
71  return std::fabs(lhs.value()-rhs.value()) <= std::numeric_limits<double>::epsilon();
72 }
73 }
74 }
75 }
76 }
77 
78 #endif // LOCATION_SERVICE_COM_LOMIRI_LOCATION_UNITS_UNITS_H_
79 
com::lomiri::location::units::MetersPerSecond
static const Velocity MetersPerSecond
Definition: units.h:57
com::lomiri::location::units::Meters
static const Length Meters
Definition: units.h:51
com::lomiri::location::units::MeterPerSecond
static const Velocity MeterPerSecond
Definition: units.h:56
com::lomiri::location::units::Gradians
boost::units::gradian::plane_angle Gradians
Definition: units.h:47
com::lomiri::location::units::Length
boost::units::si::length Length
Definition: units.h:49
com::lomiri::location::units::Quantity
boost::units::quantity< Unit, double > Quantity
Definition: units.h:60
com::lomiri::location::units::roughly_equals
bool roughly_equals(const Quantity< Unit > &lhs, const Quantity< Unit > &rhs)
Definition: units.h:69
com::lomiri::location::units::Degree
static const PlaneAngle Degree
Definition: units.h:45
com::lomiri::location::units::Meter
static const Length Meter
Definition: units.h:50
com
Definition: accuracy.h:23
com::lomiri::location::units::Dimensionless
boost::units::si::dimensionless Dimensionless
Definition: units.h:62
com::lomiri::location::units::PlaneAngle
boost::units::degree::plane_angle PlaneAngle
Definition: units.h:44
com::lomiri::location::units::Velocity
boost::units::si::velocity Velocity
Definition: units.h:55
com::lomiri::location::units::Degrees
static const PlaneAngle Degrees
Definition: units.h:46