summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPaolo Angelelli <paolo.angelelli@qt.io>2017-08-04 13:22:43 +0200
committerPaolo Angelelli <paolo.angelelli@qt.io>2017-08-09 14:16:46 +0000
commit602cd4845dff2bbe5a8118899f1dfbcca9d614f1 (patch)
treea2e6c52c7d3982d883e6643a798b4c483c30b3d3 /tests
parentb6294cfca675bd5aa9a34e15c93692a0f1b8fdb2 (diff)
downloadqtlocation-602cd4845dff2bbe5a8118899f1dfbcca9d614f1.tar.gz
Fix visible region computation in QGeoProjectionWebMercator
Currently the visible region is calculated as the intersection between the viewing frustum and the map plane clipped against the map extended rectangle in mercator space (from -1 to 2 in x coords, 0 to 1 in y coords). The result is correct in the extended mercator space. However, this may lead to overlapping coordinates when converted back to latitude and longitude. For this reason, this patch changes the clipping geometry to be the map un-extended rectangle centered around the current map center. The result is a geometry that never wraps around or overlaps, thus removing the need for handling separately the case when the map is fully visible when returning the visible region. Task-number: QTBUG-57690 Change-Id: I8396c40a123ce94bff4388dfefbd8a694657b8bd Reviewed-by: BogDan Vatra <bogdan@kdab.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/declarative_ui/tst_map.qml41
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/auto/declarative_ui/tst_map.qml b/tests/auto/declarative_ui/tst_map.qml
index 846a621f..408bf96e 100644
--- a/tests/auto/declarative_ui/tst_map.qml
+++ b/tests/auto/declarative_ui/tst_map.qml
@@ -30,6 +30,7 @@ import QtQuick 2.0
import QtTest 1.0
import QtPositioning 5.5
import QtLocation 5.9
+import QtLocation.Test 5.6
Item {
width:100
@@ -55,6 +56,10 @@ Item {
property variant coordinate3: QtPositioning.coordinate(50, 50, 0)
property variant coordinate4: QtPositioning.coordinate(80, 80, 0)
property variant coordinate5: QtPositioning.coordinate(20, 180)
+ property variant coordinateCenterVisibleRegion: QtPositioning.coordinate(27, 77)
+ property variant coordinateVisible1: QtPositioning.coordinate(28, 77)
+ property variant coordinateVisible2: QtPositioning.coordinate(33, 79.1)
+ property variant coordinateVisible3: QtPositioning.coordinate(27, 80.5)
property variant invalidCoordinate: QtPositioning.coordinate()
property variant altitudelessCoordinate: QtPositioning.coordinate(50, 50)
property bool allMapsReady: mapZoomOnCompleted.mapReady
@@ -84,6 +89,9 @@ Item {
}
}
+ Map { id: mapVisibleRegion; width: 800; height: 600;
+ center: coordinateCenterVisibleRegion; plugin: testPlugin; zoomLevel: 1.0 }
+
Map {id: map; plugin: testPlugin; center: coordinate1; width: 100; height: 100}
SignalSpy {id: mapCenterSpy; target: map; signalName: 'centerChanged'}
@@ -148,6 +156,39 @@ Item {
compare(map.center.latitude, 12)
}
+ function test_map_visible_region()
+ {
+ mapVisibleRegion.zoomLevel = 1.0
+ wait(50)
+ verify(mapVisibleRegion.visibleRegion.contains(coordinateVisible1))
+ verify(mapVisibleRegion.visibleRegion.contains(coordinateVisible2))
+ verify(mapVisibleRegion.visibleRegion.contains(coordinateVisible3))
+
+ mapVisibleRegion.zoomLevel = 1.88
+ verify(LocationTestHelper.waitForPolished(mapVisibleRegion))
+ verify(mapVisibleRegion.visibleRegion.contains(coordinateVisible1))
+ verify(mapVisibleRegion.visibleRegion.contains(coordinateVisible2))
+ verify(mapVisibleRegion.visibleRegion.contains(coordinateVisible3))
+
+ mapVisibleRegion.zoomLevel = 2.12
+ verify(LocationTestHelper.waitForPolished(mapVisibleRegion))
+ verify(mapVisibleRegion.visibleRegion.contains(coordinateVisible1))
+ verify(mapVisibleRegion.visibleRegion.contains(coordinateVisible2))
+ verify(mapVisibleRegion.visibleRegion.contains(coordinateVisible3))
+
+ mapVisibleRegion.zoomLevel = 2.5
+ verify(LocationTestHelper.waitForPolished(mapVisibleRegion))
+ verify(mapVisibleRegion.visibleRegion.contains(coordinateVisible1))
+ verify(mapVisibleRegion.visibleRegion.contains(coordinateVisible2))
+ verify(mapVisibleRegion.visibleRegion.contains(coordinateVisible3))
+
+ mapVisibleRegion.zoomLevel = 2.7
+ verify(LocationTestHelper.waitForPolished(mapVisibleRegion))
+ verify(mapVisibleRegion.visibleRegion.contains(coordinateVisible1))
+ verify(mapVisibleRegion.visibleRegion.contains(coordinateVisible2))
+ verify(mapVisibleRegion.visibleRegion.contains(coordinateVisible3))
+ }
+
function test_map_parameters()
{
// coordinate is set at map element declaration