qDebug() << "Scene coord: " << sceneCoord.x() << "," << sceneCoord.y();
setLocation(sceneCoord);
+ qDebug() << "centerToScene: " << sceneCoord.x() << "," << sceneCoord.y();
+ emit centerToSceneCoordinates(sceneCoord);
}
QUrl MapEngine::buildURL(int zoomLevel, QPoint tileNumbers)
MapTile *mapTile = new MapTile();
mapTile->setZoomLevel(zoom);
mapTile->setTileNumber(QPoint(x, y));
- mapTile->setPixmap(pixmap);
+ mapTile->setPixmap(pixmap);
+
+ mapTilesInScene.insert(url.toString(), mapTile);
m_mapScene->addMapTile(mapTile);
+
+ qDebug() << "Tile count: " << mapTilesInScene.size();
}
QGraphicsScene* MapEngine::scene()
else if (tileY > tileMaxVal)
tileY -= tileMaxVal;
- qDebug() << QUrl(buildURL(m_zoomLevel, QPoint(tileX, tileY))).toString();
- emit fetchImage(buildURL(m_zoomLevel, QPoint(tileX, tileY)));
+ QUrl url = buildURL(m_zoomLevel, QPoint(tileX, tileY));
+
+ qDebug() << url.toString();
+
+ if (!mapTilesInScene.contains(url.toString()))
+ emit fetchImage(buildURL(m_zoomLevel, QPoint(tileX, tileY)));
}
}
}
#include "common.h"
#include "mapfetcher.h"
#include "mapscene.h"
+#include "maptile.h"
/**
* @brief Map engine
void fetchImage(const QUrl &url);
+ void centerToSceneCoordinates(QPointF sceneCoordinate);
+
private:
MapScene *m_mapScene; ///< Scene for map tiles
MapFetcher *m_mapFetcher; ///< Fetcher for map tiles
int m_zoomLevel; ///< Current zoom level
- QStringList mapTilesInScene; ///< List of map tiles in map scene
+ QHash<QString, MapTile *> mapTilesInScene; ///< List of map tiles in map scene
};
#endif // MAPENGINE_H
//DEBUG
QVBoxLayout *topAreaLayout = new QVBoxLayout;
search = new QPushButton("Show", this);
+ lonLine.setText(QString("25.5400"));
+ latLine.setText(QString("65.0000"));
topAreaLayout->addWidget(&lonLine);
topAreaLayout->addWidget(&latLine);
topAreaLayout->addWidget(search);
mapEngine = new MapEngine(this);
mapView->setScene(mapEngine->scene());
connect(mapEngine, SIGNAL(zoomLevelChanged(int)), mapView, SLOT(setZoomLevel(int)));
- mapEngine->setViewLocation(QPointF(25.5000, 65.0000));
+ show();
}
void MapViewScreen::show()