summaryrefslogtreecommitdiff
path: root/src/imports
diff options
context:
space:
mode:
authorPaolo Angelelli <paolo.angelelli@qt.io>2016-12-02 18:18:23 +0100
committerPaolo Angelelli <paolo.angelelli@qt.io>2017-01-16 16:18:23 +0000
commit45b1f2c23cf0e782c0b99f38e4d01a88da765753 (patch)
tree1bfe5d5706db94722b3956ac17b65897b2370d30 /src/imports
parent5504a4c00ec01fdbc95a862c9bc63a680095daee (diff)
downloadqtlocation-45b1f2c23cf0e782c0b99f38e4d01a88da765753.tar.gz
Make zoomLevel refer to a default 256^2 tile size
Currently the zoomLevel is the power of 2 reflecting how many tiles are in a map edge. This means that two plugins with two different tileSize will show a map of different size at the same zoomLevel. With this patch the zoomLevel is "normalized" upon a tileSize of 256, regardless of the tile size in use. In this way, the new 256 based zoom level can be a consistent parameter also for plugins that are not tile based. CameraCapabilities therefore now offers two new methods, m[in,ax]imumZoomLevelAt256, that return the respective value for the normalized 256^2 tilesize. It also gets a setTileSize, which is currently not used as all our plugins use a tile size of 256 (which is the camera capabilities default tilesize value). Change-Id: Ib12092fd14faf7fc85f8be5fb799dbd5496b760b Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'src/imports')
-rw-r--r--src/imports/location/qdeclarativegeomap.cpp21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/imports/location/qdeclarativegeomap.cpp b/src/imports/location/qdeclarativegeomap.cpp
index a46d8b81..761fcdc5 100644
--- a/src/imports/location/qdeclarativegeomap.cpp
+++ b/src/imports/location/qdeclarativegeomap.cpp
@@ -51,6 +51,11 @@
#include <QtQml/qqmlinfo.h>
#include <cmath>
+#ifndef M_PI
+#define M_PI 3.141592653589793238463
+#endif
+
+
QT_BEGIN_NAMESPACE
/*!
@@ -562,11 +567,11 @@ void QDeclarativeGeoMap::mappingManagerInitialized()
//minimum zoom level might be changed to limit gray bundaries
if (m_gestureArea->maximumZoomLevel() < 0
- || m_mappingManager->cameraCapabilities().maximumZoomLevel() < m_gestureArea->maximumZoomLevel())
- setMaximumZoomLevel(m_mappingManager->cameraCapabilities().maximumZoomLevel());
+ || m_mappingManager->cameraCapabilities().maximumZoomLevelAt256() < m_gestureArea->maximumZoomLevel())
+ setMaximumZoomLevel(m_mappingManager->cameraCapabilities().maximumZoomLevelAt256());
- if (m_mappingManager->cameraCapabilities().minimumZoomLevel() > m_gestureArea->minimumZoomLevel())
- setMinimumZoomLevel(m_mappingManager->cameraCapabilities().minimumZoomLevel());
+ if (m_mappingManager->cameraCapabilities().minimumZoomLevelAt256() > m_gestureArea->minimumZoomLevel())
+ setMinimumZoomLevel(m_mappingManager->cameraCapabilities().minimumZoomLevelAt256());
// Map tiles are built in this call. m_map->minimumZoom() becomes operational
@@ -633,7 +638,7 @@ void QDeclarativeGeoMap::setMinimumZoomLevel(qreal minimumZoomLevel)
qreal oldMinimumZoomLevel = this->minimumZoomLevel();
if (m_map) {
- minimumZoomLevel = qBound(qreal(m_map->cameraCapabilities().minimumZoomLevel()), minimumZoomLevel, maximumZoomLevel());
+ minimumZoomLevel = qBound(qreal(m_map->cameraCapabilities().minimumZoomLevelAt256()), minimumZoomLevel, maximumZoomLevel());
double minimumViewportZoomLevel = m_map->minimumZoomAtViewportSize(width(),height());
if (minimumZoomLevel < minimumViewportZoomLevel)
minimumZoomLevel = minimumViewportZoomLevel;
@@ -668,7 +673,7 @@ qreal QDeclarativeGeoMap::minimumZoomLevel() const
if (m_gestureArea->minimumZoomLevel() != -1)
return m_gestureArea->minimumZoomLevel();
else if (m_map)
- return m_map->cameraCapabilities().minimumZoomLevel();
+ return m_map->cameraCapabilities().minimumZoomLevelAt256();
else
return -1.0;
}
@@ -684,7 +689,7 @@ void QDeclarativeGeoMap::setMaximumZoomLevel(qreal maximumZoomLevel)
qreal oldMaximumZoomLevel = this->maximumZoomLevel();
if (m_map)
- maximumZoomLevel = qBound(minimumZoomLevel(), maximumZoomLevel, qreal(m_map->cameraCapabilities().maximumZoomLevel()));
+ maximumZoomLevel = qBound(minimumZoomLevel(), maximumZoomLevel, qreal(m_map->cameraCapabilities().maximumZoomLevelAt256()));
m_gestureArea->setMaximumZoomLevel(maximumZoomLevel);
@@ -710,7 +715,7 @@ qreal QDeclarativeGeoMap::maximumZoomLevel() const
if (m_gestureArea->maximumZoomLevel() != -1)
return m_gestureArea->maximumZoomLevel();
else if (m_map)
- return m_map->cameraCapabilities().maximumZoomLevel();
+ return m_map->cameraCapabilities().minimumZoomLevelAt256();
else
return -1.0;
}