Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qgeosatelliteinfo.cpp
Go to the documentation of this file.
1
// Copyright (C) 2016 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
// Qt-Security score:significant reason:default
4
#
include
"qgeosatelliteinfo.h"
5
#
include
"private/qgeosatelliteinfo_p.h"
6
7
#
include
<
QHash
>
8
#
include
<
QDebug
>
9
#
include
<
QDataStream
>
10
11
QT_BEGIN_NAMESPACE
12
13
QT_IMPL_METATYPE_EXTERN(QGeoSatelliteInfo)
14
15
/*!
16
\class QGeoSatelliteInfo
17
\inmodule QtPositioning
18
\ingroup QtPositioning-positioning
19
\ingroup shared
20
\since 5.2
21
22
\brief The QGeoSatelliteInfo class contains basic information about a satellite.
23
24
\sa QGeoSatelliteInfoSource
25
*/
26
27
/*!
28
\enum QGeoSatelliteInfo::Attribute
29
Defines the attributes for the satellite information.
30
\value Elevation The elevation of the satellite, in degrees.
31
\value Azimuth The azimuth to true north, in degrees.
32
*/
33
34
/*!
35
\enum QGeoSatelliteInfo::SatelliteSystem
36
Defines the GNSS system of the satellite.
37
\value Undefined Not defined.
38
\value GPS Global Positioning System (USA).
39
\value GLONASS Global Positioning System (Russia).
40
\value GALILEO Global navigation satellite system (EU).
41
\value BEIDOU BeiDou navigation satellite system (China).
42
\value QZSS Quasi-Zenith Satellite System (Japan).
43
\value [since 6.12] IRNSS Indian Regional Navigation Satellite System.
44
\value [since 6.12] SBAS Satellite-based augmentation system.
45
\value Multiple This type normally indicates that the information is
46
received from a device that supports multiple satellite systems, and
47
the satellite system is not explicitly specified. Depending on the
48
data source, you might use other information to determine the actual
49
system type. One example of the usage of this type is an NMEA $GNGSA
50
message, which contains the IDs of the satellites being used, but
51
does not explicitly mention their system types.
52
\value CustomType The first type that can be used for user purposes. For
53
example when reimplementing NMEA data parsing in
54
\l QNmeaSatelliteInfoSource. User can add more types using
55
\c {CustomType + 1}, \c {CustomType + 2} and so on.
56
*/
57
58
/*!
59
Creates a satellite information object.
60
*/
61
QGeoSatelliteInfo::QGeoSatelliteInfo()
62
: d(
new
QGeoSatelliteInfoPrivate)
63
{
64
d->signal = -1;
65
d->satId = -1;
66
d->system = QGeoSatelliteInfo::Undefined;
67
}
68
69
/*!
70
Creates a satellite information object with the values of \a other.
71
*/
72
73
QGeoSatelliteInfo::QGeoSatelliteInfo(
const
QGeoSatelliteInfo &other)
74
: d(other.d)
75
{
76
}
77
78
QGeoSatelliteInfo::QGeoSatelliteInfo(QGeoSatelliteInfoPrivate &dd) : d(&dd)
79
{
80
}
81
82
/*!
83
\fn QGeoSatelliteInfo::QGeoSatelliteInfo(QGeoSatelliteInfo &&other) noexcept
84
\since 6.2
85
86
Creates a satellite information object by moving from \a other.
87
88
Note that a moved-from QGeoSatelliteInfo can only be destroyed or
89
assigned to. The effect of calling other functions than the destructor
90
or one of the assignment operators is undefined.
91
*/
92
93
/*!
94
Destroys a satellite information object.
95
*/
96
QGeoSatelliteInfo::~QGeoSatelliteInfo()
97
{
98
}
99
100
QT_DEFINE_QESDP_SPECIALIZATION_DTOR(QGeoSatelliteInfoPrivate)
101
102
/*!
103
Assigns the values from \a other to this object.
104
*/
105
QGeoSatelliteInfo &QGeoSatelliteInfo::operator=(
const
QGeoSatelliteInfo & other)
106
{
107
if
(
this
== &other)
108
return
*
this
;
109
110
d = other.d;
111
return
*
this
;
112
}
113
114
/*!
115
\fn QGeoSatelliteInfo &QGeoSatelliteInfo::operator=(QGeoSatelliteInfo &&other) noexcept
116
\since 6.2
117
118
Move-assigns the value from \a other to this object
119
120
Note that a moved-from QGeoSatelliteInfo can only be destroyed or
121
assigned to. The effect of calling other functions than the destructor
122
or one of the assignment operators is undefined.
123
*/
124
125
/*!
126
\fn bool QGeoSatelliteInfo::operator==(const QGeoSatelliteInfo &lhs, const QGeoSatelliteInfo &rhs)
127
128
Returns \c true if all the parameters of the \a lhs satellite are the same
129
as those of \a rhs. Otherwise returns \c false.
130
*/
131
132
/*!
133
\fn bool QGeoSatelliteInfo::operator!=(const QGeoSatelliteInfo &lhs, const QGeoSatelliteInfo &rhs)
134
135
Returns \c true if any of the parameters of the \a lhs satellite are not
136
the same as those of \a rhs. Otherwise returns \c false.
137
*/
138
139
/*!
140
\fn void QGeoSatelliteInfo::swap(QGeoSatelliteInfo &other)
141
\since 6.2
142
\memberswap{satellite information}
143
*/
144
145
/*!
146
Sets the Satellite System (GPS, GLONASS, ...) to \a system.
147
*/
148
void
QGeoSatelliteInfo::setSatelliteSystem(SatelliteSystem system)
149
{
150
d.detach();
151
d->system = system;
152
}
153
154
/*!
155
\property QGeoSatelliteInfo::satelliteSystem
156
\brief the satellite system in use, such as GPS or GLONASS.
157
158
Returns the Satellite System (GPS, GLONASS, ...)
159
\note This value can be used together with \l satelliteIdentifier
160
to uniquely identify a satellite.
161
162
\sa satelliteIdentifier
163
*/
164
QGeoSatelliteInfo::SatelliteSystem QGeoSatelliteInfo::satelliteSystem()
const
165
{
166
return
d->system;
167
}
168
169
/*!
170
Sets the satellite identifier number to \a satId.
171
172
The satellite identifier number can be used to identify a satellite within
173
the satellite system.
174
175
The actual value may vary, depending on the platform and the selected
176
backend.
177
178
For example, if \e nmea plugin is used, the satellite identifier for GPS
179
satellite system represents the PRN (Pseudo-random noise) number, and the
180
satellite identifier for GLONASS satellite system represents the slot
181
number.
182
*/
183
void
QGeoSatelliteInfo::setSatelliteIdentifier(
int
satId)
184
{
185
d.detach();
186
d->satId = satId;
187
}
188
189
/*!
190
\property QGeoSatelliteInfo::satelliteIdentifier
191
\brief the satellite identifier number.
192
193
The satellite identifier number can be used to identify a satellite within
194
the satellite system.
195
196
The actual value may vary, depending on the platform and the selected
197
backend.
198
199
For example, if \e nmea plugin is used, the satellite identifier for GPS
200
satellite system represents the PRN (Pseudo-random noise) number, and the
201
satellite identifier for GLONASS satellite system represents the slot
202
number.
203
204
For NMEA-based backends the satellite identifier can be used to determine
205
the satellite system type if it is not available from other sources.
206
You can refer to \l {https://gpsd.gitlab.io/gpsd/NMEA.html#_satellite_ids}
207
{satellite IDs list} to check the ID ranges for different satellite systems.
208
209
\note Depending on the platform and the selected backend, the satellite
210
identifier ranges for different satellite systems may intersect. To uniquely
211
identify a satellite, a combination of satelliteIndetifier() and
212
\l satelliteSystem() must be used.
213
*/
214
215
/*!
216
Returns the satellite identifier number.
217
218
\sa satelliteSystem()
219
*/
220
int
QGeoSatelliteInfo::satelliteIdentifier()
const
221
{
222
return
d->satId;
223
}
224
225
/*!
226
Sets the signal strength to \a signalStrength, in decibels.
227
*/
228
void
QGeoSatelliteInfo::setSignalStrength(
int
signalStrength)
229
{
230
d.detach();
231
d->signal = signalStrength;
232
}
233
234
/*!
235
\property QGeoSatelliteInfo::signalStrength
236
\brief the signal strength.
237
*/
238
239
/*!
240
Returns the signal strength, or -1 if the value has not been set.
241
*/
242
int
QGeoSatelliteInfo::signalStrength()
const
243
{
244
return
d->signal;
245
}
246
247
/*!
248
Sets the value for \a attribute to \a value.
249
*/
250
void
QGeoSatelliteInfo::setAttribute(Attribute attribute, qreal value)
251
{
252
d.detach();
253
d->doubleAttribs[attribute] = value;
254
}
255
256
/*!
257
Returns the value of the specified \a attribute as a qreal value.
258
259
Returns -1 if the value has not been set.
260
261
\sa hasAttribute(), setAttribute()
262
*/
263
qreal QGeoSatelliteInfo::attribute(Attribute attribute)
const
264
{
265
return
d->doubleAttribs.value(attribute, -1);
266
}
267
268
/*!
269
Removes the specified \a attribute and its value.
270
*/
271
void
QGeoSatelliteInfo::removeAttribute(Attribute attribute)
272
{
273
const
auto
it = d->doubleAttribs.constFind(attribute);
274
if
(it != d->doubleAttribs.cend()) {
275
d.detach();
276
d->doubleAttribs.erase(it);
277
}
278
}
279
280
/*!
281
Returns true if the specified \a attribute is present in this update.
282
*/
283
bool
QGeoSatelliteInfo::hasAttribute(Attribute attribute)
const
284
{
285
return
d->doubleAttribs.contains(attribute);
286
}
287
288
/*!
289
\internal
290
*/
291
void
QGeoSatelliteInfo::detach()
292
{
293
if
(d)
294
d.detach();
295
else
296
d =
new
QGeoSatelliteInfoPrivate;
297
}
298
299
bool
QGeoSatelliteInfo::equals(
const
QGeoSatelliteInfo &lhs,
const
QGeoSatelliteInfo &rhs)
300
{
301
return
*lhs.d == *rhs.d;
302
}
303
304
#
ifndef
QT_NO_DEBUG_STREAM
305
QDebug QGeoSatelliteInfo::debugStreaming(QDebug dbg,
const
QGeoSatelliteInfo &info)
306
{
307
QDebugStateSaver saver(dbg);
308
dbg.nospace() <<
"QGeoSatelliteInfo(system="
<< info.d->system;
309
dbg <<
", satId="
<< info.d->satId;
310
dbg <<
", signal-strength="
<< info.d->signal;
311
312
313
const
QList<QGeoSatelliteInfo::Attribute> attribs = info.d->doubleAttribs.keys();
314
for
(qsizetype i = 0; i < attribs.size(); ++i) {
315
dbg <<
", "
;
316
switch
(attribs[i]) {
317
case
QGeoSatelliteInfo::Elevation:
318
dbg <<
"Elevation="
;
319
break
;
320
case
QGeoSatelliteInfo::Azimuth:
321
dbg <<
"Azimuth="
;
322
break
;
323
}
324
dbg << info.d->doubleAttribs[attribs[i]];
325
}
326
dbg <<
')'
;
327
return
dbg;
328
}
329
#
endif
// QT_NO_DEBUG_STREAM
330
331
#
ifndef
QT_NO_DATASTREAM
332
/*!
333
\fn QDataStream &QGeoSatelliteInfo::operator<<(QDataStream &stream, const QGeoSatelliteInfo &info)
334
335
Writes the given \a info to the specified \a stream.
336
337
\sa {Serializing Qt Data Types}
338
339
*/
340
341
QDataStream &QGeoSatelliteInfo::dataStreamOut(QDataStream &stream,
const
QGeoSatelliteInfo &info)
342
{
343
stream << info.d->signal;
344
stream << info.d->doubleAttribs;
345
stream << info.d->satId;
346
stream <<
int
(info.d->system);
347
return
stream;
348
}
349
#
endif
// QT_NO_DATASTREAM
350
351
#
ifndef
QT_NO_DATASTREAM
352
/*!
353
\fn QDataStream &QGeoSatelliteInfo::operator>>(QDataStream &stream, QGeoSatelliteInfo &info)
354
355
Reads satellite information from the specified \a stream into the given
356
\a info.
357
358
\sa {Serializing Qt Data Types}
359
*/
360
361
QDataStream &QGeoSatelliteInfo::dataStreamIn(QDataStream &stream, QGeoSatelliteInfo &info)
362
{
363
int
system;
364
stream >> info.d->signal;
365
stream >> info.d->doubleAttribs;
366
stream >> info.d->satId;
367
stream >> system;
368
info.d->system = (QGeoSatelliteInfo::SatelliteSystem)system;
369
return
stream;
370
}
371
#
endif
// QT_NO_DATASTREAM
372
373
QGeoSatelliteInfoPrivate::QGeoSatelliteInfoPrivate() : QSharedData()
374
{
375
376
}
377
378
QGeoSatelliteInfoPrivate::QGeoSatelliteInfoPrivate(
const
QGeoSatelliteInfoPrivate &other)
379
: QSharedData(other)
380
{
381
signal = other.signal;
382
satId = other.satId;
383
system = other.system;
384
doubleAttribs = other.doubleAttribs;
385
}
386
387
QGeoSatelliteInfoPrivate::~QGeoSatelliteInfoPrivate() {}
388
389
bool
QGeoSatelliteInfoPrivate::operator==(
const
QGeoSatelliteInfoPrivate &other)
const
390
{
391
return
signal == other.signal
392
&& satId == other.satId
393
&& system == other.system
394
&& doubleAttribs == other.doubleAttribs;
395
}
396
397
QGeoSatelliteInfoPrivate *QGeoSatelliteInfoPrivate::get(
const
QGeoSatelliteInfo &info)
398
{
399
return
info.d.data();
400
}
401
402
size_t
qHash
(
const
QGeoSatelliteInfo &key, size_t seed)
noexcept
403
{
404
// Other properties and attributes might change
405
return
qHashMulti(seed, key.d->satId, key.d->system);
406
}
407
408
namespace
QTest
409
{
410
411
char
*
toString
(
const
QGeoSatelliteInfo &info)
412
{
413
QString result;
414
QDebug dbg(&result);
415
dbg << info;
416
417
return
qstrdup(qPrintable(result));
418
}
419
420
}
421
422
423
QT_END_NAMESPACE
QTest
[15]
Definition
qtestsupport_core.h:15
QTest::toString
char * toString(const QGeoSatelliteInfo &info)
Definition
qgeosatelliteinfo.cpp:411
qHash
size_t qHash(const QGeoSatelliteInfo &key, size_t seed) noexcept
Definition
qgeosatelliteinfo.cpp:402
qtpositioning
src
positioning
qgeosatelliteinfo.cpp
Generated on
for Qt by
1.18.0