Got spanning of items (friends, locations) working
[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        Jussi Laitinen - jussi.laitinen@ixonos.com
7        Pekka Nissinen - pekka.nissinen@ixonos.com
8        Ville Tiensuu - ville.tiensuu@ixonos.com
9
10    Situare is free software; you can redistribute it and/or
11    modify it under the terms of the GNU General Public License
12    version 2 as published by the Free Software Foundation.
13
14    Situare is distributed in the hope that it will be useful,
15    but WITHOUT ANY WARRANTY; without even the implied warranty of
16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17    GNU General Public License for more details.
18
19    You should have received a copy of the GNU General Public License
20    along with Situare; if not, write to the Free Software
21    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
22    USA.
23 */
24
25 #include <QtAlgorithms>
26 #include <QDebug>
27 #include <QString>
28 #include <QStringList>
29 #include <QUrl>
30 #include <QHash>
31 #include <QHashIterator>
32 #include <QRect>
33
34 #include "common.h"
35 #include "frienditemshandler.h"
36 #include "gpslocationitem.h"
37 #include "mapcommon.h"
38 #include "mapfetcher.h"
39 #include "mapscene.h"
40 #include "maptile.h"
41 #include "network/networkaccessmanager.h"
42 #include "ownlocationitem.h"
43 #include "user/user.h"
44
45 #include "mapengine.h"
46
47 MapEngine::MapEngine(QObject *parent)
48     : QObject(parent),
49       m_autoCenteringEnabled(false),
50       m_zoomedIn(false),
51       m_zoomLevel(DEFAULT_ZOOM_LEVEL),
52       m_centerTile(QPoint(UNDEFINED, UNDEFINED)),
53       m_lastManualPosition(QPoint(0, 0)),
54       m_tilesGridSize(QSize(0, 0)),
55       m_viewSize(QSize(DEFAULT_SCREEN_WIDTH, DEFAULT_SCREEN_HEIGHT))
56 {
57     qDebug() << __PRETTY_FUNCTION__;
58
59     m_mapScene = new MapScene(this);
60
61     m_mapFetcher = new MapFetcher(NetworkAccessManager::instance(), this);
62     connect(this, SIGNAL(fetchImage(int, int, int)),
63             m_mapFetcher, SLOT(enqueueFetchMapImage(int, int, int)));
64     connect(m_mapFetcher, SIGNAL(mapImageReceived(int, int, int, QPixmap)),
65             this, SLOT(mapImageReceived(int, int, int, QPixmap)));
66
67     m_ownLocation = new OwnLocationItem();
68     m_ownLocation->hide(); // hide until first location info is received
69     m_mapScene->addItem(m_ownLocation);
70
71     m_gpsLocationItem = new GPSLocationItem();
72     m_mapScene->addItem(m_gpsLocationItem);
73
74     m_friendItemsHandler = new FriendItemsHandler(m_mapScene, this);
75     connect(this, SIGNAL(zoomLevelChanged(int)),
76             m_friendItemsHandler, SLOT(refactorFriendItems(int)));
77
78     connect(this, SIGNAL(friendsLocationsReady(QList<User*>&)),
79             m_friendItemsHandler, SLOT(friendListUpdated(QList<User*>&)));
80
81     connect(m_friendItemsHandler, SIGNAL(locationItemClicked(QList<QString>)),
82             this, SIGNAL(locationItemClicked(QList<QString>)));
83 }
84
85 MapEngine::~MapEngine()
86 {
87     qDebug() << __PRETTY_FUNCTION__;
88
89     QSettings settings(DIRECTORY_NAME, FILE_NAME);
90     settings.setValue(MAP_LAST_POSITION,
91                       convertSceneCoordinateToLatLon(m_zoomLevel, m_sceneCoordinate));
92     settings.setValue(MAP_LAST_ZOOMLEVEL, m_zoomLevel);
93 }
94
95 QRect MapEngine::calculateTileGrid(QPoint sceneCoordinate)
96 {
97     qDebug() << __PRETTY_FUNCTION__;
98
99     QPoint tileCoordinate = convertSceneCoordinateToTileNumber(m_zoomLevel, sceneCoordinate);
100
101     QPoint topLeft;
102     topLeft.setX(tileCoordinate.x() - (m_tilesGridSize.width() / 2));
103     topLeft.setY(tileCoordinate.y() - (m_tilesGridSize.height() / 2));
104
105     return QRect(topLeft, m_tilesGridSize);
106 }
107
108 QPointF MapEngine::centerGeoCoordinate()
109 {
110     qDebug() << __PRETTY_FUNCTION__;
111
112     return convertSceneCoordinateToLatLon(m_zoomLevel, m_sceneCoordinate);
113 }
114
115 QPoint MapEngine::convertLatLonToSceneCoordinate(QPointF latLonCoordinate)
116 {
117     qDebug() << __PRETTY_FUNCTION__;
118
119     qreal longitude = latLonCoordinate.x();
120     qreal latitude = latLonCoordinate.y();
121
122     if ((longitude > MAX_LONGITUDE) || (longitude < MIN_LONGITUDE))
123         return QPoint(UNDEFINED, UNDEFINED);
124     if ((latitude > MAX_LATITUDE) || (latitude < MIN_LATITUDE))
125         return QPoint(UNDEFINED, UNDEFINED);
126
127     qreal z = static_cast<qreal>(1 << MAX_MAP_ZOOM_LEVEL);
128
129     qreal x = static_cast<qreal>((longitude + 180.0) / 360.0);
130     qreal y = static_cast<qreal>((1.0 - log(tan(latitude * M_PI / 180.0) + 1.0
131                                 / cos(latitude * M_PI / 180.0)) / M_PI) / 2.0);
132
133     return QPointF(x * z * TILE_SIZE_X, y * z * TILE_SIZE_Y).toPoint();
134 }
135
136 QPointF MapEngine::convertSceneCoordinateToLatLon(int zoomLevel, QPoint sceneCoordinate)
137 {
138     qDebug() << __PRETTY_FUNCTION__;
139
140     double tileFactor = 1 << (MAX_MAP_ZOOM_LEVEL - zoomLevel);
141     double xFactor = (sceneCoordinate.x() / (TILE_SIZE_X*tileFactor));
142     double yFactor = (sceneCoordinate.y() / (TILE_SIZE_Y*tileFactor));
143
144     tileFactor = 1 << zoomLevel;
145     double longitude = xFactor / tileFactor * 360.0 - 180;
146
147     double n = M_PI - 2.0 * M_PI * yFactor / tileFactor;
148     double latitude = 180.0 / M_PI * atan(0.5 * (exp(n) - exp(-n)));
149
150     return QPointF(longitude, latitude);
151 }
152
153 QPoint MapEngine::convertSceneCoordinateToTileNumber(int zoomLevel, QPoint sceneCoordinate)
154 {
155     qDebug() << __PRETTY_FUNCTION__;
156
157     int pow = 1 << (MAX_MAP_ZOOM_LEVEL - zoomLevel);
158     int x = static_cast<int>(sceneCoordinate.x() / (TILE_SIZE_X * pow));
159     int y = static_cast<int>(sceneCoordinate.y() / (TILE_SIZE_Y * pow));
160
161     return QPoint(x, y);
162 }
163
164 QPoint MapEngine::convertTileNumberToSceneCoordinate(int zoomLevel, QPoint tileNumber)
165 {
166     qDebug() << __PRETTY_FUNCTION__;
167
168     int pow = 1 << (MAX_MAP_ZOOM_LEVEL - zoomLevel);
169     int x = tileNumber.x() * TILE_SIZE_X * pow;
170     int y = tileNumber.y() * TILE_SIZE_Y * pow;
171
172     return QPoint(x, y);
173 }
174
175 bool MapEngine::disableAutoCentering(QPoint sceneCoordinate)
176 {
177     if (isAutoCenteringEnabled()) {
178         int zoomFactor = (1 << (MAX_MAP_ZOOM_LEVEL - m_zoomLevel));
179
180         QPoint oldPixelValue = QPoint(m_lastManualPosition.x() / zoomFactor,
181                                       m_lastManualPosition.y() / zoomFactor);
182
183         QPoint newPixelValue = QPoint(sceneCoordinate.x() / zoomFactor,
184                                       sceneCoordinate.y() / zoomFactor);
185
186         if ((abs(oldPixelValue.x() - newPixelValue.x()) > AUTO_CENTERING_DISABLE_DISTANCE) ||
187             (abs(oldPixelValue.y() - newPixelValue.y()) > AUTO_CENTERING_DISABLE_DISTANCE))
188             return true;
189     }
190
191     return false;
192 }
193
194 void MapEngine::getTiles(QPoint sceneCoordinate)
195 {
196     qDebug() << __PRETTY_FUNCTION__;
197
198     m_viewTilesGrid = calculateTileGrid(sceneCoordinate);
199     updateViewTilesSceneRect();
200
201     int topLeftX = m_viewTilesGrid.topLeft().x();
202     int topLeftY = m_viewTilesGrid.topLeft().y();
203     int bottomRightX = m_viewTilesGrid.bottomRight().x();
204     int bottomRightY = m_viewTilesGrid.bottomRight().y();
205
206     int tileMaxVal = tileMaxValue(m_zoomLevel);
207
208     for (int x = topLeftX; x <= bottomRightX; ++x) {
209         for (int y = topLeftY; y <= bottomRightY; ++y) {
210
211             int tileX = x;
212             int tileY = y;
213
214             // span in horizontal direction if world limits has been reached
215 //            if (tileX < 0)
216 //                tileX += tileMaxVal + 1;
217 //            else if (tileX > tileMaxVal)
218 //                tileX -= tileMaxVal + 1;
219
220             // map doesn't span in vertical direction
221             if (tileY < 0 || tileY > tileMaxVal)
222                 continue;
223
224             if (!m_mapScene->tileInScene(tilePath(m_zoomLevel, tileX, tileY)))
225                 emit fetchImage(m_zoomLevel, normalize(tileX, 0, tileMaxVal), tileY);
226         }
227     }
228
229 //    QRect spanRect = m_mapScene->spanItems(m_scrollDirection, m_zoomLevel, m_sceneCoordinate, m_viewSize);
230 //    m_friendItemsHandler->spanHiddenFriendLocationItems(m_scrollDirection, spanRect, m_sceneCoordinate);
231 //    m_friendItemsHandler->refactorFriendItems(m_zoomLevel);
232
233
234 }
235
236 void MapEngine::gpsPositionUpdate(QPointF position, qreal accuracy)
237 {
238     qDebug() << __PRETTY_FUNCTION__;
239
240     m_gpsLocationItem->updatePosition(convertLatLonToSceneCoordinate(position), accuracy);
241
242     if (m_autoCenteringEnabled)
243         setViewLocation(position);
244 }
245
246 void MapEngine::init()
247 {
248     qDebug() << __PRETTY_FUNCTION__;
249
250     QPointF startLocation;
251     QSettings settings(DIRECTORY_NAME, FILE_NAME);
252
253     if (settings.value(MAP_LAST_POSITION, ERROR_VALUE_NOT_FOUND_ON_SETTINGS).toString()
254         == ERROR_VALUE_NOT_FOUND_ON_SETTINGS || settings.value(MAP_LAST_ZOOMLEVEL,
255         ERROR_VALUE_NOT_FOUND_ON_SETTINGS).toString() == ERROR_VALUE_NOT_FOUND_ON_SETTINGS) {
256
257         startLocation = QPointF(DEFAULT_LONGITUDE, DEFAULT_LATITUDE);
258         m_zoomLevel = qBound(MIN_VIEW_ZOOM_LEVEL, DEFAULT_START_ZOOM_LEVEL, MAX_MAP_ZOOM_LEVEL);
259     } else {
260         m_zoomLevel = settings.value(MAP_LAST_ZOOMLEVEL, ERROR_VALUE_NOT_FOUND_ON_SETTINGS).toInt();
261         startLocation = settings.value(MAP_LAST_POSITION,
262                                        ERROR_VALUE_NOT_FOUND_ON_SETTINGS).toPointF();
263     }
264
265     emit zoomLevelChanged(m_zoomLevel);
266     setViewLocation(QPointF(startLocation.x(), startLocation.y()));
267 }
268
269 bool MapEngine::isAutoCenteringEnabled()
270 {
271     return m_autoCenteringEnabled;
272 }
273
274 bool MapEngine::isCenterTileChanged(QPoint sceneCoordinate)
275 {
276     qDebug() << __PRETTY_FUNCTION__;
277
278     QPoint centerTile = convertSceneCoordinateToTileNumber(m_zoomLevel, sceneCoordinate);
279     QPoint temp = m_centerTile;
280     m_centerTile = centerTile;
281
282     return (centerTile != temp);
283 }
284
285 void MapEngine::mapImageReceived(int zoomLevel, int x, int y, const QPixmap &image)
286 {
287 //    if (y != 3)
288 //        return;
289
290     qDebug() << __PRETTY_FUNCTION__; // << "x:" << x << "y:" << y;
291
292     // add normal tile
293     QPoint tileNumber(x, y);
294     m_mapScene->addTile(zoomLevel, tileNumber, image, m_zoomLevel);
295
296     int tilesGridWidthHalf = (m_viewTilesGrid.width() + 1) / 2;
297
298     // expand to east side? (don't need to expand over padding)
299     if (tileNumber.x() < (tilesGridWidthHalf - GRID_PADDING)) {
300         QPoint adjustedTileNumber(tileNumber.x() + tileMaxValue(zoomLevel) + 1, tileNumber.y());
301         m_mapScene->addTile(zoomLevel, adjustedTileNumber, image, m_zoomLevel);
302 //        qWarning() << __PRETTY_FUNCTION__ << "duplicate tile to east, x:" << x << "->" << adjustedTileNumber.x() << "y:" << adjustedTileNumber.y();
303     }
304
305     // expand to west side? (don't need to expand over padding)
306     if (tileNumber.x() > (tileMaxValue(zoomLevel) - tilesGridWidthHalf + GRID_PADDING)) {
307         QPoint adjustedTileNumber(tileNumber.x() - tileMaxValue(zoomLevel) - 1, tileNumber.y());
308         m_mapScene->addTile(zoomLevel, adjustedTileNumber, image, m_zoomLevel);
309 //        qWarning() << __PRETTY_FUNCTION__ << "duplicate tile to west, x:" << x << "->" << adjustedTileNumber.x() << "y:" << adjustedTileNumber.y();
310     }
311
312 //    // expanding is only done if received tile zoom level is same as current zoom level
313 //    if (zoomLevel == m_zoomLevel) {
314 //        // expand to east side?
315 //        if (m_viewTilesGrid.right() > tileMaxValue(zoomLevel)) {
316 //            int crossing = m_viewTilesGrid.right() - tileMaxValue(zoomLevel);
317 //            if (tileNumber.x() < crossing) {
318 //                QPoint adjustedTileNumber(tileNumber.x() + tileMaxValue(zoomLevel) + 1, tileNumber.y());
319 //                m_mapScene->addTile(zoomLevel, adjustedTileNumber, image, m_zoomLevel);
320 //                qWarning() << __PRETTY_FUNCTION__ << "duplicate tile to east, x:" << x << "->" << adjustedTileNumber.x() << "y:" << adjustedTileNumber.y();
321 //            }
322 //        }
323
324 //        // expand to west side?
325 //        if (m_viewTilesGrid.left() < 0) {
326 //            int crossing = -m_viewTilesGrid.left();
327 //            if (tileNumber.x() > (tileMaxValue(zoomLevel) - crossing)) {
328 //                QPoint adjustedTileNumber(tileNumber.x() - tileMaxValue(zoomLevel) - 1, tileNumber.y());
329 //                m_mapScene->addTile(zoomLevel, adjustedTileNumber, image, m_zoomLevel);
330 //                qWarning() << __PRETTY_FUNCTION__ << "duplicate tile to west, x:" << x << "->" << adjustedTileNumber.x() << "y:" << adjustedTileNumber.y();
331 //            }
332 //        }
333 //    }
334
335
336 //    int crossing =  m_tilesGridSize.width() - tileMaxValue(zoomLevel) - 1;
337 ////    qWarning() << __PRETTY_FUNCTION__ << "crossing:" << crossing;
338 //    if (crossing > 0) {
339 //        qWarning() << __PRETTY_FUNCTION__ << "grid was bigger than amount of tiles at this tile level";
340
341 //        if (x < crossing) {
342 //            // expand to east side
343 //            QPoint adjustedTileNumber(tileNumber.x() + tileMaxValue(zoomLevel) + 1, tileNumber.y());
344 //            m_mapScene->addTile(zoomLevel, adjustedTileNumber, image, m_zoomLevel);
345 //            qWarning() << __PRETTY_FUNCTION__ << "duplicate tile to east, x:" << x << "->" << adjustedTileNumber.x();
346 //        }
347
348 //        if (x > (tileMaxValue(zoomLevel) - crossing)) {
349 //            // expand to west side
350 //            QPoint adjustedTileNumber(tileNumber.x() - tileMaxValue(zoomLevel) - 1, tileNumber.y());
351 //            m_mapScene->addTile(zoomLevel, adjustedTileNumber, image, m_zoomLevel);
352 //            qWarning() << __PRETTY_FUNCTION__ << "duplicate tile to west, x:" << x << "->" << adjustedTileNumber.x();
353 //        }
354 //    }
355
356 //    m_mapScene->spanItems(m_scrollDirection, m_zoomLevel);
357 }
358
359 int MapEngine::normalize(int value, int min, int max)
360 {
361     qDebug() << __PRETTY_FUNCTION__; // << "value:" << value << "min:" << min << "max:" << max;
362     Q_ASSERT_X(max >= min, "parameters", "max can't be smaller than min");
363
364     while (value < min)
365         value += max - min + 1;
366
367     while (value > max)
368         value -= max - min + 1;
369
370     return value;
371 }
372
373 void MapEngine::receiveOwnLocation(User *user)
374 {
375     qDebug() << __PRETTY_FUNCTION__;
376
377     if(user) {
378         QPoint newPosition = convertLatLonToSceneCoordinate(user->coordinates());
379         if (m_ownLocation->pos().toPoint() != newPosition) {
380             m_ownLocation->setPos(newPosition);
381         }
382
383         if (!m_ownLocation->isVisible())
384             m_ownLocation->show();
385     }
386     else {
387         m_ownLocation->hide();
388     }
389 }
390
391 QGraphicsScene* MapEngine::scene()
392 {
393     qDebug() << __PRETTY_FUNCTION__;
394
395     return m_mapScene;
396 }
397
398 void MapEngine::setAutoCentering(bool enabled)
399 {
400     m_autoCenteringEnabled = enabled;
401 }
402
403 void MapEngine::setGPSEnabled(bool enabled)
404 {
405     m_gpsLocationItem->setEnabled(enabled);
406 }
407
408 void MapEngine::setLocation(QPoint sceneCoordinate)
409 {
410     qDebug() << __PRETTY_FUNCTION__;
411
412     // jump to opposite side of the world if world limit is exceeded
413     if (sceneCoordinate.x() < 0)
414         sceneCoordinate.setX(sceneCoordinate.x() + WORLD_PIXELS_X);
415     else if (sceneCoordinate.x() > WORLD_PIXELS_X - 1)
416         sceneCoordinate.setX(sceneCoordinate.x() - WORLD_PIXELS_X);
417
418     if (sceneCoordinate.x() > m_sceneCoordinate.x())
419         m_scrollDirection = SCROLL_EAST;
420     else
421         m_scrollDirection = SCROLL_WEST;
422
423     if (disableAutoCentering(sceneCoordinate))
424         emit mapScrolledManually();
425
426     m_sceneCoordinate = sceneCoordinate;
427     emit locationChanged(m_sceneCoordinate);
428
429     if (isCenterTileChanged(sceneCoordinate)) {
430         getTiles(sceneCoordinate);
431         m_mapScene->removeOutOfViewTiles(m_viewTilesGrid, m_zoomLevel);
432     }
433
434     m_mapScene->spanItems(m_scrollDirection, m_zoomLevel, m_sceneCoordinate, m_viewSize);
435 }
436
437 void MapEngine::setZoomLevel(int newZoomLevel)
438 {
439     qDebug() << __PRETTY_FUNCTION__;
440
441     m_zoomLevel = newZoomLevel;
442     zoomed();
443 }
444
445 void MapEngine::setTilesGridSize(const QSize &viewSize)
446 {
447     qDebug() << __PRETTY_FUNCTION__;
448
449     // there must be scrolling reserve of at least half tile added to tile amount
450     // calculated from view size
451     const qreal SCROLLING_RESERVE = 0.5;
452
453     // converting scene tile to tile number does cause grid centering inaccuracy of one tile
454     const int CENTER_TILE_INACCURACY = 1;
455
456     int gridWidth = ceil(qreal(viewSize.width()) / TILE_SIZE_X + SCROLLING_RESERVE)
457                     + CENTER_TILE_INACCURACY + (GRID_PADDING * 2);
458     int gridHeight = ceil(qreal(viewSize.height()) / TILE_SIZE_Y + SCROLLING_RESERVE)
459                      + CENTER_TILE_INACCURACY + (GRID_PADDING * 2);
460
461     m_mapFetcher->setDownloadQueueSize(gridWidth * gridHeight);
462
463     m_tilesGridSize.setHeight(gridHeight);
464     m_tilesGridSize.setWidth(gridWidth);
465
466 //    qWarning() << __PRETTY_FUNCTION__ << "tiles grid:" << m_tilesGridSize.width()
467 //                                      << "*" << m_tilesGridSize.height();
468 }
469
470 void MapEngine::setViewLocation(QPointF latLonCoordinate)
471 {
472     qDebug() << __PRETTY_FUNCTION__;
473
474     QPoint sceneCoordinate = convertLatLonToSceneCoordinate(latLonCoordinate);
475
476     m_lastManualPosition = sceneCoordinate;
477
478     setLocation(sceneCoordinate);
479 }
480
481 int MapEngine::tileMaxValue(int zoomLevel)
482 {
483     qDebug() << __PRETTY_FUNCTION__;
484
485     return (1 << zoomLevel) - 1;
486 }
487
488 QString MapEngine::tilePath(int zoomLevel, int x, int y)
489 {
490     qDebug() << __PRETTY_FUNCTION__;
491
492     QString tilePathString(QString::number(zoomLevel) + "/");
493     tilePathString.append(QString::number(x) + "/");
494     tilePathString.append(QString::number(y));
495
496     return tilePathString;
497 }
498
499 void MapEngine::updateViewTilesSceneRect()
500 {
501     qDebug() << __PRETTY_FUNCTION__;
502
503     const QPoint ONE_TILE = QPoint(1, 1);
504     const QPoint ONE_PIXEL = QPoint(1, 1);
505
506     QPoint topLeft = convertTileNumberToSceneCoordinate(m_zoomLevel, m_viewTilesGrid.topLeft());
507     // one tile - one pixel is added because returned coordinates are pointing to upper left corner
508     // of the last tile.
509     QPoint bottomRight = convertTileNumberToSceneCoordinate(m_zoomLevel,
510                                                             m_viewTilesGrid.bottomRight()
511                                                              + ONE_TILE) - ONE_PIXEL;
512
513     m_mapScene->tilesSceneRectUpdated(QRect(topLeft, bottomRight));
514 }
515
516 void MapEngine::viewResized(const QSize &size)
517 {
518     qDebug() << __PRETTY_FUNCTION__;
519
520     m_viewSize = size;
521     setTilesGridSize(m_viewSize);
522
523     emit locationChanged(m_sceneCoordinate);
524     getTiles(m_sceneCoordinate);
525     m_mapScene->removeOutOfViewTiles(m_viewTilesGrid, m_zoomLevel);
526     m_mapScene->setSceneVerticalOverlap(m_viewSize.height(), m_zoomLevel);
527 }
528
529 void MapEngine::viewZoomFinished()
530 {
531     qDebug() << __PRETTY_FUNCTION__;
532
533     if (m_zoomedIn) {
534         m_zoomedIn = false;
535         m_mapScene->removeOutOfViewTiles(m_viewTilesGrid, m_zoomLevel);
536     }
537
538     if (m_zoomLevel == MAX_MAP_ZOOM_LEVEL)
539         emit maxZoomLevelReached();
540     else if (m_zoomLevel == MIN_VIEW_ZOOM_LEVEL)
541         emit minZoomLevelReached();
542 }
543
544 void MapEngine::zoomed()
545 {
546     emit zoomLevelChanged(m_zoomLevel);
547     m_mapScene->setTilesDrawingLevels(m_zoomLevel);
548     getTiles(m_sceneCoordinate);
549     m_mapScene->setSceneVerticalOverlap(m_viewSize.height(), m_zoomLevel);
550 }
551
552 void MapEngine::zoomIn()
553 {
554     qDebug() << __PRETTY_FUNCTION__;
555
556     if (m_zoomLevel < MAX_MAP_ZOOM_LEVEL) {
557         m_zoomLevel++;
558         m_zoomedIn = true;
559         zoomed();
560     }
561 }
562
563 void MapEngine::zoomOut()
564 {
565     qDebug() << __PRETTY_FUNCTION__;
566
567     if (m_zoomLevel > MIN_VIEW_ZOOM_LEVEL) {
568         m_zoomLevel--;
569         zoomed();
570     }
571 }