summaryrefslogtreecommitdiff
path: root/test/map
diff options
context:
space:
mode:
authorAsheem Mamoowala <asheem.mamoowala@mapbox.com>2017-10-02 13:42:26 -0700
committerAsheem Mamoowala <asheem.mamoowala@mapbox.com>2017-10-09 11:42:37 -0700
commit2366487275ce90022bac67d51205e3011bca6f0a (patch)
tree9423626f1f20864805f7fc142e501e0ad0b5a32a /test/map
parent6cf153a6de2a32f29d3de5fff2fed435990a875c (diff)
downloadqtlocation-mapboxgl-2366487275ce90022bac67d51205e3011bca6f0a.tar.gz
[core] Add `cameraForLatLngs()` method with modified bearing
Diffstat (limited to 'test/map')
-rw-r--r--test/map/map.test.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/map/map.test.cpp b/test/map/map.test.cpp
index 50d5e50abb..9358175297 100644
--- a/test/map/map.test.cpp
+++ b/test/map/map.test.cpp
@@ -109,6 +109,32 @@ TEST(Map, LatLngBoundsToCamera) {
CameraOptions virtualCamera = test.map.cameraForLatLngBounds(bounds, {});
ASSERT_TRUE(bounds.contains(*virtualCamera.center));
+ EXPECT_NEAR(*virtualCamera.zoom, 1.55467, 1e-5);
+}
+
+TEST(Map, LatLngBoundsToCameraWithAngle) {
+ MapTest<> test;
+
+ test.map.setLatLngZoom({ 40.712730, -74.005953 }, 16.0);
+
+ LatLngBounds bounds = LatLngBounds::hull({15.68169,73.499857}, {53.560711, 134.77281});
+
+ CameraOptions virtualCamera = test.map.cameraForLatLngBounds(bounds, {}, 35);
+ ASSERT_TRUE(bounds.contains(*virtualCamera.center));
+ EXPECT_NEAR(*virtualCamera.zoom, 1.21385, 1e-5);
+ EXPECT_DOUBLE_EQ(virtualCamera.angle.value_or(0), -35 * util::DEG2RAD);
+}
+
+TEST(Map, LatLngsToCamera) {
+ MapTest<> test;
+
+ std::vector<LatLng> latLngs{{ 40.712730, 74.005953 }, {15.68169,73.499857}, {30.82678, 83.4082}};
+
+ CameraOptions virtualCamera = test.map.cameraForLatLngs(latLngs, {}, 23);
+ EXPECT_DOUBLE_EQ(virtualCamera.angle.value_or(0), -23 * util::DEG2RAD);
+ EXPECT_NEAR(virtualCamera.zoom.value_or(0), 2.75434, 1e-5);
+ EXPECT_NEAR(virtualCamera.center->latitude(), 28.49288, 1e-5);
+ EXPECT_NEAR(virtualCamera.center->longitude(), 74.97437, 1e-5);
}
TEST(Map, CameraToLatLngBounds) {