diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2013-06-05 11:46:57 +0900 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-06-05 12:16:34 +0900 |
commit | 6f979b48edf0e264a209e99d2164c7b4e8d925f4 (patch) | |
tree | 06b6ca8e1c64e1eafd65aaec13db57e7ac4303aa | |
parent | 9dab88611757db54d2f534e96b840a42a914b255 (diff) | |
download | subsurface-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>
-rw-r--r-- | qt-ui/globe.cpp | 22 | ||||
-rw-r--r-- | qt-ui/globe.h | 1 |
2 files changed, 16 insertions, 7 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); } } diff --git a/qt-ui/globe.h b/qt-ui/globe.h index 167cdf292..44e50b6ed 100644 --- a/qt-ui/globe.h +++ b/qt-ui/globe.h @@ -26,7 +26,6 @@ protected: private: GeoDataDocument *loadedDives; - QStringList diveLocations; struct dive* editingDiveCoords; KMessageWidget* messageWidget; |