summaryrefslogtreecommitdiffstats
path: root/qt-ui/globe.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2015-06-10 11:45:34 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-06-10 11:51:15 -0700
commitd541c2b601a82aad7ae8e0e419b172cc32f24a84 (patch)
treefd488a7983c0e27c274541676dfedcdd62cb3c04 /qt-ui/globe.cpp
parent1ee447b5a95e97f5eb409ce67b0b06464138e572 (diff)
downloadsubsurface-d541c2b601a82aad7ae8e0e419b172cc32f24a84.tar.gz
Add helper function to determine the distance between two points
And use this to find a dive site within a certain radius of a GPS fix. This will be used to figure out if dive sites might be the same. This uses a new Qt5 component (Positioning) which was added in Qt5.2. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/globe.cpp')
-rw-r--r--qt-ui/globe.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/qt-ui/globe.cpp b/qt-ui/globe.cpp
index b8e0ec87e..76d48b7ba 100644
--- a/qt-ui/globe.cpp
+++ b/qt-ui/globe.cpp
@@ -1,4 +1,5 @@
#include "globe.h"
+#include <QGeoCoordinate>
#ifndef NO_MARBLE
#include "mainwindow.h"
#include "helpers.h"
@@ -392,3 +393,10 @@ void GlobeGPS::reload()
{
}
#endif
+
+extern "C" double getDistance(int lat1, int lon1, int lat2, int lon2)
+{
+ QGeoCoordinate c1(lat1 / 1000000.0, lon1 / 1000000.0);
+ QGeoCoordinate c2(lat2 / 1000000.0, lon2 / 1000000.0);
+ return c1.distanceTo(c2);
+}