summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPaolo Angelelli <paolo.angelelli@qt.io>2016-12-02 18:22:12 +0100
committerPaolo Angelelli <paolo.angelelli@qt.io>2017-01-16 16:18:27 +0000
commit762dc9dd2b47f908c3739173aa1e108dd7386717 (patch)
tree201747076f1ee6deda535a6e58cafc4edaa37cbe /tests
parent45b1f2c23cf0e782c0b99f38e4d01a88da765753 (diff)
downloadqtlocation-762dc9dd2b47f908c3739173aa1e108dd7386717.tar.gz
Move the coordinate <-> item position conversion to QGeoProjection
This patch simplifies the QGeoMap API removing all the API necessary to convert to and from screen. This is now demanded to a specific QGeoProjection class, that will be independent of the map, except for using the same Geo projection (currently only WebMercator, or EPSG:3857, although we use a sphere instead of an ellipsoid, i believe) The benefits are - This relieves subclasses of QGeoMap from implementing a GeoProjection API, especially since QtLocation currently supports only WebMercator, and reimplementations would have to anyway produce the same results as the inbuilt one. - This avoids the several indirection steps previously necessary to perform a map projection (qgeotiledmap -> private->mapscene-> private). Since these operation are quite frequent one per map item coordinate at every redraw, shortening the indirection chain is beneficial - It simplifies the highly complex QGeoTiledMapScene, separating all the logic that is not needed to draw the scene, but only to perform geo coordinate <-> screen coordinate conversion Change-Id: I9e3ca5280166f2d6430a32deb44c030d02d9d4e1 Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qgeocameradata/qgeocameradata.pro2
-rw-r--r--tests/auto/qgeocameratiles/qgeocameratiles.pro2
-rw-r--r--tests/auto/qgeocameratiles/tst_qgeocameratiles.cpp8
-rw-r--r--tests/auto/qgeotiledmapscene/qgeotiledmapscene.pro2
-rw-r--r--tests/auto/qgeotiledmapscene/tst_qgeotiledmapscene.cpp18
5 files changed, 20 insertions, 12 deletions
diff --git a/tests/auto/qgeocameradata/qgeocameradata.pro b/tests/auto/qgeocameradata/qgeocameradata.pro
index f2d6d5d8..80069ea1 100644
--- a/tests/auto/qgeocameradata/qgeocameradata.pro
+++ b/tests/auto/qgeocameradata/qgeocameradata.pro
@@ -6,4 +6,4 @@ INCLUDEPATH += ../../../src/location/maps
SOURCES += tst_qgeocameradata.cpp
-QT += location positioning-private testlib
+QT += location-private positioning-private testlib
diff --git a/tests/auto/qgeocameratiles/qgeocameratiles.pro b/tests/auto/qgeocameratiles/qgeocameratiles.pro
index 816e4240..63ab2771 100644
--- a/tests/auto/qgeocameratiles/qgeocameratiles.pro
+++ b/tests/auto/qgeocameratiles/qgeocameratiles.pro
@@ -5,4 +5,4 @@ INCLUDEPATH += ../../../src/location/maps
SOURCES += tst_qgeocameratiles.cpp
-QT += location positioning-private testlib
+QT += location-private positioning-private testlib
diff --git a/tests/auto/qgeocameratiles/tst_qgeocameratiles.cpp b/tests/auto/qgeocameratiles/tst_qgeocameratiles.cpp
index 7a3ab513..33ebda67 100644
--- a/tests/auto/qgeocameratiles/tst_qgeocameratiles.cpp
+++ b/tests/auto/qgeocameratiles/tst_qgeocameratiles.cpp
@@ -28,10 +28,10 @@
//TESTED_COMPONENT=src/location/maps
-#include "qgeotilespec_p.h"
-#include "qgeocameratiles_p.h"
-#include "qgeocameradata_p.h"
-#include "qgeomaptype_p.h"
+#include <QtLocation/private/qgeotilespec_p.h>
+#include <QtLocation/private/qgeocameratiles_p.h>
+#include <QtLocation/private/qgeocameradata_p.h>
+#include <QtLocation/private/qgeomaptype_p.h>
#include <QtPositioning/private/qwebmercator_p.h>
#include <QtPositioning/private/qdoublevector2d_p.h>
diff --git a/tests/auto/qgeotiledmapscene/qgeotiledmapscene.pro b/tests/auto/qgeotiledmapscene/qgeotiledmapscene.pro
index c3ec6e91..0db4b544 100644
--- a/tests/auto/qgeotiledmapscene/qgeotiledmapscene.pro
+++ b/tests/auto/qgeotiledmapscene/qgeotiledmapscene.pro
@@ -5,4 +5,4 @@ INCLUDEPATH += ../../../src/location/maps
SOURCES += tst_qgeotiledmapscene.cpp
-QT += location positioning-private testlib
+QT += location-private positioning-private testlib
diff --git a/tests/auto/qgeotiledmapscene/tst_qgeotiledmapscene.cpp b/tests/auto/qgeotiledmapscene/tst_qgeotiledmapscene.cpp
index 0935c3f7..91b3eda8 100644
--- a/tests/auto/qgeotiledmapscene/tst_qgeotiledmapscene.cpp
+++ b/tests/auto/qgeotiledmapscene/tst_qgeotiledmapscene.cpp
@@ -33,7 +33,7 @@
#include "qgeocameratiles_p.h"
#include "qgeocameradata_p.h"
#include "qabstractgeotilecache_p.h"
-
+#include <QtLocation/private/qgeoprojection_p.h>
#include <QtPositioning/private/qwebmercator_p.h>
#include <QtPositioning/private/qdoublevector2d_p.h>
@@ -247,8 +247,8 @@ class tst_QGeoTiledMapScene : public QObject
int screenWidth;
int screenHeight;
QString name;
- tileSize = 16;
- zoom = 1.0; // 4 tiles in the map. map size = 32x32
+ tileSize = 256;
+ zoom = 1.0; // 4 tiles in the map. map size = 2*tileSize x 2*tileSize
/*
ScreenWidth = t
@@ -317,8 +317,12 @@ class tst_QGeoTiledMapScene : public QObject
mapGeometry.setCameraData(camera);
mapGeometry.setVisibleTiles(ct.createTiles());
+ QGeoProjectionWebMercator projection;
+ projection.setViewportSize(QSize(screenWidth,screenHeight));
+ projection.setCameraData(camera);
+
QDoubleVector2D point(screenX,screenY);
- QDoubleVector2D mercartorPos = mapGeometry.itemPositionToMercator(point);
+ QDoubleVector2D mercartorPos = projection.unwrapMapProjection(projection.itemPositionToWrappedMapProjection(point));
QCOMPARE(mercartorPos.x(), mercatorX);
QCOMPARE(mercartorPos.y(), mercatorY);
@@ -358,8 +362,12 @@ class tst_QGeoTiledMapScene : public QObject
mapGeometry.setCameraData(camera);
mapGeometry.setVisibleTiles(ct.createTiles());
+ QGeoProjectionWebMercator projection;
+ projection.setViewportSize(QSize(screenWidth,screenHeight));
+ projection.setCameraData(camera);
+
QDoubleVector2D mercatorPos(mercatorX, mercatorY);
- QPointF point = mapGeometry.mercatorToItemPosition(mercatorPos).toPointF();
+ QPointF point = projection.wrappedMapProjectionToItemPosition(projection.wrapMapProjection(mercatorPos)).toPointF();
QVERIFY2((point.x() == screenX) || (point.x() == screenX2),
qPrintable(QString("Accepted: { %1 , %2 } Actual: %3")