summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorPeng Liu <peng.liu@mapbox.com>2020-01-09 15:53:23 +0200
committerGitHub <noreply@github.com>2020-01-09 15:53:23 +0200
commit236afc03958cc729b3b8121a1c5a72660f0e9fa2 (patch)
treead7da4d786c7ef7ce0ee14ecacd303e5a3eb34f2 /test
parentd3a5ed968cc5288c171404d5c3f8d16a552ff28a (diff)
downloadqtlocation-mapboxgl-236afc03958cc729b3b8121a1c5a72660f0e9fa2.tar.gz
[android][core] Add `Map::latLngBoundsForCameraUnwrapped` and jni binding for `getVisibleCoordinateBounds`. (#16069)
* [android] Add getVisibleCoordinateBounds method. * Fix Map::latLngBoundsForCamera, add Android binding for getVisibleRegionBounds. * Add unit tests for CameraToLatLngBoundsWithRotation and CameraToLatLngBoundsCrossDateLine. * Move API breaking changes to a new method name latLngBoundsForCameraUnwrapped.
Diffstat (limited to 'test')
-rw-r--r--test/map/map.test.cpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/test/map/map.test.cpp b/test/map/map.test.cpp
index 31cc85619e..a0cd64bdd5 100644
--- a/test/map/map.test.cpp
+++ b/test/map/map.test.cpp
@@ -252,6 +252,48 @@ TEST(Map, CameraToLatLngBounds) {
ASSERT_NEAR(camera.center->longitude(), virtualCamera.center->longitude(), 1e-7);
}
+TEST(Map, CameraToLatLngBoundsUnwrappedWithRotation) {
+ MapTest<> test;
+
+ test.map.jumpTo(CameraOptions().withCenter(LatLng{45, 90}).withZoom(16.0).withBearing(45.0));
+
+ const Size size = test.map.getMapOptions().size();
+
+ CameraOptions camera = test.map.getCameraOptions();
+
+ ASSERT_TRUE(test.map.latLngBoundsForCameraUnwrapped(camera).contains(test.map.latLngForPixel({})));
+ ASSERT_TRUE(
+ test.map.latLngBoundsForCameraUnwrapped(camera).contains(test.map.latLngForPixel({0.0, double(size.height)})));
+ ASSERT_TRUE(
+ test.map.latLngBoundsForCameraUnwrapped(camera).contains(test.map.latLngForPixel({double(size.width), 0.0})));
+ ASSERT_TRUE(test.map.latLngBoundsForCameraUnwrapped(camera).contains(
+ test.map.latLngForPixel({double(size.width), double(size.height)})));
+ ASSERT_TRUE(test.map.latLngBoundsForCameraUnwrapped(camera).contains(
+ test.map.latLngForPixel({double(size.width) / 2, double(size.height) / 2})));
+}
+
+TEST(Map, CameraToLatLngBoundsUnwrappedCrossDateLine) {
+ MapTest<> test;
+
+ test.map.jumpTo(CameraOptions().withCenter(LatLng{0, 180}).withZoom(16.0));
+
+ const Size size = test.map.getMapOptions().size();
+
+ CameraOptions camera = test.map.getCameraOptions();
+
+ ASSERT_TRUE(test.map.latLngBoundsForCameraUnwrapped(camera).contains(test.map.latLngForPixel({}), LatLng::Wrapped));
+ ASSERT_TRUE(test.map.latLngBoundsForCameraUnwrapped(camera).contains(
+ test.map.latLngForPixel({0.0, double(size.height)}), LatLng::Wrapped));
+ ASSERT_TRUE(test.map.latLngBoundsForCameraUnwrapped(camera).contains(
+ test.map.latLngForPixel({double(size.width), 0.0}), LatLng::Wrapped));
+ ASSERT_TRUE(test.map.latLngBoundsForCameraUnwrapped(camera).contains(
+ test.map.latLngForPixel({double(size.width), double(size.height)}), LatLng::Wrapped));
+ ASSERT_TRUE(test.map.latLngBoundsForCameraUnwrapped(camera).contains(
+ test.map.latLngForPixel({double(size.width) / 2, double(size.height) / 2})));
+
+ ASSERT_TRUE(test.map.latLngBoundsForCameraUnwrapped(camera).crossesAntimeridian());
+}
+
TEST(Map, Offline) {
MapTest<DefaultFileSource> test {":memory:", "."};