summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Dabrowski <[email protected]>2015-04-14 09:54:43 +0200
committerTorsten Rahn <[email protected]>2015-04-14 09:54:43 +0200
commit47eb3d5de43438acccd2820e1f9a94860c9fc4dc (patch)
tree1e2e24e14ea5884fdfe8f1929ea92685874418c7
parent7c4dcf9e0b384301df29fc062ef29c031eae45d3 (diff)
Improved placemark sorting to make layouting stable with placemarks on same zoomLevel
REVIEW: 123322
-rw-r--r--src/lib/marble/PlacemarkLayout.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/lib/marble/PlacemarkLayout.cpp b/src/lib/marble/PlacemarkLayout.cpp
index 6aa8f32..3fe3bbd 100644
--- a/src/lib/marble/PlacemarkLayout.cpp
+++ b/src/lib/marble/PlacemarkLayout.cpp
@@ -38,6 +38,20 @@
#include "VisiblePlacemark.h"
#include "MathHelper.h"
+namespace
+{
+ bool placemarkLayoutOrderCompare(const Marble::GeoDataPlacemark *left, const Marble::GeoDataPlacemark *right)
+ {
+ if (left->zoomLevel() != right->zoomLevel())
+ return (left->zoomLevel() < right->zoomLevel()); //lower zoom level comes first
+
+ if (left->popularity() != right->popularity())
+ return left->popularity() > right->popularity(); //higher popularity comes first
+
+ return left < right; //lower pointer value comes first
+ }
+}
+
namespace Marble
{
@@ -432,6 +446,7 @@ QVector<VisiblePlacemark *> PlacemarkLayout::generateLayout( const ViewportParam
foreach ( const TileId &tileId, tileIdList ) {
placemarkList += m_placemarkCache.value( tileId );
}
+ qSort(placemarkList.begin(), placemarkList.end(), placemarkLayoutOrderCompare);
foreach ( const GeoDataPlacemark *placemark, placemarkList ) {
const GeoDataCoordinates coordinates = placemarkIconCoordinates( placemark );