diff options
author | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2018-10-16 15:53:27 +0200 |
---|---|---|
committer | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2018-10-19 12:05:16 +0200 |
commit | 98c36fc06edb99b2db20d474c4c3ec6bf51e219d (patch) | |
tree | 81512310f121366eb84c00e39e9faba9fea72181 /src | |
parent | 0c6b1629efb85386c0197868b2764c14f3fba940 (diff) | |
download | qtlocation-mapboxgl-98c36fc06edb99b2db20d474c4c3ec6bf51e219d.tar.gz |
[core] CameraOptions receives and outputs angle and pitch as degrees, not radians
Diffstat (limited to 'src')
-rw-r--r-- | src/mbgl/map/map.cpp | 4 | ||||
-rw-r--r-- | src/mbgl/map/transform.cpp | 14 |
2 files changed, 9 insertions, 9 deletions
diff --git a/src/mbgl/map/map.cpp b/src/mbgl/map/map.cpp index 9d886cb74c..1f64cf3acc 100644 --- a/src/mbgl/map/map.cpp +++ b/src/mbgl/map/map.cpp @@ -450,8 +450,8 @@ CameraOptions Map::cameraForLatLngs(const std::vector<LatLng>& latLngs, const Ed } CameraOptions options = mbgl::cameraForLatLngs(latLngs, transform, padding); - options.angle = transform.getAngle(); - options.pitch = transform.getPitch(); + options.angle = -transform.getAngle() * util::RAD2DEG; + options.pitch = transform.getPitch() * util::RAD2DEG; return options; } diff --git a/src/mbgl/map/transform.cpp b/src/mbgl/map/transform.cpp index da8e243d91..21f1b70c42 100644 --- a/src/mbgl/map/transform.cpp +++ b/src/mbgl/map/transform.cpp @@ -91,8 +91,8 @@ void Transform::easeTo(const CameraOptions& camera, const AnimationOptions& anim const LatLng unwrappedLatLng = camera.center.value_or(getLatLng()); const LatLng latLng = unwrappedLatLng.wrapped(); double zoom = camera.zoom.value_or(getZoom()); - double angle = camera.angle.value_or(getAngle()); - double pitch = camera.pitch.value_or(getPitch()); + double angle = camera.angle ? -*camera.angle * util::DEG2RAD : getAngle(); + double pitch = camera.pitch ? *camera.pitch * util::DEG2RAD : getPitch(); if (std::isnan(zoom)) { return; @@ -164,8 +164,8 @@ void Transform::easeTo(const CameraOptions& camera, const AnimationOptions& anim void Transform::flyTo(const CameraOptions &camera, const AnimationOptions &animation) { const LatLng latLng = camera.center.value_or(getLatLng()).wrapped(); double zoom = camera.zoom.value_or(getZoom()); - double angle = camera.angle.value_or(getAngle()); - double pitch = camera.pitch.value_or(getPitch()); + double angle = camera.angle ? -*camera.angle * util::DEG2RAD : getAngle(); + double pitch = camera.pitch ? *camera.pitch * util::DEG2RAD : getPitch(); if (std::isnan(zoom) || state.size.isEmpty()) { return; @@ -451,7 +451,7 @@ void Transform::rotateBy(const ScreenCoordinate& first, const ScreenCoordinate& } CameraOptions camera; - camera.angle = state.angle + util::angle_between(first - center, second - center); + camera.angle = -(state.angle + util::angle_between(first - center, second - center)) * util::RAD2DEG; easeTo(camera, animation); } @@ -462,7 +462,7 @@ void Transform::setAngle(double angle, const AnimationOptions& animation) { void Transform::setAngle(double angle, optional<ScreenCoordinate> anchor, const AnimationOptions& animation) { if (std::isnan(angle)) return; CameraOptions camera; - camera.angle = angle; + camera.angle = -angle * util::RAD2DEG; camera.anchor = anchor; easeTo(camera, animation); } @@ -486,7 +486,7 @@ void Transform::setPitch(double pitch, const AnimationOptions& animation) { void Transform::setPitch(double pitch, optional<ScreenCoordinate> anchor, const AnimationOptions& animation) { if (std::isnan(pitch)) return; CameraOptions camera; - camera.pitch = pitch; + camera.pitch = pitch * util::RAD2DEG; camera.anchor = anchor; easeTo(camera, animation); } |