diff options
Diffstat (limited to 'src/mbgl/map/transform.cpp')
-rw-r--r-- | src/mbgl/map/transform.cpp | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/src/mbgl/map/transform.cpp b/src/mbgl/map/transform.cpp index 85805a109d..ba5e205301 100644 --- a/src/mbgl/map/transform.cpp +++ b/src/mbgl/map/transform.cpp @@ -9,8 +9,8 @@ #include <mbgl/util/chrono.hpp> #include <mbgl/util/projection.hpp> #include <mbgl/math/clamp.hpp> -#include <mbgl/platform/log.hpp> -#include <mbgl/platform/platform.hpp> +#include <mbgl/util/logging.hpp> +#include <mbgl/util/platform.hpp> #include <cstdio> #include <cmath> @@ -45,8 +45,8 @@ Transform::Transform(std::function<void(MapChange)> callback_, #pragma mark - Map View -bool Transform::resize(const std::array<uint16_t, 2> size) { - if (state.width == size[0] && state.height == size[1]) { +bool Transform::resize(const Size size) { + if (state.size == size) { return false; } @@ -54,8 +54,7 @@ bool Transform::resize(const std::array<uint16_t, 2> size) { callback(MapChangeRegionWillChange); } - state.width = size[0]; - state.height = size[1]; + state.size = size; state.constrain(state.scale, state.x, state.y); if (callback) { @@ -117,7 +116,7 @@ void Transform::easeTo(const CameraOptions& camera, const AnimationOptions& anim const Point<double> endPoint = Projection::project(latLng, state.scale); ScreenCoordinate center = getScreenCoordinate(padding); - center.y = state.height - center.y; + center.y = state.size.height - center.y; // Constrain camera options. zoom = util::clamp(zoom, state.getMinZoom(), state.getMaxZoom()); @@ -187,7 +186,7 @@ void Transform::flyTo(const CameraOptions &camera, const AnimationOptions &anima const Point<double> endPoint = Projection::project(latLng, state.scale); ScreenCoordinate center = getScreenCoordinate(padding); - center.y = state.height - center.y; + center.y = state.size.height - center.y; // Constrain camera options. zoom = util::clamp(zoom, state.getMinZoom(), state.getMaxZoom()); @@ -203,9 +202,9 @@ void Transform::flyTo(const CameraOptions &camera, const AnimationOptions &anima /// w₀: Initial visible span, measured in pixels at the initial scale. /// Known henceforth as a <i>screenful</i>. - double w0 = padding ? std::max(state.width, state.height) - : std::max(state.width - padding.left - padding.right, - state.height - padding.top - padding.bottom); + double w0 = padding ? std::max(state.size.width, state.size.height) + : std::max(state.size.width - padding.left - padding.right, + state.size.height - padding.top - padding.bottom); /// w₁: Final visible span, measured in pixels with respect to the initial /// scale. double w1 = w0 / state.zoomScale(zoom - startZoom); @@ -355,8 +354,8 @@ void Transform::setLatLng(const LatLng& latLng, optional<ScreenCoordinate> ancho EdgeInsets padding; padding.top = anchor->y; padding.left = anchor->x; - padding.bottom = state.height - anchor->y; - padding.right = state.width - anchor->x; + padding.bottom = state.size.height - anchor->y; + padding.right = state.size.width - anchor->x; if (padding) camera.padding = padding; } easeTo(camera, duration); @@ -378,7 +377,7 @@ void Transform::setLatLngZoom(const LatLng& latLng, double zoom, optional<EdgeIn LatLng Transform::getLatLng(optional<EdgeInsets> padding) const { if (padding && *padding) { - return screenCoordinateToLatLng(padding->getCenter(state.width, state.height)); + return screenCoordinateToLatLng(padding->getCenter(state.size.width, state.size.height)); } else { return state.getLatLng(); } @@ -386,9 +385,9 @@ LatLng Transform::getLatLng(optional<EdgeInsets> padding) const { ScreenCoordinate Transform::getScreenCoordinate(optional<EdgeInsets> padding) const { if (padding && *padding) { - return padding->getCenter(state.width, state.height); + return padding->getCenter(state.size.width, state.size.height); } else { - return { state.width / 2., state.height / 2. }; + return { state.size.width / 2., state.size.height / 2. }; } } @@ -565,7 +564,7 @@ void Transform::startTransition(const CameraOptions& camera, optional<ScreenCoordinate> anchor = camera.anchor; LatLng anchorLatLng; if (anchor) { - anchor->y = state.getHeight() - anchor->y; + anchor->y = state.size.height - anchor->y; anchorLatLng = state.screenCoordinateToLatLng(*anchor); } @@ -650,13 +649,13 @@ ScreenCoordinate Transform::latLngToScreenCoordinate(const LatLng& latLng) const LatLng unwrappedLatLng = latLng.wrapped(); unwrappedLatLng.unwrapForShortestPath(getLatLng()); ScreenCoordinate point = state.latLngToScreenCoordinate(unwrappedLatLng); - point.y = state.height - point.y; + point.y = state.size.height - point.y; return point; } LatLng Transform::screenCoordinateToLatLng(const ScreenCoordinate& point) const { ScreenCoordinate flippedPoint = point; - flippedPoint.y = state.height - flippedPoint.y; + flippedPoint.y = state.size.height - flippedPoint.y; return state.screenCoordinateToLatLng(flippedPoint).wrapped(); } |