ubuntu-location-service: /build/location-service-git/src/location-service/include/location_service/com/ubuntu/location/space_vehicle.h Source File

ubuntu-location-service .. An aggregating location service providing positioning and geocoding capabilities to applications.

space_vehicle.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_SPACE_VEHICLE_H_
19 #define LOCATION_SERVICE_COM_UBUNTU_LOCATION_SPACE_VEHICLE_H_
20
21 #include <com/ubuntu/location/units/units.h>
22
23 #include <iostream>
24 #include <map>
25
26 namespace com
27 {
28 namespace ubuntu
29 {
30 namespace location
31 {
33 struct SpaceVehicle
34 {
36 typedef std::uint32_t Id;
37
39 enum class Type
40 {
41 unknown,
42 beidou,
43 galileo,
44 glonass,
45 gps,
46 compass,
47 irnss,
48 qzss
49 };
50
52 struct Key
53 {
54 Type type = Type::unknown;
55 Id id = 0;
56
57 inline bool operator==(const SpaceVehicle::Key& rhs) const
58 {
59 return type == rhs.type && id == rhs.id;
60 }
61
62 inline bool operator<(const SpaceVehicle::Key& rhs) const
63 {
64 if (type != rhs.type)
65 return type < rhs.type;
66
67 return id < rhs.id;
68 }
69 };
70
71 inline bool operator==(const SpaceVehicle& rhs) const
72 {
73 return key == rhs.key &&
74 has_almanac_data == rhs.has_almanac_data &&
75 has_ephimeris_data == rhs.has_ephimeris_data &&
76 used_in_fix == rhs.used_in_fix &&
77 units::roughly_equals(azimuth, rhs.azimuth) &&
78 units::roughly_equals(elevation, rhs.elevation);
79 }
80
81 inline bool operator<(const SpaceVehicle& rhs) const
82 {
83 return key < rhs.key;
84 }
85
86 Key key;
87 float snr = -std::numeric_limits<float>::max();
88 bool has_almanac_data = false;
89 bool has_ephimeris_data = false;
90 bool used_in_fix = false;
91 units::Quantity<units::PlaneAngle> azimuth;
92 units::Quantity<units::PlaneAngle> elevation;
93 };
94
95 inline std::ostream& operator<<(std::ostream& out, const SpaceVehicle& sv)
96 {
97 static const std::map<SpaceVehicle::Type, std::string> lut =
98 {
99 {SpaceVehicle::Type::unknown, "unknown"},
100 {SpaceVehicle::Type::beidou, "beidou"},
101 {SpaceVehicle::Type::galileo, "galileo"},
102 {SpaceVehicle::Type::glonass, "glonass"},
103 {SpaceVehicle::Type::gps, "gps"},
104 {SpaceVehicle::Type::compass, "compass"},
105 {SpaceVehicle::Type::irnss, "irnss"},
106 {SpaceVehicle::Type::qzss, "qzss" }
107 };
108 return out << "("
109 << "type: " << lut.at(sv.key.type) << ", "
110 << "prn: " << sv.key.id << ", "
111 << "snr: " << sv.snr << ", "
112 << "has_almanac_data: " << sv.has_almanac_data << ", "
113 << "has_ephimeris_data: " << sv.has_ephimeris_data << ", "
114 << "used_in_fix: " << sv.used_in_fix << ", "
115 << "azimuth: " << sv.azimuth << ", "
116 << "elevation: " << sv.elevation
117 << ")";
118 }
119 }
120 }
121 }
122
123 #endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_SPACE_VEHICLE_H_
com::ubuntu::location::units::Quantity
boost::units::quantity< Unit, double > Quantity
Definition: units.h:53
com::ubuntu::location::units::roughly_equals
bool roughly_equals(const Quantity< Unit > &lhs, const Quantity< Unit > &rhs)
Definition: units.h:62
com::ubuntu::location::operator<<
std::ostream & operator<<(std::ostream &out, const Accuracy< T > &update)
Definition: accuracy.h:68
com
Definition: accuracy.h:24
com::ubuntu::location::SpaceVehicle::Key
Uniquely identifies a space vehicle, given its type and its id.
Definition: space_vehicle.h:53
com::ubuntu::location::SpaceVehicle::Key::operator<
bool operator<(const SpaceVehicle::Key &rhs) const
Definition: space_vehicle.h:62
com::ubuntu::location::SpaceVehicle::Key::operator==
bool operator==(const SpaceVehicle::Key &rhs) const
Definition: space_vehicle.h:57
com::ubuntu::location::SpaceVehicle::Key::type
Type type
The positioning system this vehicle belongs to.
Definition: space_vehicle.h:54
com::ubuntu::location::SpaceVehicle::Key::id
Id id
Unique id of the space vehicle.
Definition: space_vehicle.h:55
com::ubuntu::location::SpaceVehicle
A space-vehicle as visible to providers.
Definition: space_vehicle.h:34
com::ubuntu::location::SpaceVehicle::key
Key key
Unique key identifying an instance.
Definition: space_vehicle.h:86
com::ubuntu::location::SpaceVehicle::has_ephimeris_data
bool has_ephimeris_data
Ephimeris data is available for this vehicle.
Definition: space_vehicle.h:89
com::ubuntu::location::SpaceVehicle::operator==
bool operator==(const SpaceVehicle &rhs) const
Definition: space_vehicle.h:71
com::ubuntu::location::SpaceVehicle::Id
std::uint32_t Id
Numeric Id of an individual SpaceVehicle.
Definition: space_vehicle.h:36
com::ubuntu::location::SpaceVehicle::snr
float snr
Signal to noise ratio;.
Definition: space_vehicle.h:87
com::ubuntu::location::SpaceVehicle::used_in_fix
bool used_in_fix
This vehicle has been used to obtain a fix.
Definition: space_vehicle.h:90
com::ubuntu::location::SpaceVehicle::azimuth
units::Quantity< units::PlaneAngle > azimuth
Azimuth of SV.
Definition: space_vehicle.h:91
com::ubuntu::location::SpaceVehicle::elevation
units::Quantity< units::PlaneAngle > elevation
Elevation of SV.
Definition: space_vehicle.h:92
com::ubuntu::location::SpaceVehicle::Type
Type
Enumerates all known space-vehicle types.
Definition: space_vehicle.h:40
com::ubuntu::location::SpaceVehicle::Type::gps
@ gps
Fully operational worldwide.
com::ubuntu::location::SpaceVehicle::Type::galileo
@ galileo
A global system being developed by the European Union and other partner countries,...
com::ubuntu::location::SpaceVehicle::Type::qzss
@ qzss
Japanese regional system covering Asia and Oceania.
com::ubuntu::location::SpaceVehicle::Type::compass
@ compass
People's Republic of China's global system, planned to be operational by 2020.
com::ubuntu::location::SpaceVehicle::Type::glonass
@ glonass
Russia's global navigation system. Fully operational worldwide.
com::ubuntu::location::SpaceVehicle::Type::unknown
@ unknown
Unknown (and thus invalid) type.
com::ubuntu::location::SpaceVehicle::Type::irnss
@ irnss
India's regional navigation system, planned to be operational by 2014, covering India and Northern In...
com::ubuntu::location::SpaceVehicle::Type::beidou
@ beidou
People's Republic of China's regional system, currently limited to Asia and the West Pacific.
com::ubuntu::location::SpaceVehicle::operator<
bool operator<(const SpaceVehicle &rhs) const
Definition: space_vehicle.h:81
com::ubuntu::location::SpaceVehicle::has_almanac_data
bool has_almanac_data
Almanac data available for this vehicle.
Definition: space_vehicle.h:88
units.h