From d541c2b601a82aad7ae8e0e419b172cc32f24a84 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Wed, 10 Jun 2015 11:45:34 -0700 Subject: 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 --- qt-ui/globe.cpp | 8 ++++++++ qt-ui/globe.h | 3 +++ 2 files changed, 11 insertions(+) (limited to 'qt-ui') 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 #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); +} diff --git a/qt-ui/globe.h b/qt-ui/globe.h index 903b9f89c..1791e0ff3 100644 --- a/qt-ui/globe.h +++ b/qt-ui/globe.h @@ -74,4 +74,7 @@ slots: }; #endif // NO_MARBLE + +extern "C" double getDistance(int lat1, int lon1, int lat2, int lon2); + #endif // GLOBE_H -- cgit v1.2.3-70-g09d2