summaryrefslogtreecommitdiffstats
path: root/qt-ui/globe.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2013-06-05 11:46:57 +0900
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-06-05 12:16:34 +0900
commit6f979b48edf0e264a209e99d2164c7b4e8d925f4 (patch)
tree06b6ca8e1c64e1eafd65aaec13db57e7ac4303aa /qt-ui/globe.cpp
parent9dab88611757db54d2f534e96b840a42a914b255 (diff)
downloadsubsurface-6f979b48edf0e264a209e99d2164c7b4e8d925f4.tar.gz
Show locations with same name on the map if they are more than 50m apart
Not showing them at all was a little too blunt of an instrument. There likely are dive spots with the same name at different resorts. And even at the same resort you could have multiple morings for the same dive site. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/globe.cpp')
-rw-r--r--qt-ui/globe.cpp22
1 files changed, 16 insertions, 6 deletions
diff --git a/qt-ui/globe.cpp b/qt-ui/globe.cpp
index 67a4fcd73..0bd2db423 100644
--- a/qt-ui/globe.cpp
+++ b/qt-ui/globe.cpp
@@ -11,6 +11,7 @@
#include <marble/MarbleModel.h>
#include <marble/MarbleDirs.h>
#include <marble/MapThemeManager.h>
+#include <marble/GeoDataLineString.h>
#if INCOMPLETE_MARBLE
#include "marble/GeoDataTreeModel.h"
#else
@@ -69,19 +70,28 @@ void GlobeGPS::reload()
}
loadedDives = new GeoDataDocument;
+ QMap<QString, GeoDataPlacemark *> locationMap;
- diveLocations.clear();
int idx = 0;
struct dive *dive;
for_each_dive(idx, dive) {
if (dive_has_gps_location(dive)) {
- // don't add dive locations twice.
- if (diveLocations.contains(QString(dive->location)))
- continue;
-
- diveLocations.append(QString(dive->location));
GeoDataPlacemark *place = new GeoDataPlacemark(dive->location);
place->setCoordinate(dive->longitude.udeg / 1000000.0,dive->latitude.udeg / 1000000.0 , 0, GeoDataCoordinates::Degree);
+ // don't add dive locations twice, unless they are at least 50m apart
+ if (locationMap[QString(dive->location)]) {
+ GeoDataPoint existingLocation = locationMap[QString(dive->location)]->coordinate();
+ GeoDataLineString segment = GeoDataLineString();
+ segment.append(existingLocation);
+ GeoDataPoint newLocation = place->coordinate();
+ segment.append(newLocation);
+ double dist = segment.length(6371);
+ // the dist is scaled to the radius given - so with 6371km as radius
+ // 50m turns into 0.05 as threashold
+ if (dist < 0.05)
+ continue;
+ }
+ locationMap[QString(dive->location)] = place;
loadedDives->append(place);
}
}