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/qgeotiledmapscene.cpp | |
parent | e405d931678510d9f6f92d27a7834cb683665a5d (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.cpp | 9 |
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); } |