diff options
author | Paolo Angelelli <paolo.angelelli@qt.io> | 2017-03-16 15:47:41 +0100 |
---|---|---|
committer | Paolo Angelelli <paolo.angelelli@qt.io> | 2017-03-22 11:13:49 +0000 |
commit | bf356670158e95e4ba7fbeea774964e535bf6886 (patch) | |
tree | aa958d92645d947cad89db8aad79a55b1ca7c9c9 /src/location/maps/qgeoprojection.cpp | |
parent | e405d931678510d9f6f92d27a7834cb683665a5d (diff) | |
download | qtlocation-bf356670158e95e4ba7fbeea774964e535bf6886.tar.gz |
Fix for projection mismatch when aspect ratio < 1.0
This patch fixes an incorrect computation of the projection matrices and
thus a mismatch in projections between mbgl vs the other plugins when
the window A/R is less than 1.0.
Task-number: QTBUG-59417
Change-Id: Ib03eaa4c877a00c9281c335f859c854d6db632c0
Reviewed-by: Bruno de Oliveira Abinader <brunoabinader@gmail.com>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Diffstat (limited to 'src/location/maps/qgeoprojection.cpp')
-rw-r--r-- | src/location/maps/qgeoprojection.cpp | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/src/location/maps/qgeoprojection.cpp b/src/location/maps/qgeoprojection.cpp index 81f3a947..4e5f1979 100644 --- a/src/location/maps/qgeoprojection.cpp +++ b/src/location/maps/qgeoprojection.cpp @@ -329,7 +329,7 @@ void QGeoProjectionWebMercator::setupCamera() m_sideLength = (1 << intZoomLevel) * defaultTileSize; m_center = m_centerMercator * m_sideLength; - double f = 1.0 * qMin(m_viewportWidth, m_viewportHeight); + double f = m_viewportHeight; double z = std::pow(2.0, m_cameraData.zoomLevel() - intZoomLevel) * defaultTileSize; double altitude = f / (2.0 * z); // Also in mercator space @@ -402,16 +402,10 @@ void QGeoProjectionWebMercator::setupCamera() double aspectRatio = 1.0 * m_viewportWidth / m_viewportHeight; - m_halfWidth = m_aperture; + m_halfWidth = m_aperture * aspectRatio; m_halfHeight = m_aperture; - double verticalAperture = m_aperture; - if (aspectRatio > 1.0) { - m_halfWidth *= aspectRatio; - } else if (aspectRatio > 0.0 && aspectRatio < 1.0) { - m_halfHeight /= aspectRatio; - verticalAperture /= aspectRatio; - } - double verticalHalfFOV = QLocationUtils::degrees(atan(verticalAperture)); + + double verticalHalfFOV = QLocationUtils::degrees(atan(m_aperture)); QDoubleMatrix4x4 cameraMatrix; cameraMatrix.lookAt(m_eye, m_center, m_up); @@ -452,7 +446,7 @@ void QGeoProjectionWebMercator::setupCamera() double verticalEstateToSkip = 0; if (maxRayElevation < verticalHalfFOV) { maxHalfAperture = tan(QLocationUtils::radians(maxRayElevation)); - verticalEstateToSkip = 1.0 - maxHalfAperture / verticalAperture; + verticalEstateToSkip = 1.0 - maxHalfAperture / m_aperture; } m_minimumUnprojectableY = verticalEstateToSkip * 0.5 * m_viewportHeight; // verticalEstateToSkip is relative to half aperture |