diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2016-03-16 17:45:00 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2016-05-05 11:30:53 -0700 |
commit | 9330d674a983652d248d6a43fa4adbf5970c3d30 (patch) | |
tree | bd9292fcdb14f416922197f36c7707bb52e13591 /src/mbgl/map/transform.cpp | |
parent | f89cfacab2457602c5bd81ab9da35cede23584e2 (diff) | |
download | qtlocation-mapboxgl-9330d674a983652d248d6a43fa4adbf5970c3d30.tar.gz |
[core] Use geometry.hpp's point
Diffstat (limited to 'src/mbgl/map/transform.cpp')
-rw-r--r-- | src/mbgl/map/transform.cpp | 20 |
1 files changed, 3 insertions, 17 deletions
diff --git a/src/mbgl/map/transform.cpp b/src/mbgl/map/transform.cpp index 06cde18c6e..69a644c7d9 100644 --- a/src/mbgl/map/transform.cpp +++ b/src/mbgl/map/transform.cpp @@ -343,8 +343,6 @@ void Transform::flyTo(const CameraOptions &camera, const AnimationOptions &anima #pragma mark - Position void Transform::moveBy(const ScreenCoordinate& offset, const Duration& duration) { - if (!offset) return; - ScreenCoordinate centerOffset = { offset.x, -offset.y, @@ -477,10 +475,6 @@ void Transform::setMaxZoom(const double maxZoom) { #pragma mark - Angle void Transform::rotateBy(const ScreenCoordinate& first, const ScreenCoordinate& second, const Duration& duration) { - if (!first || !second) { - return; - } - ScreenCoordinate center = getScreenCoordinate(); const ScreenCoordinate offset = first - center; const double distance = std::sqrt(std::pow(2, offset.x) + std::pow(2, offset.y)); @@ -493,13 +487,9 @@ void Transform::rotateBy(const ScreenCoordinate& first, const ScreenCoordinate& center.x = first.x + std::cos(rotateAngle) * heightOffset; center.y = first.y + std::sin(rotateAngle) * heightOffset; } - - const ScreenCoordinate newFirst = first - center; - const ScreenCoordinate newSecond = second - center; - const double ang = state.angle + util::angle_between(newFirst.x, newFirst.y, newSecond.x, newSecond.y); CameraOptions camera; - camera.angle = ang; + camera.angle = state.angle + util::angle_between(first - center, second - center); easeTo(camera, duration); } @@ -581,7 +571,7 @@ void Transform::startTransition(const CameraOptions& camera, // Associate the anchor, if given, with a coordinate. optional<ScreenCoordinate> anchor = camera.anchor; LatLng anchorLatLng; - if (anchor && *anchor) { + if (anchor) { anchor->y = state.getHeight() - anchor->y; anchorLatLng = state.screenCoordinateToLatLng(*anchor); } @@ -599,7 +589,7 @@ void Transform::startTransition(const CameraOptions& camera, result = frame(ease.solve(t, 0.001)); } - if (anchor && *anchor) state.moveLatLng(anchorLatLng, *anchor); + if (anchor) state.moveLatLng(anchorLatLng, *anchor); // At t = 1.0, a DidChangeAnimated notification should be sent from finish(). if (t < 1.0) { @@ -657,8 +647,6 @@ void Transform::setGestureInProgress(bool inProgress) { #pragma mark Conversion and projection ScreenCoordinate Transform::latLngToScreenCoordinate(const LatLng& latLng) const { - if (!latLng) return ScreenCoordinate::null(); - // If the center and point longitudes are not in the same side of the // antimeridian, we unwrap the point longitude so it would be seen if // e.g. the next antimeridian side is visible. @@ -670,8 +658,6 @@ ScreenCoordinate Transform::latLngToScreenCoordinate(const LatLng& latLng) const } LatLng Transform::screenCoordinateToLatLng(const ScreenCoordinate& point) const { - if (!point) return LatLng::null(); - ScreenCoordinate flippedPoint = point; flippedPoint.y = state.height - flippedPoint.y; return state.screenCoordinateToLatLng(flippedPoint).wrapped(); |