diff options
author | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2017-03-23 18:10:16 +0200 |
---|---|---|
committer | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2017-03-24 13:51:35 +0200 |
commit | 80915992ab4e970ca005009ca1175bae24cb448b (patch) | |
tree | 75cfac7d0933b77ad5e93e95471cc0b96e85ba88 /test/map | |
parent | e67abfbe67d7c08e90fdbd8727c4e9ed17dfa1ed (diff) | |
download | qtlocation-mapboxgl-80915992ab4e970ca005009ca1175bae24cb448b.tar.gz |
[core] Added Map::latLngBoundsForCamera
Diffstat (limited to 'test/map')
-rw-r--r-- | test/map/map.test.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/test/map/map.test.cpp b/test/map/map.test.cpp index c5017aeb04..8f81a5d8c5 100644 --- a/test/map/map.test.cpp +++ b/test/map/map.test.cpp @@ -69,6 +69,28 @@ TEST(Map, LatLngBehavior) { ASSERT_DOUBLE_EQ(latLng1.longitude, latLng2.longitude); } +TEST(Map, CameraToLatLngBounds) { + MapTest test; + Map map(test.backend, test.view.getSize(), 1, test.fileSource, test.threadPool, MapMode::Still); + + map.setLatLngZoom({ 45, 90 }, 16); + + LatLngBounds bounds = LatLngBounds::hull( + map.latLngForPixel({}), + map.latLngForPixel({ double(map.getSize().width), double(map.getSize().height) })); + + CameraOptions camera = map.getCameraOptions({}); + + ASSERT_EQ(bounds, map.latLngBoundsForCamera(camera)); + + CameraOptions virtualCamera = map.cameraForLatLngBounds(bounds, {}); + ASSERT_NEAR(*camera.zoom, *virtualCamera.zoom, 1e-7); + ASSERT_NEAR(*camera.angle, *virtualCamera.angle, 1e-10); + ASSERT_NEAR(*camera.pitch, *virtualCamera.pitch, 1e-10); + ASSERT_NEAR(camera.center->latitude, virtualCamera.center->latitude, 1e-10); + ASSERT_NEAR(camera.center->longitude, virtualCamera.center->longitude, 1e-10); +} + TEST(Map, Offline) { MapTest test; DefaultFileSource fileSource(":memory:", "."); |