summaryrefslogtreecommitdiff
path: root/test/map/map.test.cpp
diff options
context:
space:
mode:
authorBobby Sudekum <bobby@mapbox.com>2018-07-02 16:30:18 -0700
committerGitHub <noreply@github.com>2018-07-02 16:30:18 -0700
commit4286d5869c9af0513298b8b31d36744a3243bff4 (patch)
tree8db8172a0bc9320fb79d9060bddede7cca7ee1b3 /test/map/map.test.cpp
parent29e25356e355d466a60297117f3e7c010825a7ff (diff)
downloadqtlocation-mapboxgl-4286d5869c9af0513298b8b31d36744a3243bff4.tar.gz
Add pitch argument to cameraThatFits functions (#12213)
Diffstat (limited to 'test/map/map.test.cpp')
-rw-r--r--test/map/map.test.cpp32
1 files changed, 30 insertions, 2 deletions
diff --git a/test/map/map.test.cpp b/test/map/map.test.cpp
index f95e26fd82..4f7bd2df7b 100644
--- a/test/map/map.test.cpp
+++ b/test/map/map.test.cpp
@@ -84,7 +84,21 @@ TEST(Map, LatLngBoundsToCameraWithAngle) {
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);
+ EXPECT_NEAR(virtualCamera.angle.value_or(0), -35 * util::DEG2RAD, 1e-5);
+}
+
+TEST(Map, LatLngBoundsToCameraWithAngleAndPitch) {
+ 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, 20);
+ ASSERT_TRUE(bounds.contains(*virtualCamera.center));
+ EXPECT_NEAR(*virtualCamera.zoom, 13.66272, 1e-5);
+ ASSERT_DOUBLE_EQ(*virtualCamera.pitch, 20 * util::DEG2RAD);
+ EXPECT_NEAR(virtualCamera.angle.value_or(0), -35 * util::DEG2RAD, 1e-5);
}
TEST(Map, LatLngsToCamera) {
@@ -93,12 +107,26 @@ TEST(Map, LatLngsToCamera) {
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.angle.value_or(0), -23 * util::DEG2RAD, 1e-5);
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, LatLngsToCameraWithAngleAndPitch) {
+ 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, 20);
+ EXPECT_NEAR(virtualCamera.angle.value_or(0), -23 * util::DEG2RAD, 1e-5);
+ EXPECT_NEAR(virtualCamera.zoom.value_or(0), 3.04378, 1e-5);
+ EXPECT_NEAR(virtualCamera.center->latitude(), 28.53718, 1e-5);
+ EXPECT_NEAR(virtualCamera.center->longitude(), 74.31746, 1e-5);
+ ASSERT_DOUBLE_EQ(*virtualCamera.pitch, 20 * util::DEG2RAD);
+}
+
+
TEST(Map, CameraToLatLngBounds) {
MapTest<> test;