diff options
author | Paolo Angelelli <paolo.angelelli@qt.io> | 2017-01-13 17:51:30 +0100 |
---|---|---|
committer | Paolo Angelelli <paolo.angelelli@qt.io> | 2017-01-26 14:46:21 +0000 |
commit | 1946896ace3f5fa8b6086fb416ea934fea387f12 (patch) | |
tree | ff64d144760bef6d917967579b2c7e368dac7a6e /src/location/maps | |
parent | d83f23e1ef19fe524c50b827ee408523dbb74bdc (diff) | |
download | qtlocation-1946896ace3f5fa8b6086fb416ea934fea387f12.tar.gz |
Adapt QQuickGeoMapGestureArea to work with tilted and rotated maps
This patch fixes the handling of pan/flick/pinch in
presence of tilt or bearing.
Change-Id: Iad04fd92e1c8e318e3b1b0d344852c81e554ebb7
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Diffstat (limited to 'src/location/maps')
-rw-r--r-- | src/location/maps/qgeoprojection.cpp | 8 | ||||
-rw-r--r-- | src/location/maps/qgeoprojection_p.h | 1 |
2 files changed, 8 insertions, 1 deletions
diff --git a/src/location/maps/qgeoprojection.cpp b/src/location/maps/qgeoprojection.cpp index 77a91a15..15f400d9 100644 --- a/src/location/maps/qgeoprojection.cpp +++ b/src/location/maps/qgeoprojection.cpp @@ -84,7 +84,8 @@ QGeoProjectionWebMercator::QGeoProjectionWebMercator() m_nearPlane(0.0), m_farPlane(0.0), m_halfWidth(0.0), - m_halfHeight(0.0) + m_halfHeight(0.0), + m_minimumUnprojectableY(0.0) { } @@ -195,6 +196,9 @@ QDoubleVector2D QGeoProjectionWebMercator::wrappedMapProjectionToItemPosition(co QDoubleVector2D QGeoProjectionWebMercator::itemPositionToWrappedMapProjection(const QDoubleVector2D &itemPosition) const { QDoubleVector2D pos = itemPosition; + // when the camera is tilted, picking a point above the horizon returns a coordinate behind the camera + if (pos.y() < m_minimumUnprojectableY) + pos.setY(m_minimumUnprojectableY); pos *= QDoubleVector2D(m_1_viewportWidth, m_1_viewportHeight); pos *= 2.0; pos -= QDoubleVector2D(1.0,1.0); @@ -399,6 +403,8 @@ void QGeoProjectionWebMercator::setupCamera() verticalEstateToSkip = 1.0 - maxHalfAperture / verticalAperture; } + m_minimumUnprojectableY = verticalEstateToSkip * 0.5 * m_viewportHeight; // verticalEstateToSkip is relative to half aperture + QDoubleVector2D tl = viewportToWrappedMapProjection(QDoubleVector2D(-1, -1 + verticalEstateToSkip )); QDoubleVector2D tr = viewportToWrappedMapProjection(QDoubleVector2D( 1, -1 + verticalEstateToSkip )); QDoubleVector2D bl = viewportToWrappedMapProjection(QDoubleVector2D(-1, 1 )); diff --git a/src/location/maps/qgeoprojection_p.h b/src/location/maps/qgeoprojection_p.h index d8508578..6ea8fd6e 100644 --- a/src/location/maps/qgeoprojection_p.h +++ b/src/location/maps/qgeoprojection_p.h @@ -183,6 +183,7 @@ private: double m_farPlane; double m_halfWidth; double m_halfHeight; + double m_minimumUnprojectableY; // For the clipping region QDoubleVector3D m_centerMercator; |