summaryrefslogtreecommitdiff
path: root/src/mbgl
diff options
context:
space:
mode:
authorBruno de Oliveira Abinader <bruno@mapbox.com>2019-03-01 09:58:58 +0200
committerBruno de Oliveira Abinader <bruno@mapbox.com>2019-03-04 14:45:32 +0200
commitba7427b4acf116aca7451ad3a6067dc234d3fa70 (patch)
tree106462886345e60f47bdeeaaf46580c67987b064 /src/mbgl
parent73ac3c784fe755650dc631e2e722a47890981248 (diff)
downloadqtlocation-mapboxgl-ba7427b4acf116aca7451ad3a6067dc234d3fa70.tar.gz
[core] Transform{State}: s/angle/bearing/
Diffstat (limited to 'src/mbgl')
-rw-r--r--src/mbgl/layout/symbol_projection.cpp4
-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
-rw-r--r--src/mbgl/programs/fill_extrusion_program.cpp2
-rw-r--r--src/mbgl/renderer/layers/render_circle_layer.cpp2
-rw-r--r--src/mbgl/renderer/layers/render_custom_layer.cpp2
-rw-r--r--src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp2
-rw-r--r--src/mbgl/renderer/layers/render_fill_layer.cpp2
-rw-r--r--src/mbgl/renderer/layers/render_hillshade_layer.cpp2
-rw-r--r--src/mbgl/renderer/layers/render_line_layer.cpp2
-rw-r--r--src/mbgl/renderer/layers/render_symbol_layer.cpp4
-rw-r--r--src/mbgl/renderer/render_tile.cpp4
-rw-r--r--src/mbgl/style/style_impl.cpp2
-rw-r--r--src/mbgl/text/placement.cpp2
17 files changed, 53 insertions, 56 deletions
diff --git a/src/mbgl/layout/symbol_projection.cpp b/src/mbgl/layout/symbol_projection.cpp
index edf916484b..293cdc5427 100644
--- a/src/mbgl/layout/symbol_projection.cpp
+++ b/src/mbgl/layout/symbol_projection.cpp
@@ -62,7 +62,7 @@ namespace mbgl {
if (pitchWithMap) {
matrix::scale(m, m, 1 / pixelsToTileUnits, 1 / pixelsToTileUnits, 1);
if (!rotateWithMap) {
- matrix::rotate_z(m, m, state.getAngle());
+ matrix::rotate_z(m, m, state.getBearing());
}
} else {
matrix::scale(m, m, state.getSize().width / 2.0, -(state.getSize().height / 2.0), 1.0);
@@ -82,7 +82,7 @@ namespace mbgl {
matrix::multiply(m, m, posMatrix);
matrix::scale(m, m, pixelsToTileUnits, pixelsToTileUnits, 1);
if (!rotateWithMap) {
- matrix::rotate_z(m, m, -state.getAngle());
+ matrix::rotate_z(m, m, -state.getBearing());
}
} else {
matrix::scale(m, m, 1, -1, 1);
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
diff --git a/src/mbgl/programs/fill_extrusion_program.cpp b/src/mbgl/programs/fill_extrusion_program.cpp
index b262485b35..92916a61ab 100644
--- a/src/mbgl/programs/fill_extrusion_program.cpp
+++ b/src/mbgl/programs/fill_extrusion_program.cpp
@@ -21,7 +21,7 @@ std::array<float, 3> lightPosition(const EvaluatedLight& light, const TransformS
mat3 lightMat;
matrix::identity(lightMat);
if (light.get<LightAnchor>() == LightAnchorType::Viewport) {
- matrix::rotate(lightMat, lightMat, -state.getAngle());
+ matrix::rotate(lightMat, lightMat, -state.getBearing());
}
matrix::transformMat3f(lightPos, lightPos, lightMat);
return lightPos;
diff --git a/src/mbgl/renderer/layers/render_circle_layer.cpp b/src/mbgl/renderer/layers/render_circle_layer.cpp
index 10f38a3413..aec6813823 100644
--- a/src/mbgl/renderer/layers/render_circle_layer.cpp
+++ b/src/mbgl/renderer/layers/render_circle_layer.cpp
@@ -142,7 +142,7 @@ bool RenderCircleLayer::queryIntersectsFeature(
queryGeometry,
evaluated.get<style::CircleTranslate>(),
evaluated.get<style::CircleTranslateAnchor>(),
- transformState.getAngle(),
+ transformState.getBearing(),
pixelsToTileUnits).value_or(queryGeometry);
// Evaluate functions
diff --git a/src/mbgl/renderer/layers/render_custom_layer.cpp b/src/mbgl/renderer/layers/render_custom_layer.cpp
index 5eef5d2cb1..bcb0decb74 100644
--- a/src/mbgl/renderer/layers/render_custom_layer.cpp
+++ b/src/mbgl/renderer/layers/render_custom_layer.cpp
@@ -74,7 +74,7 @@ void RenderCustomLayer::render(PaintParameters& paintParameters, RenderSource*)
parameters.latitude = state.getLatLng().latitude();
parameters.longitude = state.getLatLng().longitude();
parameters.zoom = state.getZoom();
- parameters.bearing = -state.getAngle() * util::RAD2DEG;
+ parameters.bearing = -state.getBearing() * util::RAD2DEG;
parameters.pitch = state.getPitch();
parameters.fieldOfView = state.getFieldOfView();
mat4 projMatrix;
diff --git a/src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp b/src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp
index 2753fcd533..3224397fb7 100644
--- a/src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp
+++ b/src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp
@@ -218,7 +218,7 @@ bool RenderFillExtrusionLayer::queryIntersectsFeature(
queryGeometry,
evaluated.get<style::FillExtrusionTranslate>(),
evaluated.get<style::FillExtrusionTranslateAnchor>(),
- transformState.getAngle(),
+ transformState.getBearing(),
pixelsToTileUnits);
return util::polygonIntersectsMultiPolygon(translatedQueryGeometry.value_or(queryGeometry), feature.getGeometries());
diff --git a/src/mbgl/renderer/layers/render_fill_layer.cpp b/src/mbgl/renderer/layers/render_fill_layer.cpp
index 226c8a11b7..51019875e3 100644
--- a/src/mbgl/renderer/layers/render_fill_layer.cpp
+++ b/src/mbgl/renderer/layers/render_fill_layer.cpp
@@ -233,7 +233,7 @@ bool RenderFillLayer::queryIntersectsFeature(
queryGeometry,
evaluated.get<style::FillTranslate>(),
evaluated.get<style::FillTranslateAnchor>(),
- transformState.getAngle(),
+ transformState.getBearing(),
pixelsToTileUnits);
return util::polygonIntersectsMultiPolygon(translatedQueryGeometry.value_or(queryGeometry), feature.getGeometries());
diff --git a/src/mbgl/renderer/layers/render_hillshade_layer.cpp b/src/mbgl/renderer/layers/render_hillshade_layer.cpp
index c18e09512d..2ee824dcf3 100644
--- a/src/mbgl/renderer/layers/render_hillshade_layer.cpp
+++ b/src/mbgl/renderer/layers/render_hillshade_layer.cpp
@@ -32,7 +32,7 @@ const std::array<float, 2> RenderHillshadeLayer::getLatRange(const UnwrappedTile
const std::array<float, 2> RenderHillshadeLayer::getLight(const PaintParameters& parameters){
float azimuthal = evaluated.get<HillshadeIlluminationDirection>() * util::DEG2RAD;
- if (evaluated.get<HillshadeIlluminationAnchor>() == HillshadeIlluminationAnchorType::Viewport) azimuthal = azimuthal - parameters.state.getAngle();
+ if (evaluated.get<HillshadeIlluminationAnchor>() == HillshadeIlluminationAnchorType::Viewport) azimuthal = azimuthal - parameters.state.getBearing();
return {{evaluated.get<HillshadeExaggeration>(), azimuthal}};
}
diff --git a/src/mbgl/renderer/layers/render_line_layer.cpp b/src/mbgl/renderer/layers/render_line_layer.cpp
index 5b36cd4158..b0c441f5a1 100644
--- a/src/mbgl/renderer/layers/render_line_layer.cpp
+++ b/src/mbgl/renderer/layers/render_line_layer.cpp
@@ -207,7 +207,7 @@ bool RenderLineLayer::queryIntersectsFeature(
queryGeometry,
evaluated.get<style::LineTranslate>(),
evaluated.get<style::LineTranslateAnchor>(),
- transformState.getAngle(),
+ transformState.getBearing(),
pixelsToTileUnits);
// Evaluate function
diff --git a/src/mbgl/renderer/layers/render_symbol_layer.cpp b/src/mbgl/renderer/layers/render_symbol_layer.cpp
index 44d0c0001e..19edb6afbd 100644
--- a/src/mbgl/renderer/layers/render_symbol_layer.cpp
+++ b/src/mbgl/renderer/layers/render_symbol_layer.cpp
@@ -379,8 +379,8 @@ void RenderSymbolLayer::sortRenderTiles(const TransformState& state) {
Point<float> pa(a.get().id.canonical.x, a.get().id.canonical.y);
Point<float> pb(b.get().id.canonical.x, b.get().id.canonical.y);
- auto par = util::rotate(pa, state.getAngle());
- auto pbr = util::rotate(pb, state.getAngle());
+ auto par = util::rotate(pa, state.getBearing());
+ auto pbr = util::rotate(pb, state.getBearing());
return std::tie(b.get().id.canonical.z, par.y, par.x) < std::tie(a.get().id.canonical.z, pbr.y, pbr.x);
});
diff --git a/src/mbgl/renderer/render_tile.cpp b/src/mbgl/renderer/render_tile.cpp
index 1ea39f6bd7..beb0a06af9 100644
--- a/src/mbgl/renderer/render_tile.cpp
+++ b/src/mbgl/renderer/render_tile.cpp
@@ -23,8 +23,8 @@ mat4 RenderTile::translateVtxMatrix(const mat4& tileMatrix,
mat4 vtxMatrix;
const float angle = inViewportPixelUnits ?
- (anchor == TranslateAnchorType::Map ? state.getAngle() : 0) :
- (anchor == TranslateAnchorType::Viewport ? -state.getAngle() : 0);
+ (anchor == TranslateAnchorType::Map ? state.getBearing() : 0) :
+ (anchor == TranslateAnchorType::Viewport ? -state.getBearing() : 0);
Point<float> translate = util::rotate(Point<float>{ translation[0], translation[1] }, angle);
diff --git a/src/mbgl/style/style_impl.cpp b/src/mbgl/style/style_impl.cpp
index 760e2bc396..d65e9c9de2 100644
--- a/src/mbgl/style/style_impl.cpp
+++ b/src/mbgl/style/style_impl.cpp
@@ -105,7 +105,7 @@ void Style::Impl::parse(const std::string& json_) {
name = parser.name;
defaultCamera.center = parser.latLng;
defaultCamera.zoom = parser.zoom;
- defaultCamera.angle = parser.bearing;
+ defaultCamera.bearing = parser.bearing;
defaultCamera.pitch = parser.pitch;
setLight(std::make_unique<Light>(parser.light));
diff --git a/src/mbgl/text/placement.cpp b/src/mbgl/text/placement.cpp
index 078d646dc4..4cc12b0980 100644
--- a/src/mbgl/text/placement.cpp
+++ b/src/mbgl/text/placement.cpp
@@ -399,7 +399,7 @@ void Placement::updateBucketOpacities(SymbolBucket& bucket, std::set<uint32_t>&
}
bucket.updateOpacity();
- bucket.sortFeatures(state.getAngle());
+ bucket.sortFeatures(state.getBearing());
auto retainedData = retainedQueryData.find(bucket.bucketInstanceId);
if (retainedData != retainedQueryData.end()) {
retainedData->second.featureSortOrder = bucket.featureSortOrder;