1 /****************************************************************************
2 **
3 ** Copyright (C) 2016 The Qt Company Ltd.
4 ** Contact: https://www.qt.io/licensing/
5 **
6 ** This file is part of the QtPositioning module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and The Qt Company. For licensing terms
14 ** and conditions see https://www.qt.io/terms-conditions. For further
15 ** information use the contact form at https://www.qt.io/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 3 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL3 included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 3 requirements
23 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24 **
25 ** GNU General Public License Usage
26 ** Alternatively, this file may be used under the terms of the GNU
27 ** General Public License version 2.0 or (at your option) the GNU General
28 ** Public license version 3 or any later version approved by the KDE Free
29 ** Qt Foundation. The licenses are as published by the Free Software
30 ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31 ** included in the packaging of this file. Please review the following
32 ** information to ensure the GNU General Public License requirements will
33 ** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34 ** https://www.gnu.org/licenses/gpl-3.0.html.
35 **
36 ** $QT_END_LICENSE$
37 **
38 ****************************************************************************/
39 
40 #include "qlocationdata_simulator_p.h"
41 
42 #include <QtCore/QDataStream>
43 
44 QT_BEGIN_NAMESPACE
45 
QGeoPositionInfoData()46 QGeoPositionInfoData::QGeoPositionInfoData()
47     : latitude(0.0),
48       longitude(0.0),
49       altitude(0.0),
50       direction(0.0),
51       groundSpeed(0.0),
52       verticalSpeed(0.0),
53       magneticVariation(0.0),
54       horizontalAccuracy(0.0),
55       verticalAccuracy(0.0),
56       dateTime(),
57       minimumInterval(0),
58       enabled(false) {}
59 
SatelliteInfo()60 QGeoSatelliteInfoData::SatelliteInfo::SatelliteInfo()
61     : azimuth(0.0),
62       elevation(0.0),
63       signalStrength(0),
64       inUse(false),
65       satelliteSystem(Undefined),
66       satelliteIdentifier(0) {}
67 
qt_registerLocationTypes()68 void qt_registerLocationTypes()
69 {
70     qRegisterMetaTypeStreamOperators<QGeoPositionInfoData>("QGeoPositionInfoData");
71     qRegisterMetaTypeStreamOperators<QGeoSatelliteInfoData>("QGeoSatelliteInfoData");
72     qRegisterMetaTypeStreamOperators<QGeoSatelliteInfoData::SatelliteInfo>("QGeoSatelliteInfoData::SatelliteInfo");
73 }
74 
operator <<(QDataStream & out,const QGeoPositionInfoData & s)75 QDataStream &operator<<(QDataStream &out, const QGeoPositionInfoData &s)
76 {
77     out << s.latitude << s.longitude << s.altitude;
78     out << s.direction << s.groundSpeed << s.verticalSpeed << s.magneticVariation << s.horizontalAccuracy << s.verticalAccuracy;
79     out << s.dateTime;
80     out << s.minimumInterval << s.enabled;
81     return out;
82 }
83 
operator >>(QDataStream & in,QGeoPositionInfoData & s)84 QDataStream &operator>>(QDataStream &in, QGeoPositionInfoData &s)
85 {
86     in >> s.latitude >> s.longitude >> s.altitude;
87     in >> s.direction >> s.groundSpeed >> s.verticalSpeed >> s.magneticVariation >> s.horizontalAccuracy >> s.verticalAccuracy;
88     in >> s.dateTime;
89     in >> s.minimumInterval >> s.enabled;
90     return in;
91 }
92 
operator <<(QDataStream & out,const QGeoSatelliteInfoData & s)93 QDataStream &operator<<(QDataStream &out, const QGeoSatelliteInfoData &s)
94 {
95     out << s.satellites;
96     return out;
97 }
98 
operator >>(QDataStream & in,QGeoSatelliteInfoData & s)99 QDataStream &operator>>(QDataStream &in, QGeoSatelliteInfoData &s)
100 {
101     in >> s.satellites;
102     return in;
103 }
104 
operator <<(QDataStream & out,const QGeoSatelliteInfoData::SatelliteInfo & s)105 QDataStream &operator<<(QDataStream &out, const QGeoSatelliteInfoData::SatelliteInfo &s)
106 {
107     out << s.azimuth << s.elevation << s.signalStrength << s.inUse << static_cast<qint32>(s.satelliteSystem) << s.satelliteIdentifier;
108     return out;
109 }
110 
operator >>(QDataStream & in,QGeoSatelliteInfoData::SatelliteInfo & s)111 QDataStream &operator>>(QDataStream &in, QGeoSatelliteInfoData::SatelliteInfo &s)
112 {
113     qint32 satelliteSystem;
114     in >> s.azimuth >> s.elevation >> s.signalStrength >> s.inUse >> satelliteSystem >> s.satelliteIdentifier;
115     s.satelliteSystem = static_cast<QGeoSatelliteInfoData::SatelliteInfo::SatelliteSystem>(satelliteSystem);
116     return in;
117 }
118 
119 QT_END_NAMESPACE
120