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
36namespace com
37{
38namespace lomiri
39{
40namespace location
41{
42namespace units
43{
44typedef boost::units::degree::plane_angle PlaneAngle;
45static const PlaneAngle Degree;
46static const PlaneAngle Degrees;
47typedef boost::units::gradian::plane_angle Gradians;
48
49typedef boost::units::si::length Length;
50static const Length Meter;
51static const Length Meters;
52
53using boost::units::si::kilo;
54
55typedef boost::units::si::velocity Velocity;
58
59template<typename Unit>
60using Quantity = boost::units::quantity<Unit, double>;
61
62typedef boost::units::si::dimensionless Dimensionless;
63
64using boost::units::sin;
65using boost::units::cos;
66using boost::units::atan2;
67
68template<typename Unit>
69inline 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
static const Velocity MetersPerSecond
Definition units.h:57
boost::units::si::dimensionless Dimensionless
Definition units.h:62
static const Length Meters
Definition units.h:51
static const PlaneAngle Degree
Definition units.h:45
boost::units::gradian::plane_angle Gradians
Definition units.h:47
boost::units::si::velocity Velocity
Definition units.h:55
static const PlaneAngle Degrees
Definition units.h:46
boost::units::quantity< Unit, double > Quantity
Definition units.h:60
boost::units::degree::plane_angle PlaneAngle
Definition units.h:44
static const Length Meter
Definition units.h:50
static const Velocity MeterPerSecond
Definition units.h:56
boost::units::si::length Length
Definition units.h:49
bool roughly_equals(const Quantity< Unit > &lhs, const Quantity< Unit > &rhs)
Definition units.h:69
Definition accuracy.h:24