summaryrefslogtreecommitdiff
path: root/src/location/maps/qgeocameratiles.cpp
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@digia.com>2013-10-22 14:37:37 +0200
committerAlex Blasche <alexander.blasche@digia.com>2013-10-22 14:38:06 +0200
commit71dffcd319c2641e1022bf857f9c72671cb1446a (patch)
tree84a7685d0c174a6c461c06aed60a2961a7d3f8fb /src/location/maps/qgeocameratiles.cpp
parent2867f1efc989478667ea7ae56ff91cd991d74121 (diff)
parent654b01af941ec620ca8a9b98be8542dda862d4a8 (diff)
downloadqtlocation-71dffcd319c2641e1022bf857f9c72671cb1446a.tar.gz
Merge branch 'stable' into dev
Conflicts: src/imports/location/qdeclarativegeomap.cpp src/imports/location/qdeclarativegeoroute.cpp src/imports/location/qdeclarativegeoroutemodel.cpp src/imports/location/qdeclarativegeoroutesegment.cpp src/imports/location/qdeclarativepolygonmapitem.cpp src/imports/location/qdeclarativepolylinemapitem.cpp src/imports/positioning/positioning.cpp Change-Id: Ieaa5f567d2144d0267e7eef5bd75bde7e0079fbe
Diffstat (limited to 'src/location/maps/qgeocameratiles.cpp')
-rw-r--r--src/location/maps/qgeocameratiles.cpp74
1 files changed, 72 insertions, 2 deletions
diff --git a/src/location/maps/qgeocameratiles.cpp b/src/location/maps/qgeocameratiles.cpp
index 050e7fc3..32bbae36 100644
--- a/src/location/maps/qgeocameratiles.cpp
+++ b/src/location/maps/qgeocameratiles.cpp
@@ -53,6 +53,7 @@
#include <QDebug>
+#include <algorithm>
#include <cmath>
QT_BEGIN_NAMESPACE
@@ -413,6 +414,74 @@ void QGeoCameraTilesPrivate::appendZIntersects(const QDoubleVector3D &start,
}
}
+/***************************************************/
+/* Local copy of qSort & qSortHelper to suppress deprecation warnings
+ * following the deprecation of QtAlgorithms. The comparison has subtle
+ * differences which eluded detection so far. We just reuse old qSort for now.
+ **/
+
+template <typename RandomAccessIterator, typename LessThan>
+inline void localqSort(RandomAccessIterator start, RandomAccessIterator end, LessThan lessThan)
+{
+ if (start != end)
+ localqSortHelper(start, end, *start, lessThan);
+}
+
+template <typename RandomAccessIterator, typename T, typename LessThan>
+void localqSortHelper(RandomAccessIterator start, RandomAccessIterator end, const T &t, LessThan lessThan)
+{
+top:
+ int span = int(end - start);
+ if (span < 2)
+ return;
+
+ --end;
+ RandomAccessIterator low = start, high = end - 1;
+ RandomAccessIterator pivot = start + span / 2;
+
+ if (lessThan(*end, *start))
+ qSwap(*end, *start);
+ if (span == 2)
+ return;
+
+ if (lessThan(*pivot, *start))
+ qSwap(*pivot, *start);
+ if (lessThan(*end, *pivot))
+ qSwap(*end, *pivot);
+ if (span == 3)
+ return;
+
+ qSwap(*pivot, *end);
+
+ while (low < high) {
+ while (low < high && lessThan(*low, *end))
+ ++low;
+
+ while (high > low && lessThan(*end, *high))
+ --high;
+
+ if (low < high) {
+ qSwap(*low, *high);
+ ++low;
+ --high;
+ } else {
+ break;
+ }
+ }
+
+ if (lessThan(*low, *end))
+ ++low;
+
+ qSwap(*end, *low);
+ localqSortHelper(start, low, t, lessThan);
+
+ start = low + 1;
+ ++end;
+ goto top;
+}
+/***************************************************/
+
+
// Returns the intersection of the plane of the map and the camera frustum as a right handed polygon
Polygon QGeoCameraTilesPrivate::frustumFootprint(const Frustum &frustum) const
{
@@ -443,7 +512,8 @@ Polygon QGeoCameraTilesPrivate::frustumFootprint(const Frustum &frustum) const
// - initial sort to remove duplicates
sorter.base = points.first();
- qSort(points.begin(), points.end(), sorter);
+ localqSort(points.begin(), points.end(), sorter);
+ //std::sort(points.begin(), points.end(), sorter);
for (int i = points.size() - 1; i > 0; --i) {
if (points.at(i) == points.at(i - 1))
points.remove(i);
@@ -457,7 +527,7 @@ Polygon QGeoCameraTilesPrivate::frustumFootprint(const Frustum &frustum) const
for (i = points.begin(); i != points.end(); ++i) {
sorter.base = *i;
if (i + 1 != points.end())
- qSort(i + 1, points.end(), sorter);
+ std::sort(i + 1, points.end(), sorter) ;
}
// - determine if what we have is right handed