summaryrefslogtreecommitdiffstats
path: root/desktop-widgets/importgps.h
diff options
context:
space:
mode:
authorGravatar Willem Ferguson <willemferguson@zoology.up.ac.za>2020-01-19 12:06:50 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-01-24 09:51:02 -0800
commit1ecd5065a0f821bb9406b5f651ebf6db5d6c2040 (patch)
tree005526bde95db900712a9de2e37d1f9886305c0b /desktop-widgets/importgps.h
parent1f51251f1b80304d65c36b46cfa84ba892a62683 (diff)
downloadsubsurface-1ecd5065a0f821bb9406b5f651ebf6db5d6c2040.tar.gz
Desktop: Import dive coordinates directly from GPS
This allows Subsurface to obtain the coordinates of a dive directly from a GPS track. It parses a GPX file (GPX V1.0 or V1.1) from a GPS to locate the trackpoint immediatedly after the start of a dive. There is an additional "Use GPS file" button in the Edit Dive Site panel that is selected from the Notes tab. Image: This allows one to select a GPX file, bringing up the Import GPS dialog. There is extensive provision for cross-checking that the dive track synchronises with the dive start and end. If the Save button in the dialog is pressed the dive coordinates are copied into the Dive Coordinates text box in the Edit Dive Site panel. The map moves to indicate the location of the dive site. The bulk of the work is done in importgps.cpp. The code is pretty intergrated: I tried to break it up in smaller commits but that was not feasible. The code includes responses to the comments by @neolit123 and @bstoeger. The C-based file input was replaced with Qt-based code using QChar, QString and QFile. [Dirk Hohndel: fixed several small issues in the .ui file, removed various headers includes that weren't needed and fixed printing of minutes as zero padded] Signed-off-by: willemferguson <willemferguson@zoology.up.ac.za> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'desktop-widgets/importgps.h')
-rw-r--r--desktop-widgets/importgps.h49
1 files changed, 49 insertions, 0 deletions
diff --git a/desktop-widgets/importgps.h b/desktop-widgets/importgps.h
new file mode 100644
index 000000000..1cef9e57a
--- /dev/null
+++ b/desktop-widgets/importgps.h
@@ -0,0 +1,49 @@
+// SPDX-License-Identifier: GPL-2.0
+#ifndef IMPORT_GPS_H
+#define IMPORT_GPS_H
+
+#include "ui_importgps.h"
+#include "desktop-widgets/locationinformation.h"
+
+#include <QFile>
+
+struct dive_coords { // This structure holds important information after parsing the GPX file:
+ time_t start_dive; // Start time of the current dive, obtained using current_dive (local time)
+ time_t end_dive; // End time of current dive (local time)
+ time_t start_track; // Start time of GPX track (UCT)
+ time_t end_track; // End time of GPX track (UCT)
+ double lon; // Longitude of the first trackpoint after the start of the dive
+ double lat; // Latitude of the first trackpoint after the start of the dive
+ int64_t settingsDiff_offset; // Local time difference between dive computer and GPS equipment
+ int64_t timeZone_offset; // UCT international time zone offset of dive site
+};
+
+class ImportGPS : public QDialog {
+ Q_OBJECT
+public:
+ Ui::ImportGPS ui;
+ explicit ImportGPS(QWidget *parent, QString fileName, class Ui::LocationInformation *LocationUI);
+ struct dive_coords coords;
+ int getCoordsFromFile();
+ void updateUI();
+
+private
+slots:
+ void timeDiffEditChanged();
+ void timeZoneEditChanged();
+ void changeZoneForward();
+ void changeZoneBackwards();
+ void changeDiffForward();
+ void changeDiffBackwards();
+ void buttonClicked(QAbstractButton *button);
+
+private:
+ QString fileName;
+ class Ui::LocationInformation *LocationUI;
+ int getSubstring(QFile *f, QString *buf, char delim);
+ int findXmlElement(QFile *f, QString target, QString *buf, char termc);
+ int pixmapSize;
+};
+
+#endif
+