ubuntu-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_UBUNTU_LOCATION_UNITS_UNITS_H_
19 #define LOCATION_SERVICE_COM_UBUNTU_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 namespace com
30 {
31 namespace ubuntu
32 {
33 namespace location
34 {
35 namespace units
36 {
37 typedef boost::units::degree::plane_angle PlaneAngle;
38 static const PlaneAngle Degree;
39 static const PlaneAngle Degrees;
40 typedef boost::units::gradian::plane_angle Gradians;
41 
42 typedef boost::units::si::length Length;
43 static const Length Meter;
44 static const Length Meters;
45 
46 using boost::units::si::kilo;
47 
48 typedef boost::units::si::velocity Velocity;
49 static const Velocity MeterPerSecond;
51 
52 template<typename Unit>
53 using Quantity = boost::units::quantity<Unit, double>;
54 
55 typedef boost::units::si::dimensionless Dimensionless;
56 
57 using boost::units::sin;
58 using boost::units::cos;
59 using boost::units::atan2;
60 
61 template<typename Unit>
62 inline bool roughly_equals(const Quantity<Unit>& lhs, const Quantity<Unit>& rhs)
63 {
64  return std::fabs(lhs.value()-rhs.value()) <= std::numeric_limits<double>::epsilon();
65 }
66 }
67 }
68 }
69 }
70 
71 #endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_UNITS_UNITS_H_
72 
static const Velocity MetersPerSecond
Definition: units.h:50
boost::units::quantity< Unit, double > Quantity
Definition: units.h:53
boost::units::si::dimensionless Dimensionless
Definition: units.h:55
static const Length Meter
Definition: units.h:43
static const Length Meters
Definition: units.h:44
static const PlaneAngle Degrees
Definition: units.h:39
boost::units::si::velocity Velocity
Definition: units.h:48
static const Velocity MeterPerSecond
Definition: units.h:49
bool roughly_equals(const Quantity< Unit > &lhs, const Quantity< Unit > &rhs)
Definition: units.h:62
boost::units::degree::plane_angle PlaneAngle
Definition: units.h:37
boost::units::si::length Length
Definition: units.h:42
boost::units::gradian::plane_angle Gradians
Definition: units.h:40
static const PlaneAngle Degree
Definition: units.h:38
Definition: accuracy.h:24