Merge branch 'map' of https://vcs.maemo.org/git/situare into map
[situare] / src / map / mapengine.cpp
index 38f45f2..6b607aa 100644 (file)
@@ -53,6 +53,7 @@ void MapEngine::init()
 {
     emit zoomLevelChanged(m_zoomLevel);
     setViewLocation(QPointF(25.5000, 65.0000));
+    emit locationChanged(m_sceneCoordinate);
 
 //    // Fetch some map tiles for demo purposes
 //    for (int x=9351; x<=9354; x++) {
@@ -67,6 +68,7 @@ void MapEngine::setViewLocation(QPointF latLonCoordinate)
 {
     qDebug() << __PRETTY_FUNCTION__;
     setLocation(convertLatLonToSceneCoordinate(latLonCoordinate));
+    emit locationChanged(m_sceneCoordinate);
 }
 
 QUrl MapEngine::buildURL(int zoomLevel, QPoint tileNumbers)
@@ -115,7 +117,7 @@ void MapEngine::mapImageReceived(const QUrl &url, const QPixmap &pixmap)
 
         removeStackedTiles(mapTile);
 
-        qDebug() << "Tile count: " << m_mapScene->items().count();
+        //qDebug() << "Tile count: " << m_mapScene->items().count();
    }
 }
 
@@ -129,7 +131,7 @@ int MapEngine::tileMaxValue(int zoomLevel)
     return (1 << zoomLevel) - 1;
 }
 
-QRect MapEngine::calculateGrid(QPointF sceneCoordinate)
+QRect MapEngine::calculateGrid(QPoint sceneCoordinate)
 {
     QPoint tileCoordinate = convertSceneCoordinateToTileNumber(m_zoomLevel, sceneCoordinate);
     int gridWidth = (m_viewSize.width()/TILE_SIZE_X + 1) + (GRID_PADDING*2);
@@ -140,10 +142,11 @@ QRect MapEngine::calculateGrid(QPointF sceneCoordinate)
     return QRect(topLeftX, topLeftY, gridWidth, gridHeight);
 }
 
-void MapEngine::setLocation(QPointF sceneCoordinate)
+void MapEngine::setLocation(QPoint sceneCoordinate)
 {
+    //qDebug() << __PRETTY_FUNCTION__;
+
     m_sceneCoordinate = sceneCoordinate;
-    emit locationChanged(m_sceneCoordinate);
 
     if (centerTileChanged(sceneCoordinate)) {
         calculateNewTiles(sceneCoordinate);
@@ -151,7 +154,7 @@ void MapEngine::setLocation(QPointF sceneCoordinate)
     }
 }
 
-bool MapEngine::centerTileChanged(QPointF sceneCoordinate)
+bool MapEngine::centerTileChanged(QPoint sceneCoordinate)
 {
     QPoint centerTile = convertSceneCoordinateToTileNumber(m_zoomLevel, sceneCoordinate);
     QPoint temp = m_centerTile;
@@ -160,7 +163,7 @@ bool MapEngine::centerTileChanged(QPointF sceneCoordinate)
     return (centerTile != temp);
 }
 
-void MapEngine::calculateNewTiles(QPointF sceneCoordinate)
+void MapEngine::calculateNewTiles(QPoint sceneCoordinate)
 {
     //qDebug() << __PRETTY_FUNCTION__;
 
@@ -251,8 +254,7 @@ void MapEngine::removeStackedTiles(MapTile *tile)
 void MapEngine::viewResized(const QSize &size)
 {
     m_viewSize = size;
-    //setLocation(m_sceneCoordinate);
-    calculateNewTiles(m_sceneCoordinate);
+    setLocation(m_sceneCoordinate);
 }
 
 void MapEngine::zoomIn()