2 Situare - A location system for Facebook
3 Copyright (C) 2010 Ixonos Plc. Authors:
5 Sami Rämö - sami.ramo@ixonos.com
6 Jussi Laitinen - jussi.laitinen@ixonos.com
8 Situare is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 version 2 as published by the Free Software Foundation.
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.
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,
30 #include "mapfetcher.h"
37 * Logic for controlling map functionality. Does also include static methods for
38 * converting coordinates.
39 * @author Sami Rämö - sami.ramo (at) ixonos.com
41 class MapEngine : public QObject
48 * Does create and add scene to map view.
49 * @param mapView View for map
50 * @param parent Parent
52 MapEngine(MapView *mapView, QWidget *parent = 0);
55 * @brief Convert tile x & y numbers to MapScene coordinates
57 * @param zoomLevel Zoom level
58 * @param tileNumber x & y numbers of the tile
59 * @return QPoint MapScene coordinate
62 * @todo use bit shift instead of pow
64 static QPoint convertTileNumberToSceneCoordinate(int zoomLevel, QPoint tileNumber)
66 int x = tileNumber.x() * TILE_SIZE_X * pow(2, MAX_ZOOM_LEVEL - zoomLevel);
67 int y = tileNumber.y() * TILE_SIZE_Y * pow(2, MAX_ZOOM_LEVEL - zoomLevel);
73 * @brief Set view location
75 * @param latLonCoordinate Latitude & longitude coordinates for location
77 void setViewLocation(QPointF latLonCoordinate);
79 QPoint latLonToTile(qreal latitude, qreal longitude, int zoom);
82 * @brief Transforms tile x value to longitude.
84 * @param x tile x value
85 * @param zoom zoom value
86 * @return qreal longitude
88 qreal tileXToLongitude(int x, int zoom);
91 * @brief Transforms tile y value to latitude.
93 * @param y tile y value
94 * @param zoom zoom value
95 * @return qreal latitude
97 qreal tileYToLatitude(int y, int zoom);
101 * @brief Slot for received map tile images
103 * Does add MapTile objects to MapScene. Zoom level and location is parsed from URL.
104 * @param url URL of the received image
105 * @param pixmap Received pixmap
107 void mapImageReceived(const QUrl &url, const QPixmap &pixmap);
110 static const int TILE_SIZE_X = 256; ///< Tile image size in x direction
111 static const int TILE_SIZE_Y = 256; ///< Tile image size in y direction
112 static const int MIN_ZOOM_LEVEL = 0; ///< Minimum zoom level
113 static const int MAX_ZOOM_LEVEL = 18; ///< Maximum zoom level
116 MapView *m_mapView; ///< View for viewing map
117 MapScene *m_mapScene; ///< Scene for map tiles
118 MapFetcher *m_mapFetcher; ///< Fetcher for map tiles
119 int m_zoomLevel; ///< Current zoom level
122 #endif // MAPENGINE_H