summaryrefslogtreecommitdiffstats
path: root/src/location/maps/qgeotiledmapscene.cpp
diff options
context:
space:
mode:
authorPaolo Angelelli <paolo.angelelli@qt.io>2017-03-16 15:47:41 +0100
committerPaolo Angelelli <paolo.angelelli@qt.io>2017-03-22 11:13:49 +0000
commitbf356670158e95e4ba7fbeea774964e535bf6886 (patch)
treeaa958d92645d947cad89db8aad79a55b1ca7c9c9 /src/location/maps/qgeotiledmapscene.cpp
parente405d931678510d9f6f92d27a7834cb683665a5d (diff)
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/qgeotiledmapscene.cpp')
-rw-r--r--src/location/maps/qgeotiledmapscene.cpp9
1 files changed, 3 insertions, 6 deletions
diff --git a/src/location/maps/qgeotiledmapscene.cpp b/src/location/maps/qgeotiledmapscene.cpp
index 3711841d..d38eec39 100644
--- a/src/location/maps/qgeotiledmapscene.cpp
+++ b/src/location/maps/qgeotiledmapscene.cpp
@@ -350,7 +350,7 @@ void QGeoTiledMapScenePrivate::updateTileBounds(const QSet<QGeoTileSpec> &tiles)
void QGeoTiledMapScenePrivate::setupCamera()
{
// NOTE: The following instruction is correct only because WebMercator is a square projection!
- double f = 1.0 * qMin(m_screenSize.width(), m_screenSize.height());
+ double f = m_screenSize.height();
// Using fraction of zoom level, z varies between [ m_tileSize , 2 * m_tileSize [
double z = std::pow(2.0, m_cameraData.zoomLevel() - m_intZoomLevel) * m_tileSize;
@@ -431,11 +431,8 @@ void QGeoTiledMapScenePrivate::setupCamera()
double aspectRatio = 1.0 * m_screenSize.width() / m_screenSize.height();
float halfWidth = 1 * apertureSize;
float halfHeight = 1 * apertureSize;
- if (aspectRatio > 1.0) {
- halfWidth *= aspectRatio;
- } else if (aspectRatio > 0.0f && aspectRatio < 1.0f) {
- halfHeight /= aspectRatio;
- }
+ halfWidth *= aspectRatio;
+
m_projectionMatrix.setToIdentity();
m_projectionMatrix.frustum(-halfWidth, halfWidth, -halfHeight, halfHeight, nearPlane, farPlane);
}