From 1946896ace3f5fa8b6086fb416ea934fea387f12 Mon Sep 17 00:00:00 2001 From: Paolo Angelelli Date: Fri, 13 Jan 2017 17:51:30 +0100 Subject: 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 --- src/location/maps/qgeoprojection.cpp | 8 +++++++- src/location/maps/qgeoprojection_p.h | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'src/location/maps') 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; -- cgit v1.2.1