summaryrefslogtreecommitdiff
path: root/src/mbgl/map
diff options
context:
space:
mode:
Diffstat (limited to 'src/mbgl/map')
-rw-r--r--src/mbgl/map/map.cpp6
-rw-r--r--src/mbgl/map/transform.cpp48
-rw-r--r--src/mbgl/map/transform.hpp7
-rw-r--r--src/mbgl/map/transform_state.cpp14
-rw-r--r--src/mbgl/map/transform_state.hpp4
5 files changed, 38 insertions, 41 deletions
diff --git a/src/mbgl/map/map.cpp b/src/mbgl/map/map.cpp
index d7a1020262..3bc4c9f8d9 100644
--- a/src/mbgl/map/map.cpp
+++ b/src/mbgl/map/map.cpp
@@ -181,7 +181,7 @@ LatLng Map::getLatLng(const EdgeInsets& padding) const {
void Map::resetPosition(const EdgeInsets& padding) {
impl->cameraMutated = true;
- impl->transform.jumpTo(CameraOptions().withCenter(LatLng()).withPadding(padding).withZoom(0.0).withAngle(0.0).withPitch(0.0));
+ impl->transform.jumpTo(CameraOptions().withCenter(LatLng()).withPadding(padding).withZoom(0.0).withBearing(0.0).withPitch(0.0));
impl->onUpdate();
}
@@ -260,11 +260,11 @@ CameraOptions Map::cameraForLatLngs(const std::vector<LatLng>& latLngs, const Ed
Transform transform(impl->transform.getState());
if (bearing || pitch) {
- transform.jumpTo(CameraOptions().withAngle(bearing).withPitch(pitch));
+ transform.jumpTo(CameraOptions().withBearing(bearing).withPitch(pitch));
}
return mbgl::cameraForLatLngs(latLngs, transform, padding)
- .withAngle(-transform.getAngle() * util::RAD2DEG)
+ .withBearing(-transform.getBearing() * util::RAD2DEG)
.withPitch(transform.getPitch() * util::RAD2DEG);
}
diff --git a/src/mbgl/map/transform.cpp b/src/mbgl/map/transform.cpp
index 8065bc17ce..96aa5d2f4a 100644
--- a/src/mbgl/map/transform.cpp
+++ b/src/mbgl/map/transform.cpp
@@ -87,10 +87,10 @@ void Transform::easeTo(const CameraOptions& camera, const AnimationOptions& anim
const LatLng& unwrappedLatLng = camera.center.value_or(startLatLng);
const LatLng& latLng = state.bounds ? unwrappedLatLng : unwrappedLatLng.wrapped();
double zoom = camera.zoom.value_or(getZoom());
- double angle = camera.angle ? -*camera.angle * util::DEG2RAD : getAngle();
+ double bearing = camera.bearing ? -*camera.bearing * util::DEG2RAD : getBearing();
double pitch = camera.pitch ? *camera.pitch * util::DEG2RAD : getPitch();
- if (std::isnan(zoom) || std::isnan(angle) || std::isnan(pitch)) {
+ if (std::isnan(zoom) || std::isnan(bearing) || std::isnan(pitch)) {
return;
}
@@ -119,17 +119,17 @@ void Transform::easeTo(const CameraOptions& camera, const AnimationOptions& anim
pitch = util::clamp(pitch, state.min_pitch, state.max_pitch);
// Minimize rotation by taking the shorter path around the circle.
- angle = _normalizeAngle(angle, state.angle);
- state.angle = _normalizeAngle(state.angle, angle);
+ bearing = _normalizeAngle(bearing, state.bearing);
+ state.bearing = _normalizeAngle(state.bearing, bearing);
Duration duration = animation.duration ? *animation.duration : Duration::zero();
const double startScale = state.scale;
- const double startAngle = state.angle;
+ const double startBearing = state.bearing;
const double startPitch = state.pitch;
state.panning = unwrappedLatLng != startLatLng;
state.scaling = scale != startScale;
- state.rotating = angle != startAngle;
+ state.rotating = bearing != startBearing;
startTransition(camera, animation, [=](double t) {
Point<double> framePoint = util::interpolate(startPoint, endPoint, t);
@@ -137,8 +137,8 @@ void Transform::easeTo(const CameraOptions& camera, const AnimationOptions& anim
double frameScale = util::interpolate(startScale, scale, t);
state.setLatLngZoom(frameLatLng, state.scaleZoom(frameScale));
- if (angle != startAngle) {
- state.angle = util::wrap(util::interpolate(startAngle, angle, t), -M_PI, M_PI);
+ if (bearing != startBearing) {
+ state.bearing = util::wrap(util::interpolate(startBearing, bearing, t), -M_PI, M_PI);
}
if (pitch != startPitch) {
state.pitch = util::interpolate(startPitch, pitch, t);
@@ -162,10 +162,10 @@ void Transform::flyTo(const CameraOptions &camera, const AnimationOptions &anima
const EdgeInsets& padding = camera.padding;
const LatLng& latLng = camera.center.value_or(getLatLng(padding, LatLng::Unwrapped)).wrapped();
double zoom = camera.zoom.value_or(getZoom());
- double angle = camera.angle ? -*camera.angle * util::DEG2RAD : getAngle();
+ double bearing = camera.bearing ? -*camera.bearing * util::DEG2RAD : getBearing();
double pitch = camera.pitch ? *camera.pitch * util::DEG2RAD : getPitch();
- if (std::isnan(zoom) || std::isnan(angle) || std::isnan(pitch) || state.size.isEmpty()) {
+ if (std::isnan(zoom) || std::isnan(bearing) || std::isnan(pitch) || state.size.isEmpty()) {
return;
}
@@ -184,11 +184,11 @@ void Transform::flyTo(const CameraOptions &camera, const AnimationOptions &anima
pitch = util::clamp(pitch, state.min_pitch, state.max_pitch);
// Minimize rotation by taking the shorter path around the circle.
- angle = _normalizeAngle(angle, state.angle);
- state.angle = _normalizeAngle(state.angle, angle);
+ bearing = _normalizeAngle(bearing, state.bearing);
+ state.bearing = _normalizeAngle(state.bearing, bearing);
const double startZoom = state.scaleZoom(state.scale);
- const double startAngle = state.angle;
+ const double startBearing = state.bearing;
const double startPitch = state.pitch;
/// w₀: Initial visible span, measured in pixels at the initial scale.
@@ -277,7 +277,7 @@ void Transform::flyTo(const CameraOptions &camera, const AnimationOptions &anima
const double startScale = state.scale;
state.panning = true;
state.scaling = true;
- state.rotating = angle != startAngle;
+ state.rotating = bearing != startBearing;
startTransition(camera, animation, [=](double k) {
/// s: The distance traveled along the flight path, measured in
@@ -298,8 +298,8 @@ void Transform::flyTo(const CameraOptions &camera, const AnimationOptions &anima
LatLng frameLatLng = Projection::unproject(framePoint, startScale);
state.setLatLngZoom(frameLatLng, frameZoom);
- if (angle != startAngle) {
- state.angle = util::wrap(util::interpolate(startAngle, angle, k), -M_PI, M_PI);
+ if (bearing != startBearing) {
+ state.bearing = util::wrap(util::interpolate(startBearing, bearing, k), -M_PI, M_PI);
}
if (pitch != startPitch) {
state.pitch = util::interpolate(startPitch, pitch, k);
@@ -371,7 +371,7 @@ void Transform::setMaxPitch(double maxPitch) {
state.setMaxPitch(maxPitch);
}
-#pragma mark - Angle
+#pragma mark - Bearing
void Transform::rotateBy(const ScreenCoordinate& first, const ScreenCoordinate& second, const AnimationOptions& animation) {
ScreenCoordinate center = getScreenCoordinate();
@@ -382,17 +382,17 @@ void Transform::rotateBy(const ScreenCoordinate& first, const ScreenCoordinate&
// in the direction of the click.
if (distance < 200) {
const double heightOffset = -200;
- const double rotateAngle = std::atan2(offset.y, offset.x);
- center.x = first.x + std::cos(rotateAngle) * heightOffset;
- center.y = first.y + std::sin(rotateAngle) * heightOffset;
+ const double rotateBearing = std::atan2(offset.y, offset.x);
+ center.x = first.x + std::cos(rotateBearing) * heightOffset;
+ center.y = first.y + std::sin(rotateBearing) * heightOffset;
}
- const double angle = -(state.angle + util::angle_between(first - center, second - center)) * util::RAD2DEG;
- easeTo(CameraOptions().withAngle(angle), animation);
+ const double bearing = -(state.bearing + util::angle_between(first - center, second - center)) * util::RAD2DEG;
+ easeTo(CameraOptions().withBearing(bearing), animation);
}
-double Transform::getAngle() const {
- return state.angle;
+double Transform::getBearing() const {
+ return state.bearing;
}
#pragma mark - Pitch
diff --git a/src/mbgl/map/transform.hpp b/src/mbgl/map/transform.hpp
index da62a3f04e..cf342181b1 100644
--- a/src/mbgl/map/transform.hpp
+++ b/src/mbgl/map/transform.hpp
@@ -62,13 +62,10 @@ public:
/** Returns the zoom level. */
double getZoom() const;
- // Angle
+ // Bearing
void rotateBy(const ScreenCoordinate& first, const ScreenCoordinate& second, const AnimationOptions& = {});
- /** Returns the angle of rotation.
- @return The angle of rotation, measured in radians counterclockwise from
- true north. */
- double getAngle() const;
+ double getBearing() const;
// Pitch
diff --git a/src/mbgl/map/transform_state.cpp b/src/mbgl/map/transform_state.cpp
index 778d4bd7e7..e911067c5b 100644
--- a/src/mbgl/map/transform_state.cpp
+++ b/src/mbgl/map/transform_state.cpp
@@ -61,7 +61,7 @@ void TransformState::getProjMatrix(mat4& projMatrix, uint16_t nearZ, bool aligne
default: matrix::rotate_x(projMatrix, projMatrix, getPitch()); break;
}
- matrix::rotate_z(projMatrix, projMatrix, getAngle() + getNorthOrientationAngle());
+ matrix::rotate_z(projMatrix, projMatrix, getBearing() + getNorthOrientationAngle());
const double dx = pixel_x() - size.width / 2.0f, dy = pixel_y() - size.height / 2.0f;
matrix::translate(projMatrix, projMatrix, dx, dy, 0);
@@ -86,10 +86,10 @@ void TransformState::getProjMatrix(mat4& projMatrix, uint16_t nearZ, bool aligne
// it is always <= 0.5 pixels.
if (aligned) {
const float xShift = float(size.width % 2) / 2, yShift = float(size.height % 2) / 2;
- const double angleCos = std::cos(angle), angleSin = std::sin(angle);
+ const double bearingCos = std::cos(bearing), bearingSin = std::sin(bearing);
double devNull;
- const float dxa = -std::modf(dx, &devNull) + angleCos * xShift + angleSin * yShift;
- const float dya = -std::modf(dy, &devNull) + angleCos * yShift + angleSin * xShift;
+ const float dxa = -std::modf(dx, &devNull) + bearingCos * xShift + bearingSin * yShift;
+ const float dya = -std::modf(dy, &devNull) + bearingCos * yShift + bearingSin * xShift;
matrix::translate(projMatrix, projMatrix, dxa > 0.5 ? dxa - 1 : dxa, dya > 0.5 ? dya - 1 : dya, 0);
}
}
@@ -145,7 +145,7 @@ CameraOptions TransformState::getCameraOptions(const EdgeInsets& padding) const
.withCenter(center)
.withPadding(padding)
.withZoom(getZoom())
- .withAngle(-angle * util::RAD2DEG)
+ .withBearing(-bearing * util::RAD2DEG)
.withPitch(pitch * util::RAD2DEG);
}
@@ -243,8 +243,8 @@ double TransformState::getMaxPitch() const {
#pragma mark - Rotation
-float TransformState::getAngle() const {
- return angle;
+float TransformState::getBearing() const {
+ return bearing;
}
float TransformState::getFieldOfView() const {
diff --git a/src/mbgl/map/transform_state.hpp b/src/mbgl/map/transform_state.hpp
index fe716d8ea8..be7c300803 100644
--- a/src/mbgl/map/transform_state.hpp
+++ b/src/mbgl/map/transform_state.hpp
@@ -67,7 +67,7 @@ public:
double getMaxPitch() const;
// Rotation
- float getAngle() const;
+ float getBearing() const;
float getFieldOfView() const;
float getCameraToCenterDistance() const;
float getPitch() const;
@@ -131,7 +131,7 @@ private:
// map position
double x = 0, y = 0;
- double angle = 0;
+ double bearing = 0;
double scale = 1;
// This fov value is somewhat arbitrary. The altitude of the camera used
// to be defined as 1.5 screen heights above the ground, which was an