echo "##########################################" >> $REPORT
echo "" >> $REPORT
- # find all test .pro files pahts, cut .pro extension
- UNIT_TEST_PROJECTS=(`find $UNIT_TESTS_ROOT_DIR_ABSOLUTE | egrep \.pro$ | sed -e s,[^/]pro,,g`)
+ # find all test .pro files paths, cut .pro extension
+ UNIT_TEST_PROJECTS=(`find $UNIT_TESTS_ROOT_DIR_ABSOLUTE | egrep \.pro$ | sed -e s,.pro$,,g`)
echo "###################################################"
echo "All unit test executables will be deleted"
USA.
*/
+#include <cmath>
+
#include <QDebug>
-/// @todo remove mapcommon.h include after refactored the convertFrom()
-#include "map/mapcommon.h"
+#include "map/osm.h"
#include "scenecoordinate.h"
#include "geocoordinate.h"
{
qDebug() << __PRETTY_FUNCTION__;
- const int zoomLevel = 18; // replacing the parameter temporarily
-
- double tileFactor = 1 << (MAX_MAP_ZOOM_LEVEL - zoomLevel);
- double xFactor = (coordinate.x() / (TILE_SIZE_X*tileFactor));
- double yFactor = (coordinate.y() / (TILE_SIZE_Y*tileFactor));
+ const int MAP_PIXELS_Y = OSM_MAP_MAX_PIXEL_Y + 1;
- tileFactor = 1 << zoomLevel;
- double longitude = xFactor / tileFactor * 360.0 - 180;
+ double longitude = coordinate.x() / OMS_MAP_PIXELS_X * 360.0 - 180;
- double n = M_PI - 2.0 * M_PI * yFactor / tileFactor;
+ double n = M_PI - 2.0 * M_PI * coordinate.y() / MAP_PIXELS_Y;
double latitude = 180.0 / M_PI * atan(0.5 * (exp(n) - exp(-n)));
-// return QPointF(longitude, latitude);
setLatitude(latitude);
setLongitude(longitude);
}
-//double tilex2long(int x, int z)
-//{
-// return x / pow(2.0, z) * 360.0 - 180;
-//}
-
-//double tiley2lat(int y, int z)
-//{
-// double n = M_PI - 2.0 * M_PI * y / pow(2.0, z);
-// return 180.0 / M_PI * atan(0.5 * (exp(n) - exp(-n)));
-//}
-
bool GeoCoordinate::isNull() const
{
qDebug() << __PRETTY_FUNCTION__;
USA.
*/
+#include <cmath>
+
#include <QDebug>
#include "geocoordinate.h"
-#include "map/mapcommon.h"
+#include "map/osm.h"
#include "scenecoordinate.h"
double worldY = static_cast<double>((1.0 - log(tan(coordinate.latitude() * M_PI / 180.0) + 1.0
/ cos(coordinate.latitude() * M_PI / 180.0)) / M_PI) / 2.0);
- m_x = worldX * MAX_TILES_PER_SIDE * TILE_SIZE_X;
- m_y = worldY * MAX_TILES_PER_SIDE * TILE_SIZE_Y;
+ m_x = worldX * OSM_TILES_PER_SIDE * OSM_TILE_SIZE_X;
+ m_y = worldY * OSM_TILES_PER_SIDE * OSM_TILE_SIZE_Y;
- normalize(m_x, MAP_MIN_PIXEL_X, MAP_MAX_PIXEL_X);
+ normalize(m_x, OSM_MAP_MIN_PIXEL_X, OSM_MAP_MAX_PIXEL_X);
}
bool SceneCoordinate::isNull() const
// picture side length used for collision detection
const int IMAGE_SIDE = 58;
- int multiplier = 1 << (MAX_MAP_ZOOM_LEVEL - zoomLevel);
+ int multiplier = 1 << (OSM_MAX_ZOOM_LEVEL - zoomLevel);
int side = multiplier * IMAGE_SIDE;
QPoint center = pos().toPoint();
QRect rect = QRect(topLeft, QSize(side, side));
// normalize rect's center point to be inside the map
- if (center.x() < MAP_MIN_PIXEL_X)
- rect.translate(MAP_PIXELS_X, 0);
- else if (center.x() > MAP_MAX_PIXEL_X)
- rect.translate(-MAP_PIXELS_X, 0);
+ if (center.x() < OSM_MAP_MIN_PIXEL_X)
+ rect.translate(OMS_MAP_PIXELS_X, 0);
+ else if (center.x() > OSM_MAP_MAX_PIXEL_X)
+ rect.translate(-OMS_MAP_PIXELS_X, 0);
return rect;
}
if (item1Rect.intersects(item2Rect))
return true;
- if (item1Rect.left() < (MAP_MIN_PIXEL_X + item1Rect.width() / 2)) {
- QRect translated = item1Rect.translated(MAP_PIXELS_X, 0);
+ if (item1Rect.left() < (OSM_MAP_MIN_PIXEL_X + item1Rect.width() / 2)) {
+ QRect translated = item1Rect.translated(OMS_MAP_PIXELS_X, 0);
if (translated.intersects(item2Rect))
return true;
- } else if (item1Rect.right() > (MAP_MAX_PIXEL_X - item1Rect.width() / 2)) {
- QRect translated = item1Rect.translated(-MAP_PIXELS_X, 0);
+ } else if (item1Rect.right() > (OSM_MAP_MAX_PIXEL_X - item1Rect.width() / 2)) {
+ QRect translated = item1Rect.translated(-OMS_MAP_PIXELS_X, 0);
if (translated.intersects(item2Rect))
return true;
}
#include <QtCore>
-const int TILE_SIZE_X = 256; ///< Tile image size in x direction
-const int TILE_SIZE_Y = 256; ///< Tile image size in y direction
+#include "osm.h"
+
const int MAP_TILE_MIN_INDEX = 0; ///< First index number of map tiles
-const int MIN_MAP_ZOOM_LEVEL = 0; ///< Minimum zoom level
-const int MAX_MAP_ZOOM_LEVEL = 18; ///< Maximum zoom level
-const int MIN_VIEW_ZOOM_LEVEL = 2; ///< Minimum zoom level for MapView
+const int MAP_VIEW_MIN_ZOOM_LEVEL = 2; ///< Minimum zoom level for MapView
/**
-* @var MIN_MAP_SCENE_NORMAL_LEVEL
+* @var MAP_SCENE_MIN_NORMAL_LEVEL
* @brief Used for shifting zValues of MapTiles
*/
-const int MIN_MAP_SCENE_NORMAL_LEVEL = MAX_MAP_ZOOM_LEVEL + 1;
-
-const int MAX_TILES_PER_SIDE = (1 << MAX_MAP_ZOOM_LEVEL); ///< Amount of tiles per side
-const int MAP_PIXELS_X = MAX_TILES_PER_SIDE * TILE_SIZE_X; ///< Amount of horizontal pixels in map
-
-const int MAP_MIN_PIXEL_X = 0; ///< First map horizontal pixel index
-const int MAP_MAX_PIXEL_X = MAP_PIXELS_X - 1; ///< Last map horizontal pixel index
-
-const int MAP_MIN_PIXEL_Y = 0; ///< First map vertical pixel index
-const int MAP_MAX_PIXEL_Y = MAX_TILES_PER_SIDE * TILE_SIZE_Y - 1; ///< Last map vertical pixel index
+const int MAP_SCENE_MIN_NORMAL_LEVEL = OSM_MAX_ZOOM_LEVEL + 1;
const double MAP_SCENE_VERTICAL_OVERSIZE_FACTOR = 0.5; ///< MapScene vertical oversize ( * map size)
* @var MAP_SCENE_MIN_PIXEL_X
* @brief First scene horizontal pixel
*/
-const int MAP_SCENE_MIN_PIXEL_X = -MAP_PIXELS_X * MAP_SCENE_VERTICAL_OVERSIZE_FACTOR;
+const int MAP_SCENE_MIN_PIXEL_X = -OMS_MAP_PIXELS_X * MAP_SCENE_VERTICAL_OVERSIZE_FACTOR;
/**
* @var MAP_SCENE_MAX_PIXEL_X
* @brief Last scene horizontal pixel
*/
-const int MAP_SCENE_MAX_PIXEL_X = MAP_PIXELS_X * (1 + MAP_SCENE_VERTICAL_OVERSIZE_FACTOR) - 1;
+const int MAP_SCENE_MAX_PIXEL_X = OMS_MAP_PIXELS_X * (1 + MAP_SCENE_VERTICAL_OVERSIZE_FACTOR) - 1;
+////////////////////////////////////////////////////////////////////////////////
+// DEFAULT VALUES
+////////////////////////////////////////////////////////////////////////////////
/**
-* @var DEFAULT_START_ZOOM_LEVEL
+* @var MAP_DEFAULT_ZOOM_LEVEL
* @brief Maps Default zoom level, used when latest zoom level is not available.
*/
-const int DEFAULT_START_ZOOM_LEVEL = MIN_VIEW_ZOOM_LEVEL;
+const int MAP_DEFAULT_ZOOM_LEVEL = MAP_VIEW_MIN_ZOOM_LEVEL;
+
+const qreal MAP_DEFAULT_LONGITUDE = 0.0000; ///< Default longitude value
+const qreal MAP_DEFAULT_LATITUDE = 0.0000; ///< Default latitude value
/**
* @var FRIEND_LOCATION_ICON_Z_LEVEL
* @brief layer of friend location icon
*/
-const int FRIEND_LOCATION_ICON_Z_LEVEL = MIN_MAP_SCENE_NORMAL_LEVEL + MAX_MAP_ZOOM_LEVEL + 1;
+const int FRIEND_LOCATION_ICON_Z_LEVEL = MAP_SCENE_MIN_NORMAL_LEVEL + OSM_MAX_ZOOM_LEVEL + 1;
const int GROUP_ITEM_FRIENDS_COUNT_X = 13; ///< Group item friends count x value
const int GROUP_ITEM_FRIENDS_COUNT_Y = 13; ///< Group item friends count y value
*/
const int OWN_LOCATION_ICON_Z_LEVEL = FRIEND_LOCATION_ICON_Z_LEVEL + 1;
-const double MAX_LATITUDE = 85.05112877980659237802; ///< Maximum latitude value
-const double MIN_LATITUDE = -MAX_LATITUDE; ///< Minimum latitude value
const double MIN_LONGITUDE = -180.0; ///< Minimum longitude value
const double MAX_LONGITUDE = 180.0; ///< Maximum longitude value
-const int DEFAULT_ZOOM_LEVEL = 14; ///< Default zoom level
-const qreal DEFAULT_LONGITUDE = 0.0000; ///< Default longitude value
-const qreal DEFAULT_LATITUDE = 0.0000; ///< Default latitude value
-
const qreal EARTH_RADIUS = 6371.01; ///< Earth radius in km
-const int GRID_PADDING = 0; ///< Grid padding used in tile grid calculation
+const int MAP_GRID_PADDING = 0; ///< Grid padding used in tile grid calculation
const QString OSM_LICENSE = QString::fromUtf8("© OpenStreetMap contributors, CC-BY-SA");
m_scrollStartedByGps(false),
m_smoothScrollRunning(false),
m_zoomedIn(false),
- m_zoomLevel(DEFAULT_ZOOM_LEVEL),
+ m_zoomLevel(MAP_DEFAULT_ZOOM_LEVEL),
m_centerTile(QPoint(UNDEFINED, UNDEFINED)),
m_lastAutomaticPosition(QPoint(0, 0)),
m_tilesGridSize(QSize(0, 0)),
if ((longitude > MAX_LONGITUDE) || (longitude < MIN_LONGITUDE))
return QPoint(UNDEFINED, UNDEFINED);
- if ((latitude > MAX_LATITUDE) || (latitude < MIN_LATITUDE))
+ if ((latitude > OSM_MAX_LATITUDE) || (latitude < OSM_MIN_LATITUDE))
return QPoint(UNDEFINED, UNDEFINED);
- qreal z = static_cast<qreal>(MapEngine::tilesPerSide(MAX_MAP_ZOOM_LEVEL));
+ qreal z = static_cast<qreal>(MapEngine::tilesPerSide(OSM_MAX_ZOOM_LEVEL));
qreal x = static_cast<qreal>((longitude + 180.0) / 360.0);
qreal y = static_cast<qreal>((1.0 - log(tan(latitude * M_PI / 180.0) + 1.0
/ cos(latitude * M_PI / 180.0)) / M_PI) / 2.0);
- return QPointF(x * z * TILE_SIZE_X, y * z * TILE_SIZE_Y).toPoint();
+ return QPointF(x * z * OSM_TILE_SIZE_X, y * z * OSM_TILE_SIZE_Y).toPoint();
}
QPointF MapEngine::convertSceneCoordinateToLatLon(int zoomLevel, QPoint sceneCoordinate)
{
qDebug() << __PRETTY_FUNCTION__;
- double tileFactor = 1 << (MAX_MAP_ZOOM_LEVEL - zoomLevel);
- double xFactor = (sceneCoordinate.x() / (TILE_SIZE_X*tileFactor));
- double yFactor = (sceneCoordinate.y() / (TILE_SIZE_Y*tileFactor));
+ double tileFactor = 1 << (OSM_MAX_ZOOM_LEVEL - zoomLevel);
+ double xFactor = (sceneCoordinate.x() / (OSM_TILE_SIZE_X*tileFactor));
+ double yFactor = (sceneCoordinate.y() / (OSM_TILE_SIZE_Y*tileFactor));
tileFactor = 1 << zoomLevel;
double longitude = xFactor / tileFactor * 360.0 - 180;
{
qDebug() << __PRETTY_FUNCTION__;
- int pow = 1 << (MAX_MAP_ZOOM_LEVEL - zoomLevel);
- int x = static_cast<int>(sceneCoordinate.x() / (TILE_SIZE_X * pow));
- int y = static_cast<int>(sceneCoordinate.y() / (TILE_SIZE_Y * pow));
+ int pow = 1 << (OSM_MAX_ZOOM_LEVEL - zoomLevel);
+ int x = static_cast<int>(sceneCoordinate.x() / (OSM_TILE_SIZE_X * pow));
+ int y = static_cast<int>(sceneCoordinate.y() / (OSM_TILE_SIZE_Y * pow));
return QPoint(x, y);
}
{
qDebug() << __PRETTY_FUNCTION__;
- int pow = 1 << (MAX_MAP_ZOOM_LEVEL - zoomLevel);
- int x = tileNumber.x() * TILE_SIZE_X * pow;
- int y = tileNumber.y() * TILE_SIZE_Y * pow;
+ int pow = 1 << (OSM_MAX_ZOOM_LEVEL - zoomLevel);
+ int x = tileNumber.x() * OSM_TILE_SIZE_X * pow;
+ int y = tileNumber.y() * OSM_TILE_SIZE_Y * pow;
return QPoint(x, y);
}
void MapEngine::disableAutoCenteringIfRequired(QPoint sceneCoordinate)
{
if (isAutoCenteringEnabled()) {
- int zoomFactor = (1 << (MAX_MAP_ZOOM_LEVEL - m_zoomLevel));
+ int zoomFactor = (1 << (OSM_MAX_ZOOM_LEVEL - m_zoomLevel));
QPoint oldPixelValue = QPoint(m_lastAutomaticPosition.x() / zoomFactor,
m_lastAutomaticPosition.y() / zoomFactor);
== ERROR_VALUE_NOT_FOUND_ON_SETTINGS || settings.value(MAP_LAST_ZOOMLEVEL,
ERROR_VALUE_NOT_FOUND_ON_SETTINGS).toString() == ERROR_VALUE_NOT_FOUND_ON_SETTINGS) {
- startLocation = QPointF(DEFAULT_LONGITUDE, DEFAULT_LATITUDE);
- m_zoomLevel = qBound(MIN_VIEW_ZOOM_LEVEL, DEFAULT_START_ZOOM_LEVEL, MAX_MAP_ZOOM_LEVEL);
+ startLocation = QPointF(MAP_DEFAULT_LONGITUDE, MAP_DEFAULT_LATITUDE);
+ m_zoomLevel = qBound(MAP_VIEW_MIN_ZOOM_LEVEL, MAP_DEFAULT_ZOOM_LEVEL, OSM_MAX_ZOOM_LEVEL);
} else {
m_zoomLevel = settings.value(MAP_LAST_ZOOMLEVEL, ERROR_VALUE_NOT_FOUND_ON_SETTINGS).toInt();
startLocation = settings.value(MAP_LAST_POSITION,
const int SHIFT = 200;
const int KM_TO_M = 1000;
- qreal scale = (1 << (MAX_MAP_ZOOM_LEVEL - m_zoomLevel));
+ qreal scale = (1 << (OSM_MAX_ZOOM_LEVEL - m_zoomLevel));
QPointF centerCoordinate = centerGeoCoordinate();
QPoint shiftedSceneCoordinate = QPoint(m_sceneCoordinate.x() + SHIFT*scale
, m_sceneCoordinate.y());
int tilesGridWidthHalf = (m_viewTilesGrid.width() + 1) / 2;
// duplicate to east side? (don't need to duplicate over padding)
- if (tileNumber.x() < (tilesGridWidthHalf - GRID_PADDING)) {
+ if (tileNumber.x() < (tilesGridWidthHalf - MAP_GRID_PADDING)) {
QPoint adjustedTileNumber(tileNumber.x() + tileMaxIndex(zoomLevel) + 1, tileNumber.y());
m_mapScene->addTile(zoomLevel, adjustedTileNumber, image, m_zoomLevel);
}
// duplicate to west side? (don't need to duplicate over padding)
- if (tileNumber.x() > (tileMaxIndex(zoomLevel) - tilesGridWidthHalf + GRID_PADDING)) {
+ if (tileNumber.x() > (tileMaxIndex(zoomLevel) - tilesGridWidthHalf + MAP_GRID_PADDING)) {
QPoint adjustedTileNumber(tileNumber.x() - tileMaxIndex(zoomLevel) - 1, tileNumber.y());
m_mapScene->addTile(zoomLevel, adjustedTileNumber, image, m_zoomLevel);
}
qDebug() << __PRETTY_FUNCTION__;
// jump to opposite side of the world if world horizontal limit is exceeded
- scenePosition.setX(normalize(scenePosition.x(), MAP_MIN_PIXEL_X, MAP_MAX_PIXEL_X));
+ scenePosition.setX(normalize(scenePosition.x(), OSM_MAP_MIN_PIXEL_X, OSM_MAP_MAX_PIXEL_X));
// don't allow vertical scene coordinates go out of the map
- scenePosition.setY(qBound(MAP_MIN_PIXEL_Y, scenePosition.y(), MAP_MAX_PIXEL_Y));
+ scenePosition.setY(qBound(OSM_MAP_MIN_PIXEL_Y, scenePosition.y(), OSM_MAP_MAX_PIXEL_Y));
if (!m_smoothScrollRunning)
disableAutoCenteringIfRequired(scenePosition);
// converting scene tile to tile number does cause grid centering inaccuracy of one tile
const int CENTER_TILE_INACCURACY = 1;
- int gridWidth = ceil(qreal(viewSize.width()) / TILE_SIZE_X + SCROLLING_RESERVE)
- + CENTER_TILE_INACCURACY + (GRID_PADDING * 2);
- int gridHeight = ceil(qreal(viewSize.height()) / TILE_SIZE_Y + SCROLLING_RESERVE)
- + CENTER_TILE_INACCURACY + (GRID_PADDING * 2);
+ int gridWidth = ceil(qreal(viewSize.width()) / OSM_TILE_SIZE_X + SCROLLING_RESERVE)
+ + CENTER_TILE_INACCURACY + (MAP_GRID_PADDING * 2);
+ int gridHeight = ceil(qreal(viewSize.height()) / OSM_TILE_SIZE_Y + SCROLLING_RESERVE)
+ + CENTER_TILE_INACCURACY + (MAP_GRID_PADDING * 2);
m_mapFetcher->setDownloadQueueSize(gridWidth * gridHeight);
m_mapScene->removeOutOfViewTiles(m_viewTilesGrid, m_zoomLevel);
}
- if (m_zoomLevel == MAX_MAP_ZOOM_LEVEL)
+ if (m_zoomLevel == OSM_MAX_ZOOM_LEVEL)
emit maxZoomLevelReached();
- else if (m_zoomLevel == MIN_VIEW_ZOOM_LEVEL)
+ else if (m_zoomLevel == MAP_VIEW_MIN_ZOOM_LEVEL)
emit minZoomLevelReached();
}
{
qDebug() << __PRETTY_FUNCTION__;
- if (m_zoomLevel < MAX_MAP_ZOOM_LEVEL) {
+ if (m_zoomLevel < OSM_MAX_ZOOM_LEVEL) {
m_zoomLevel++;
m_zoomedIn = true;
zoomed();
{
qDebug() << __PRETTY_FUNCTION__;
- if (m_zoomLevel > MIN_VIEW_ZOOM_LEVEL) {
+ if (m_zoomLevel > MAP_VIEW_MIN_ZOOM_LEVEL) {
m_zoomLevel--;
zoomed();
}
{
qDebug() << __PRETTY_FUNCTION__;
- if (zoomLevel > MIN_MAP_ZOOM_LEVEL) {
+ if (zoomLevel > OSM_MIN_ZOOM_LEVEL) {
zoomLevel--;
x /= 2;
y /= 2;
qDebug() << __PRETTY_FUNCTION__;
setBackgroundBrush(Qt::lightGray);
- setSceneRect(QRect(QPoint(MAP_SCENE_MIN_PIXEL_X, MAP_MIN_PIXEL_Y),
- QPoint(MAP_SCENE_MAX_PIXEL_X, MAP_MAX_PIXEL_Y)));
+ setSceneRect(QRect(QPoint(MAP_SCENE_MIN_PIXEL_X, OSM_MAP_MIN_PIXEL_Y),
+ QPoint(MAP_SCENE_MAX_PIXEL_X, OSM_MAP_MAX_PIXEL_Y)));
}
void MapScene::addTile(int tileZoomLevel, QPoint tileNumber, const QPixmap &image, int viewZoomLevel)
// if view is near east limit of the map, then there is duplicate tiles also on the opposite
// side of the world which are removed from allTiles
- if (tilesGrid.right() > (MapEngine::tileMaxIndex(zoomLevel) - tilesGridWidthHalf + GRID_PADDING)) {
+ if (tilesGrid.right() > (MapEngine::tileMaxIndex(zoomLevel) - tilesGridWidthHalf + MAP_GRID_PADDING)) {
QRect oppositeRect = m_tilesSceneRect;
- oppositeRect.translate(-MAP_PIXELS_X, 0);
+ oppositeRect.translate(-OMS_MAP_PIXELS_X, 0);
QList<QGraphicsItem *> oppositeItems = items(oppositeRect, Qt::IntersectsItemBoundingRect);
foreach (QGraphicsItem *item, oppositeItems)
allItems.removeOne(item);
// if view is near west limit of the map, then there is duplicate tiles also on the opposite
// side of the world which are removed from allTiles
- if (tilesGrid.left() < (tilesGridWidthHalf - GRID_PADDING)) {
+ if (tilesGrid.left() < (tilesGridWidthHalf - MAP_GRID_PADDING)) {
QRect oppositeRect = m_tilesSceneRect;
- oppositeRect.translate(MAP_PIXELS_X, 0);
+ oppositeRect.translate(OMS_MAP_PIXELS_X, 0);
QList<QGraphicsItem *> oppositeItems = items(oppositeRect, Qt::IntersectsItemBoundingRect);
foreach (QGraphicsItem *item, oppositeItems)
allItems.removeOne(item);
{
qDebug() << __PRETTY_FUNCTION__;
- int overlap = viewHeight / 2 * (1 << (MAX_MAP_ZOOM_LEVEL - zoomLevel));
+ int overlap = viewHeight / 2 * (1 << (OSM_MAX_ZOOM_LEVEL - zoomLevel));
QRect rect = sceneRect().toRect();
- rect.setTop(MAP_MIN_PIXEL_Y - overlap);
- rect.setBottom(MAP_MAX_PIXEL_Y + overlap);
+ rect.setTop(OSM_MAP_MIN_PIXEL_Y - overlap);
+ rect.setBottom(OSM_MAP_MAX_PIXEL_Y + overlap);
setSceneRect(rect);
}
// create rects for left and right side
QRect leftRect = sceneRect().toRect(); // this way we get the horizontal limits of the scene
- leftRect.setTop(MAP_MIN_PIXEL_Y);
- leftRect.setBottom(MAP_MAX_PIXEL_Y);
+ leftRect.setTop(OSM_MAP_MIN_PIXEL_Y);
+ leftRect.setBottom(OSM_MAP_MAX_PIXEL_Y);
QRect rightRect = leftRect;
// calculate current horizontal area shown on the view
- int viewSceneWidth = (1 << (MAX_MAP_ZOOM_LEVEL - zoomLevel)) * viewSize.width();
+ int viewSceneWidth = (1 << (OSM_MAX_ZOOM_LEVEL - zoomLevel)) * viewSize.width();
int viewSceneLeft = sceneCoordinate.x() - viewSceneWidth / 2;
int viewSceneRight = sceneCoordinate.x() + viewSceneWidth / 2;
// limit rects to include only area which really must be moved
- leftRect.setRight(-1 - (MAP_PIXELS_X - 1 - viewSceneRight));
- rightRect.setLeft(MAP_PIXELS_X + viewSceneLeft);
+ leftRect.setRight(-1 - (OMS_MAP_PIXELS_X - 1 - viewSceneRight));
+ rightRect.setLeft(OMS_MAP_PIXELS_X + viewSceneLeft);
Q_ASSERT_X(leftRect.right() < viewSceneLeft, "spanning rect right value", "move rect is in the view area");
Q_ASSERT_X(rightRect.left() > viewSceneRight, "spanning rect left value", "move rect is in the view area");
// move all items which intersects the rects
if (leftRect.left() < leftRect.right())
- moveIntersectingItemsHorizontally(leftRect, MAP_PIXELS_X);
+ moveIntersectingItemsHorizontally(leftRect, OMS_MAP_PIXELS_X);
if (rightRect.left() < rightRect.right())
- moveIntersectingItemsHorizontally(rightRect, -MAP_PIXELS_X);
+ moveIntersectingItemsHorizontally(rightRect, -OMS_MAP_PIXELS_X);
}
void MapScene::tilesSceneRectUpdated(QRect tilesSceneRect)
setSceneLevel(currentViewZoomLevel);
- qreal zoomFactor = static_cast<qreal>(1 << (MAX_MAP_ZOOM_LEVEL - m_zoomLevel));
+ qreal zoomFactor = static_cast<qreal>(1 << (OSM_MAX_ZOOM_LEVEL - m_zoomLevel));
setScale(zoomFactor);
}
qDebug() << __PRETTY_FUNCTION__;
if (currentZoomLevel < m_zoomLevel) {
- qreal z = static_cast<qreal>(MIN_MAP_SCENE_NORMAL_LEVEL + currentZoomLevel
+ qreal z = static_cast<qreal>(MAP_SCENE_MIN_NORMAL_LEVEL + currentZoomLevel
- (m_zoomLevel - currentZoomLevel)) + 0.5;
setZValue(z);
}
else
- setZValue(static_cast<qreal>(MIN_MAP_SCENE_NORMAL_LEVEL + m_zoomLevel));
+ setZValue(static_cast<qreal>(MAP_SCENE_MIN_NORMAL_LEVEL + m_zoomLevel));
}
QPoint MapTile::tileNumber()
* (1 + MAP_SCENE_VERTICAL_OVERSIZE_FACTOR)
- INDEX_0_TILE;
- if ((m_zoomLevel >= MIN_MAP_ZOOM_LEVEL) && (m_zoomLevel <= MAX_MAP_ZOOM_LEVEL)
+ if ((m_zoomLevel >= OSM_MIN_ZOOM_LEVEL) && (m_zoomLevel <= OSM_MAX_ZOOM_LEVEL)
&& (m_tileNumber.x() >= MIN_TILE_NUMBER_X) && (m_tileNumber.x() <= MAX_TILE_NUMBER_X)
&& (m_tileNumber.y() >= 0) && (m_tileNumber.y() <= MAX_TILE_NUMBER)) {
setPos(MapEngine::convertTileNumberToSceneCoordinate(m_zoomLevel, m_tileNumber));
{
qDebug() << __PRETTY_FUNCTION__;
- if (m_zoomLevel + 1 <= MAX_MAP_ZOOM_LEVEL) {
+ if (m_zoomLevel + 1 <= OSM_MAX_ZOOM_LEVEL) {
QPoint pressPosition = mapToScene(event->pos()).toPoint();
QPoint viewCenterPosition = mapToScene(width() / 2 - 1, height() / 2 - 1).toPoint();
QPoint zoomPosition = viewCenterPosition - ((viewCenterPosition - pressPosition) / 2);
m_zoomAnimation->setEasingCurve(QEasingCurve::InQuad);
m_zoomAnimation->setDuration(ZOOM_TIME_MS);
m_zoomAnimation->setStartValue(viewScale());
- m_zoomAnimation->setEndValue(pow(2, m_zoomLevel+1 - MAX_MAP_ZOOM_LEVEL));
+ m_zoomAnimation->setEndValue(pow(2, m_zoomLevel+1 - OSM_MAX_ZOOM_LEVEL));
m_scrollAndZoomAnimation->start();
}
effectViewDistance /= biggerDistance / m_kineticMaxViewDistance;
QPointF effectSceneDistance = effectViewDistance
- * (1 << (MAX_MAP_ZOOM_LEVEL - m_zoomLevel));
+ * (1 << (OSM_MAX_ZOOM_LEVEL - m_zoomLevel));
m_scroller->setEasingCurve(QEasingCurve::OutCirc);
m_scroller->setDuration(KINETIC_SCROLL_TIME_MS);
m_zoomAnimation->setEasingCurve(QEasingCurve::InQuad);
m_zoomAnimation->setDuration(ZOOM_TIME_MS);
m_zoomAnimation->setStartValue(viewScale());
- m_zoomAnimation->setEndValue(pow(2, zoomLevel - MAX_MAP_ZOOM_LEVEL));
+ m_zoomAnimation->setEndValue(pow(2, zoomLevel - OSM_MAX_ZOOM_LEVEL));
m_zoomAnimation->start();
}
--- /dev/null
+/*
+ Situare - A location system for Facebook
+ Copyright (C) 2010 Ixonos Plc. Authors:
+
+ Sami Rämö - sami.ramo@ixonos.com
+
+ Situare is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ version 2 as published by the Free Software Foundation.
+
+ Situare is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Situare; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA.
+*/
+
+
+#ifndef OSM_H
+#define OSM_H
+
+// ZOOM LEVELS
+const int OSM_MIN_ZOOM_LEVEL = 0; ///< Minimum zoom level
+const int OSM_MAX_ZOOM_LEVEL = 18; ///< Maximum zoom level
+
+// TILES
+const int OSM_TILE_SIZE_X = 256; ///< Tile image size in x direction
+const int OSM_TILE_SIZE_Y = 256; ///< Tile image size in y direction
+const int OSM_TILES_PER_SIDE = (1 << OSM_MAX_ZOOM_LEVEL); ///< Amount of tiles per side
+
+// LATITUDE COORDINATE LIMITS
+/**
+* @var OSM_MAX_LATITUDE
+* @brief Maximum latitude value ( = arctan(sinh(pi))
+*/
+const double OSM_MAX_LATITUDE = 85.05112877980659237802;
+const double OSM_MIN_LATITUDE = -OSM_MAX_LATITUDE; ///< Minimum latitude value
+
+// MAP PIXELS
+/**
+* @var OMS_MAP_PIXELS_X
+* @brief Amount of horizontal pixels in map
+*/
+const int OMS_MAP_PIXELS_X = OSM_TILES_PER_SIDE * OSM_TILE_SIZE_X;
+
+const int OSM_MAP_MIN_PIXEL_X = 0; ///< First map horizontal pixel index
+const int OSM_MAP_MIN_PIXEL_Y = 0; ///< First map vertical pixel index
+
+const int OSM_MAP_MAX_PIXEL_X = OMS_MAP_PIXELS_X - 1; ///< Last map horizontal pixel index
+/**
+* @var OSM_MAP_MAX_PIXEL_Y
+* @brief Last map vertical pixel index
+*/
+const int OSM_MAP_MAX_PIXEL_Y = OSM_TILES_PER_SIDE * OSM_TILE_SIZE_Y - 1;
+
+#endif // OSM_H
ui/zoombuttonpanel.h \
user/user.h \
ui/fullscreenbutton.h \
- engine/mce.h
+ engine/mce.h \
+ map/osm.h
QT += network \
webkit
HEADERS += \
../../../src/coordinates/geocoordinate.h \
../../../src/coordinates/scenecoordinate.h \
- ../../../src/map/mapcommon.h
+ ../../../src/map/osm.h
DEFINES += QT_NO_DEBUG_OUTPUT
QTest::addColumn<SceneCoordinate>("sceneCoordinate");
QTest::addColumn<GeoCoordinate>("result");
- QTest::newRow("top left") << SceneCoordinate(MAP_MIN_PIXEL_X, MAP_MIN_PIXEL_Y)
- << GeoCoordinate(MAX_LATITUDE, MIN_LONGITUDE);
+ QTest::newRow("top left") << SceneCoordinate(OSM_MAP_MIN_PIXEL_X, OSM_MAP_MIN_PIXEL_Y)
+ << GeoCoordinate(OSM_MAX_LATITUDE, MIN_LONGITUDE);
const double LAST_SCENE_HORIZONTAL_PIXEL_LONGITUDE = MAX_LONGITUDE
- ONE_SCENE_PIXEL_WIDTH_IN_DEGREES;
- QTest::newRow("bottom right") << SceneCoordinate(MAP_MAX_PIXEL_X, MAP_MAX_PIXEL_Y)
- << GeoCoordinate(MIN_LATITUDE, LAST_SCENE_HORIZONTAL_PIXEL_LONGITUDE);
+ QTest::newRow("bottom right") << SceneCoordinate(OSM_MAP_MAX_PIXEL_X, OSM_MAP_MAX_PIXEL_Y)
+ << GeoCoordinate(OSM_MIN_LATITUDE, LAST_SCENE_HORIZONTAL_PIXEL_LONGITUDE);
}
void TestGeoCoordinate::isNull()
HEADERS += \
../../../src/coordinates/scenecoordinate.h \
../../../src/coordinates/geocoordinate.h \
- ../../../src/map/mapcommon.h
+ ../../../src/map/osm.h
INCLUDEPATH += . \
../../../src/
QTest::addColumn<GeoCoordinate>("geoCoordinate");
QTest::addColumn<SceneCoordinate>("result");
- QTest::newRow("top left pixel") << GeoCoordinate(MAX_LATITUDE, MIN_LONGITUDE)
+ QTest::newRow("top left pixel") << GeoCoordinate(OSM_MAX_LATITUDE, MIN_LONGITUDE)
<< SceneCoordinate(0, 0);
const double ONE_SCENE_PIXEL_WIDTH_IN_DEGREES = 0.00000536441802978516;
const double LAST_SCENE_HORIZONTAL_PIXEL_LONGITUDE = MAX_LONGITUDE
- ONE_SCENE_PIXEL_WIDTH_IN_DEGREES;
QTest::newRow("bottom right pixel")
- << GeoCoordinate(MIN_LATITUDE, LAST_SCENE_HORIZONTAL_PIXEL_LONGITUDE)
- << SceneCoordinate(MAP_MAX_PIXEL_X, MAP_MAX_PIXEL_Y);
+ << GeoCoordinate(OSM_MIN_LATITUDE, LAST_SCENE_HORIZONTAL_PIXEL_LONGITUDE)
+ << SceneCoordinate(OSM_MAP_MAX_PIXEL_X, OSM_MAP_MAX_PIXEL_Y);
QTest::newRow("southeast corner with 180 degrees longitude")
- << GeoCoordinate(MIN_LATITUDE, MAX_LONGITUDE)
- << SceneCoordinate(MAP_MIN_PIXEL_X, MAP_MAX_PIXEL_Y);
+ << GeoCoordinate(OSM_MIN_LATITUDE, MAX_LONGITUDE)
+ << SceneCoordinate(OSM_MAP_MIN_PIXEL_X, OSM_MAP_MAX_PIXEL_Y);
QTest::newRow("southeast corner just little over west edge of the map")
- << GeoCoordinate(MIN_LATITUDE, MIN_LONGITUDE - ONE_SCENE_PIXEL_WIDTH_IN_DEGREES)
- << SceneCoordinate(MAP_MAX_PIXEL_X, MAP_MAX_PIXEL_Y);
+ << GeoCoordinate(OSM_MIN_LATITUDE, MIN_LONGITUDE - ONE_SCENE_PIXEL_WIDTH_IN_DEGREES)
+ << SceneCoordinate(OSM_MAP_MAX_PIXEL_X, OSM_MAP_MAX_PIXEL_Y);
}
void TestSceneCoordinate::isNull()
QTest::addColumn<QPointF>("coordinate");
QTest::addColumn<QPoint>("result");
- QTest::newRow("top left") << QPointF(MIN_LONGITUDE, MAX_LATITUDE) << QPoint(0, 0);
+ QTest::newRow("top left") << QPointF(MIN_LONGITUDE, OSM_MAX_LATITUDE) << QPoint(0, 0);
- int x = (1 << MAX_MAP_ZOOM_LEVEL) * TILE_SIZE_X;
- int y = (1 << MAX_MAP_ZOOM_LEVEL) * TILE_SIZE_Y;
- QTest::newRow("bottom right") << QPointF(MAX_LONGITUDE, MIN_LATITUDE) << QPoint(x, y);
+ int x = (1 << OSM_MAX_ZOOM_LEVEL) * OSM_TILE_SIZE_X;
+ int y = (1 << OSM_MAX_ZOOM_LEVEL) * OSM_TILE_SIZE_Y;
+ QTest::newRow("bottom right") << QPointF(MAX_LONGITUDE, OSM_MIN_LATITUDE) << QPoint(x, y);
}
/**
// move one tile to east and south, only most right one column and most bottom one row tiles
// should be downloaded
- emit setCenterPosition(QPoint((1220+TILE_SIZE_X)*16, (1220+TILE_SIZE_Y)*16));
+ emit setCenterPosition(QPoint((1220+OSM_TILE_SIZE_X)*16, (1220+OSM_TILE_SIZE_Y)*16));
QTest::qWait(1000);
QCOMPARE(fetchImageSpy.count(), 4 + 4);
fetchImageSpy.clear();
QVERIFY(parameters.at(0).toInt() == DEFAULT_TEST_ZOOMLEVEL);
parameters = mapEngineSpy.takeFirst();
- QVERIFY(parameters.at(0).toInt() == DEFAULT_START_ZOOM_LEVEL);
+ QVERIFY(parameters.at(0).toInt() == MAP_DEFAULT_ZOOM_LEVEL);
// Call set location with know parameter to get location changed
// Store new location and zoomlevel to settings
TEMPLATE = subdirs
-SUBDIRS = map/mapengine \
+SUBDIRS = coordinates/geocoordinate \
+ coordinates/scenecoordinate \
+ map/mapengine \
map/mapview \
map/ownlocationitem \
map/gpslocationitem \
map/friendgroupitem \
map/mapscene \
map/friendlocationitem \
- user \
ui/friendlist \
ui/sidepanel \
ui/avatarimage \
+ user \
routing/route \
routing/routesegment