summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnder Conselvan de Oliveira <ander.deoliveira@mapbox.com>2019-03-07 15:43:06 +0200
committerAnder Conselvan de Oliveira <ander.deoliveira@mapbox.com>2019-03-14 18:33:11 +0200
commita73cc9d8e363b0b3f4fa66c5d9c34625dffbb7e5 (patch)
treead0b4cd4349a17a8f4c3bc6ec9f5bbbf0c25f1dd
parentdba40c64ea8175b5dbf1cd043b3bc40730e13956 (diff)
downloadqtlocation-mapboxgl-a73cc9d8e363b0b3f4fa66c5d9c34625dffbb7e5.tar.gz
[core] Remove support for setting minimum and maximum pitch
Support for limiting pitch was introduced in commit c4fc89977bcb ([core] Added {set,get}{Min,Max}Pitch) in 2017 but was never exposed by the platform SDKs. Simplify the Map interface by removing this unused feature. v2: Add util::PITCH_MIN
-rw-r--r--include/mbgl/map/map.hpp4
-rw-r--r--include/mbgl/util/constants.hpp1
-rw-r--r--src/mbgl/map/map.cpp22
-rw-r--r--src/mbgl/map/transform.cpp14
-rw-r--r--src/mbgl/map/transform.hpp2
-rw-r--r--src/mbgl/map/transform_state.cpp20
-rw-r--r--src/mbgl/map/transform_state.hpp6
-rw-r--r--test/map/transform.test.cpp19
8 files changed, 3 insertions, 85 deletions
diff --git a/include/mbgl/map/map.hpp b/include/mbgl/map/map.hpp
index 548a9f6257..0c979f3e19 100644
--- a/include/mbgl/map/map.hpp
+++ b/include/mbgl/map/map.hpp
@@ -83,10 +83,6 @@ public:
double getMinZoom() const;
void setMaxZoom(double);
double getMaxZoom() const;
- void setMinPitch(double);
- double getMinPitch() const;
- void setMaxPitch(double);
- double getMaxPitch() const;
// North Orientation
void setNorthOrientation(NorthOrientation);
diff --git a/include/mbgl/util/constants.hpp b/include/mbgl/util/constants.hpp
index 7110d9e26b..b39b3a83e9 100644
--- a/include/mbgl/util/constants.hpp
+++ b/include/mbgl/util/constants.hpp
@@ -33,6 +33,7 @@ constexpr double EARTH_RADIUS_M = 6378137;
constexpr double LATITUDE_MAX = 85.051128779806604;
constexpr double LONGITUDE_MAX = 180;
constexpr double DEGREES_MAX = 360;
+constexpr double PITCH_MIN = 0.0;
constexpr double PITCH_MAX = M_PI / 3;
constexpr double MIN_ZOOM = 0.0;
constexpr double MAX_ZOOM = 25.5;
diff --git a/src/mbgl/map/map.cpp b/src/mbgl/map/map.cpp
index 556038d2d8..0d2aa421f6 100644
--- a/src/mbgl/map/map.cpp
+++ b/src/mbgl/map/map.cpp
@@ -307,28 +307,6 @@ double Map::getMaxZoom() const {
return impl->transform.getState().getMaxZoom();
}
-void Map::setMinPitch(double minPitch) {
- impl->transform.setMinPitch(minPitch * util::DEG2RAD);
- if (impl->transform.getPitch() < minPitch) {
- jumpTo(CameraOptions().withPitch(minPitch));
- }
-}
-
-double Map::getMinPitch() const {
- return impl->transform.getState().getMinPitch() * util::RAD2DEG;
-}
-
-void Map::setMaxPitch(double maxPitch) {
- impl->transform.setMaxPitch(maxPitch * util::DEG2RAD);
- if (impl->transform.getPitch() > maxPitch) {
- jumpTo(CameraOptions().withPitch(maxPitch));
- }
-}
-
-double Map::getMaxPitch() const {
- return impl->transform.getState().getMaxPitch() * util::RAD2DEG;
-}
-
#pragma mark - Size
void Map::setSize(const Size size) {
diff --git a/src/mbgl/map/transform.cpp b/src/mbgl/map/transform.cpp
index e60ce7a1bd..a90bf9871f 100644
--- a/src/mbgl/map/transform.cpp
+++ b/src/mbgl/map/transform.cpp
@@ -116,7 +116,7 @@ void Transform::easeTo(const CameraOptions& camera, const AnimationOptions& anim
// Constrain camera options.
zoom = util::clamp(zoom, state.getMinZoom(), state.getMaxZoom());
const double scale = state.zoomScale(zoom);
- pitch = util::clamp(pitch, state.min_pitch, state.max_pitch);
+ pitch = util::clamp(pitch, util::PITCH_MIN, util::PITCH_MAX);
// Minimize rotation by taking the shorter path around the circle.
bearing = _normalizeAngle(bearing, state.bearing);
@@ -181,7 +181,7 @@ void Transform::flyTo(const CameraOptions &camera, const AnimationOptions &anima
// Constrain camera options.
zoom = util::clamp(zoom, state.getMinZoom(), state.getMaxZoom());
- pitch = util::clamp(pitch, state.min_pitch, state.max_pitch);
+ pitch = util::clamp(pitch, util::PITCH_MIN, util::PITCH_MAX);
// Minimize rotation by taking the shorter path around the circle.
bearing = _normalizeAngle(bearing, state.bearing);
@@ -361,16 +361,6 @@ void Transform::setMaxZoom(const double maxZoom) {
state.setMaxZoom(maxZoom);
}
-void Transform::setMinPitch(double minPitch) {
- if (std::isnan(minPitch)) return;
- state.setMinPitch(minPitch);
-}
-
-void Transform::setMaxPitch(double maxPitch) {
- if (std::isnan(maxPitch)) return;
- state.setMaxPitch(maxPitch);
-}
-
#pragma mark - Bearing
void Transform::rotateBy(const ScreenCoordinate& first, const ScreenCoordinate& second, const AnimationOptions& animation) {
diff --git a/src/mbgl/map/transform.hpp b/src/mbgl/map/transform.hpp
index c4e10ec797..13750c2ec0 100644
--- a/src/mbgl/map/transform.hpp
+++ b/src/mbgl/map/transform.hpp
@@ -55,8 +55,6 @@ public:
void setLatLngBounds(optional<LatLngBounds>);
void setMinZoom(double);
void setMaxZoom(double);
- void setMinPitch(double);
- void setMaxPitch(double);
// Zoom
diff --git a/src/mbgl/map/transform_state.cpp b/src/mbgl/map/transform_state.cpp
index e911067c5b..73c61fdf0f 100644
--- a/src/mbgl/map/transform_state.cpp
+++ b/src/mbgl/map/transform_state.cpp
@@ -221,26 +221,6 @@ double TransformState::getMaxZoom() const {
return scaleZoom(max_scale);
}
-void TransformState::setMinPitch(double minPitch) {
- if (minPitch <= getMaxPitch()) {
- min_pitch = minPitch;
- }
-}
-
-double TransformState::getMinPitch() const {
- return min_pitch;
-}
-
-void TransformState::setMaxPitch(double maxPitch) {
- if (maxPitch >= getMinPitch()) {
- max_pitch = maxPitch;
- }
-}
-
-double TransformState::getMaxPitch() const {
- return max_pitch;
-}
-
#pragma mark - Rotation
float TransformState::getBearing() const {
diff --git a/src/mbgl/map/transform_state.hpp b/src/mbgl/map/transform_state.hpp
index be7c300803..44eb1a8a3e 100644
--- a/src/mbgl/map/transform_state.hpp
+++ b/src/mbgl/map/transform_state.hpp
@@ -61,10 +61,6 @@ public:
double getMinZoom() const;
void setMaxZoom(double);
double getMaxZoom() const;
- void setMinPitch(double);
- double getMinPitch() const;
- void setMaxPitch(double);
- double getMaxPitch() const;
// Rotation
float getBearing() const;
@@ -102,8 +98,6 @@ private:
// Limit the amount of zooming possible on the map.
double min_scale = std::pow(2, 0);
double max_scale = std::pow(2, util::DEFAULT_MAX_ZOOM);
- double min_pitch = 0.0;
- double max_pitch = util::PITCH_MAX;
NorthOrientation orientation = NorthOrientation::Upwards;
diff --git a/test/map/transform.test.cpp b/test/map/transform.test.cpp
index 04b9c1a931..441794886d 100644
--- a/test/map/transform.test.cpp
+++ b/test/map/transform.test.cpp
@@ -761,22 +761,3 @@ TEST(Transform, LatLngBounds) {
transform.moveBy(ScreenCoordinate { 500, 0 });
ASSERT_DOUBLE_EQ(transform.getLatLng().longitude(), 120.0);
}
-
-TEST(Transform, PitchBounds) {
- Transform transform;
- transform.resize({ 1000, 1000 });
-
- transform.jumpTo(CameraOptions().withCenter(LatLng()).withZoom(transform.getState().getMaxZoom()));
-
- ASSERT_DOUBLE_EQ(transform.getState().getPitch() * util::RAD2DEG, 0.0);
- ASSERT_DOUBLE_EQ(transform.getState().getMinPitch() * util::RAD2DEG, 0.0);
- ASSERT_DOUBLE_EQ(transform.getState().getMaxPitch() * util::RAD2DEG, 60.0);
-
- transform.setMinPitch(45.0 * util::DEG2RAD);
- transform.jumpTo(CameraOptions().withPitch(0));
- ASSERT_NEAR(transform.getState().getPitch() * util::RAD2DEG, 45.0, 1e-5);
-
- transform.setMaxPitch(55.0 * util::DEG2RAD);
- transform.jumpTo(CameraOptions().withPitch(60.0));
- ASSERT_NEAR(transform.getState().getPitch() * util::RAD2DEG, 55.0, 1e-5);
-}