return (centerTile != temp);
}
-qreal MapEngine::sceneResolution()
-{
- qDebug() << __PRETTY_FUNCTION__;
-
- const int SHIFT = 200;
-
- qreal scale = (1 << (OSM_MAX_ZOOM_LEVEL - m_zoomLevel));
- GeoCoordinate centerCoordinate = centerGeoCoordinate();
- SceneCoordinate shiftedSceneCoordinate(m_sceneCoordinate.x() + SHIFT * scale,
- m_sceneCoordinate.y());
- GeoCoordinate shiftedCoordinate(shiftedSceneCoordinate);
- qreal dist = centerCoordinate.distanceTo(shiftedCoordinate);
- return (dist / SHIFT);
-}
-
void MapEngine::mapImageReceived(int zoomLevel, int x, int y, const QPixmap &image)
{
qDebug() << __PRETTY_FUNCTION__;
}
m_mapScene->spanItems(m_zoomLevel, m_sceneCoordinate, m_viewSize);
- emit newMapResolution(sceneResolution());
+ emit newMapResolution(viewResolution());
}
void MapEngine::setGPSEnabled(bool enabled)
m_mapScene->setSceneVerticalOverlap(m_viewSize.height(), m_zoomLevel);
}
+qreal MapEngine::viewResolution()
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ qreal scale = (1 << (OSM_MAX_ZOOM_LEVEL - m_zoomLevel));
+
+ return MapScene::horizontalResolutionAtLatitude(centerGeoCoordinate().latitude()) * scale;
+}
+
void MapEngine::viewZoomFinished()
{
qDebug() << __PRETTY_FUNCTION__;
getTiles(m_sceneCoordinate);
m_mapScene->setSceneVerticalOverlap(m_viewSize.height(), m_zoomLevel);
m_mapScene->spanItems(m_zoomLevel, m_sceneCoordinate, m_viewSize);
- emit newMapResolution(sceneResolution());
+ emit newMapResolution(viewResolution());
}
void MapEngine::zoomIn()
bool isCenterTileChanged(SceneCoordinate coordinate);
/**
- * @brief Calculate scale at the map center of the map in meters/pixel
- *
- * @return qreal Scale of the map in meters/pixel
- */
- qreal sceneResolution();
-
- /**
* @brief Set size of tiles grid based on view size
*
* @param viewSize Current view size
void updateViewTilesSceneRect();
/**
+ * @brief Calculate scale at the map center of the map in meters/pixel
+ *
+ * @return qreal Scale of the map in meters/pixel
+ */
+ qreal viewResolution();
+
+ /**
* @brief This method is ran always when the map is zoomed
*
* This method is the right place for all actions which must be done when ever map is zoomed.
}
}
+qreal MapScene::horizontalResolutionAtLatitude(double latitude)
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ const int SHIFT = 200;
+
+ GeoCoordinate from = GeoCoordinate(latitude, 0);
+
+ SceneCoordinate fromScene = SceneCoordinate(from);
+ SceneCoordinate toScene(fromScene.x() + SHIFT, fromScene.y());
+ GeoCoordinate to(toScene);
+
+ qreal distance = from.distanceTo(to);
+
+ return (distance / SHIFT);
+}
+
void MapScene::moveIntersectingItemsHorizontally(QRect from, int distance)
{
qDebug() << __PRETTY_FUNCTION__;
void enqueueRemoveStackedTiles(MapTile *newTile);
/**
+ * @brief Calculates scene horizontal resolution in given latitude
+ *
+ * @param latitude Resolution is calculated in this latitude
+ * @returns Scene horizontal resolution (meters/pixel)
+ */
+ static qreal horizontalResolutionAtLatitude(double latitude);
+
+ /**
* @brief Returns tile mathcing given hash key
*
* @param hashKey