Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100755 76 lines (63 sloc) 2.792 kB
42aa391 Removed deprecated code (append_to_xml); \n Added read_from_xml(); \n…
Clovis Scotti authored
1 /*
2 * Copyright (c) 2011 Nokia Corporation
3 *
4 * This file is part of the Push Snowboarding Project, More info at:
5 * www.pushsnowboading.com
6 *
7 * Author: Clovis Scotti <scotti@ieee.org>
8 *
9 * This program is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation, either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 *
26 */
27
28 #include "npushgpstick.h"
29
30 NPushGpsTick::NPushGpsTick(const QGeoPositionInfo &info)
31 {
32 tick = info;
33 // QDateTime correctedTstamp;
34 // correctedTstamp = tick.timestamp().addSecs(3600);
35 // tick.setTimestamp(correctedTstamp);
36 }
37
38 NPushGpsTick::~NPushGpsTick()
39 {
40 }
41
42 void NPushGpsTick::read_from_xml( QXmlStreamReader& xml)
43 {
44 QDateTime tstamp;
45 QGeoCoordinate fakeCoord;
46
47 fakeCoord.setAltitude(xml.attributes().value("altitude").toString().toDouble());
48 fakeCoord.setLatitude(xml.attributes().value("latitude").toString().toDouble());
49 fakeCoord.setLongitude(xml.attributes().value("longitude").toString().toDouble());
50
51 tstamp = QDateTime::fromTime_t(floor(xml.attributes().value("tstamp").toString().toDouble()));//+3600.0));
52
53 tick.setTimestamp(tstamp);
54 tick.setCoordinate(fakeCoord);
55
56 tick.setAttribute(QGeoPositionInfo::GroundSpeed, xml.attributes().value("ground_speed").toString().toFloat());
57
58 }
59
60 void NPushGpsTick::dump_to_xml(QXmlStreamWriter& xml) const
61 {
62 xml.writeStartElement("gps_data");
63 xml.writeAttribute("tstamp", QString::number(tick.timestamp().toTime_t()));
64 xml.writeAttribute("longitude", QString::number(tick.coordinate().longitude()));
65 xml.writeAttribute("latitude", QString::number(tick.coordinate().latitude()));
66 xml.writeAttribute("altitude", QString::number(tick.coordinate().altitude()));
67 xml.writeAttribute("ground_speed", QString::number(tick.attribute(QGeoPositionInfo::GroundSpeed)));
68
69 xml.writeEndElement();//gps_data
70 }
71
72 QString NPushGpsTick::get_pretty_print() const
73 {
74 return QString("Speed = %1, Alt = %2").arg(QString::number(tick.attribute(QGeoPositionInfo::GroundSpeed)*3.6)).arg(QString::number(tick.coordinate().altitude()));
75 }
Something went wrong with that request. Please try again.