e545c59864d462dfab933fd3aa03a2f4367387ec
[situare] / src / map / mapengine.cpp
1  /*
2     Situare - A location system for Facebook
3     Copyright (C) 2010  Ixonos Plc. Authors:
4
5         Sami Rämö - sami.ramo@ixonos.com
6
7     Situare is free software; you can redistribute it and/or
8     modify it under the terms of the GNU General Public License
9     as published by the Free Software Foundation; either version 2
10     of the License, or (at your option) any later version.
11
12     Situare is distributed in the hope that it will be useful,
13     but WITHOUT ANY WARRANTY; without even the implied warranty of
14     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15     GNU General Public License for more details.
16
17     You should have received a copy of the GNU General Public License
18     along with Situare; if not, write to the Free Software
19     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
20     USA.
21  */
22
23 #include <QDebug>
24
25 #include "mapengine.h"
26 #include "maptile.h"
27 #include "mapscene.h"
28
29 MapEngine::MapEngine()
30 {
31
32 }
33
34 MapEngine::MapEngine(MapView *mapView)
35 {
36     m_mapView = mapView;
37     m_mapScene = new MapScene();
38     mapView->setScene(m_mapScene);
39     m_zoomLevel = 14;
40 }
41
42 void MapEngine::setViewLocation(QPointF latLonCoordinate)
43 {
44     m_mapView->setZoomLevel(m_zoomLevel);
45
46     /*
47      * Add some dummy map tiles for demo purposes
48      */
49
50     for (int x=9351; x<=9354; x++) {
51         for (int y=4261; y<=4264; y++) {
52             MapTile *mapTile = new MapTile();
53             mapTile->setZoomLevel(m_zoomLevel);
54             mapTile->setTileNumber(QPoint(x, y));
55             QString fileName = QString("res/images/test_map_tiles/%1_%2_%3.png").arg(mapTile->zoomLevel()).arg(x).arg(y);
56 //            qDebug() << __PRETTY_FUNCTION__ << "fileName:" << fileName;
57             mapTile->setPixmap(QPixmap(fileName));
58             m_mapScene->addMapTile(mapTile);
59         }
60     }
61 }