summaryrefslogtreecommitdiff
path: root/src/mbgl/map/transform.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mbgl/map/transform.cpp')
-rw-r--r--src/mbgl/map/transform.cpp24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/mbgl/map/transform.cpp b/src/mbgl/map/transform.cpp
index 9245d7c5bc..b40456ebdc 100644
--- a/src/mbgl/map/transform.cpp
+++ b/src/mbgl/map/transform.cpp
@@ -123,7 +123,7 @@ void Transform::easeTo(const CameraOptions& camera, const AnimationOptions& anim
// Constrain camera options.
zoom = util::clamp(zoom, state.getMinZoom(), state.getMaxZoom());
- pitch = util::clamp(pitch, util::PITCH_MIN, util::PITCH_MAX);
+ pitch = util::clamp(pitch, state.getMinPitch(), state.getMaxPitch());
// Minimize rotation by taking the shorter path around the circle.
bearing = _normalizeAngle(bearing, state.getBearing());
@@ -196,7 +196,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, util::PITCH_MIN, util::PITCH_MAX);
+ pitch = util::clamp(pitch, state.getMinPitch(), state.getMaxPitch());
// Minimize rotation by taking the shorter path around the circle.
bearing = _normalizeAngle(bearing, state.getBearing());
@@ -379,6 +379,26 @@ void Transform::setMaxZoom(const double maxZoom) {
state.setMaxZoom(maxZoom);
}
+void Transform::setMinPitch(const double minPitch) {
+ if (std::isnan(minPitch)) return;
+ if (minPitch * util::DEG2RAD < util::PITCH_MIN) {
+ Log::Warning(Event::General,
+ "Trying to set minimum pitch below the limit (%.0f degrees), the value will be clamped.",
+ util::PITCH_MIN * util::RAD2DEG);
+ }
+ state.setMinPitch(minPitch * util::DEG2RAD);
+}
+
+void Transform::setMaxPitch(const double maxPitch) {
+ if (std::isnan(maxPitch)) return;
+ if (maxPitch * util::DEG2RAD > util::PITCH_MAX) {
+ Log::Warning(Event::General,
+ "Trying to set maximum pitch above the limit (%.0f degrees), the value will be clamped.",
+ util::PITCH_MAX * util::RAD2DEG);
+ }
+ state.setMaxPitch(maxPitch * util::DEG2RAD);
+}
+
#pragma mark - Bearing
void Transform::rotateBy(const ScreenCoordinate& first,