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>
This commit is contained in:
Dirk Hohndel 2015-06-10 11:45:34 -07:00
parent 1ee447b5a9
commit d541c2b601
5 changed files with 36 additions and 2 deletions

View file

@ -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);
}