const int GPS_ACCURACY_UNDEFINED = -1; ///< Value used when accuracy is undefined
-/// @todo Remove, or if really needed then re-implement in GeoCoordinate (not good) or modify all needed places use constructor with invalid values as parameters
-//const int GPS_COORDINATE_UNDEFINED = -1000; ///< Value used when coordinate is undefined
-
#endif // GPSCOMMON_H
/**
* @brief Signal for position information.
*
- * @param latLonCoordinate latitude and longitude values
+ * @param coordinate latitude and longitude values
* @param accuracy accuracy in metres
*/
void position(GeoCoordinate coordinate, qreal accuracy);
#include "friendgroupitem.h"
#include "friendlocationitem.h"
#include "mapcommon.h"
-/// @todo remove #include "mapengine.h"
#include "mapscene.h"
#include "user/user.h"
}
-void GPSLocationItem::updatePosition(SceneCoordinate scenePosition, qreal accuracy)
+void GPSLocationItem::updatePosition(SceneCoordinate coordinate, qreal accuracy)
{
qDebug() << __PRETTY_FUNCTION__;
- setPos(scenePosition.toPointF());
+ setPos(coordinate.toPointF());
if (accuracy == GPS_ACCURACY_UNDEFINED) { // fix is NOT accurate
if (m_currentAccuracy != COARSE) { // coarse pixmap not yet set
*
* Use yellow led image when using network positioning and green led image when using GPS.
*
- * @param scenePosition Scene coordinate
+ * @param coordinate Scene coordinate
* @param accuracy Accuracy of the GPS fix
*/
- void updatePosition(SceneCoordinate scenePosition, qreal accuracy);
+ void updatePosition(SceneCoordinate coordinate, qreal accuracy);
/*******************************************************************************
* DATA MEMBERS
m_zoomedIn(false),
m_zoomLevel(MAP_DEFAULT_ZOOM_LEVEL),
m_centerTile(QPoint(UNDEFINED, UNDEFINED)),
- /// @todo remove, automatic init to zero // m_lastAutomaticPosition(QPoint(0, 0)),
m_sceneCoordinate(SceneCoordinate(GeoCoordinate(MAP_DEFAULT_LATITUDE, MAP_DEFAULT_LONGITUDE))),
m_tilesGridSize(QSize(0, 0)),
m_viewSize(QSize(DEFAULT_SCREEN_WIDTH, DEFAULT_SCREEN_HEIGHT))
settings.setValue(MAP_LAST_ZOOMLEVEL, m_zoomLevel);
}
-QRect MapEngine::calculateTileGrid(SceneCoordinate sceneCoordinate)
+QRect MapEngine::calculateTileGrid(SceneCoordinate coordinate)
{
qDebug() << __PRETTY_FUNCTION__;
- QPoint tileCoordinate = convertSceneCoordinateToTileNumber(m_zoomLevel, sceneCoordinate);
+ QPoint tileCoordinate = convertSceneCoordinateToTileNumber(m_zoomLevel, coordinate);
QPoint topLeft;
topLeft.setX(tileCoordinate.x() - (m_tilesGridSize.width() / 2));
return GeoCoordinate(m_sceneCoordinate);
}
-void MapEngine::centerToCoordinates(GeoCoordinate latLonCoordinate)
+void MapEngine::centerToCoordinates(GeoCoordinate coordinate)
{
qDebug() << __PRETTY_FUNCTION__;
- scrollToPosition(SceneCoordinate(latLonCoordinate));
+ scrollToPosition(SceneCoordinate(coordinate));
}
-/// @todo remove
-//QPoint MapEngine::convertLatLonToSceneCoordinate(QPointF latLonCoordinate)
-//{
-// qDebug() << __PRETTY_FUNCTION__;
-
-// qreal longitude = latLonCoordinate.x();
-// qreal latitude = latLonCoordinate.y();
-
-// if ((longitude > MAX_LONGITUDE) || (longitude < MIN_LONGITUDE))
-// return QPoint(UNDEFINED, UNDEFINED);
-// if ((latitude > OSM_MAX_LATITUDE) || (latitude < OSM_MIN_LATITUDE))
-// return QPoint(UNDEFINED, UNDEFINED);
-
-// 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 * OSM_TILE_SIZE_X, y * z * OSM_TILE_SIZE_Y).toPoint();
-//}
-
-//QPointF MapEngine::convertSceneCoordinateToLatLon(int zoomLevel, QPoint sceneCoordinate)
-//{
-// qDebug() << __PRETTY_FUNCTION__;
-
-// 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;
-
-// double n = M_PI - 2.0 * M_PI * yFactor / tileFactor;
-// double latitude = 180.0 / M_PI * atan(0.5 * (exp(n) - exp(-n)));
-
-// return QPointF(longitude, latitude);
-//}
-
-QPoint MapEngine::convertSceneCoordinateToTileNumber(int zoomLevel, SceneCoordinate sceneCoordinate)
+QPoint MapEngine::convertSceneCoordinateToTileNumber(int zoomLevel, SceneCoordinate coordinate)
{
qDebug() << __PRETTY_FUNCTION__;
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));
+ int x = static_cast<int>(coordinate.x() / (OSM_TILE_SIZE_X * pow));
+ int y = static_cast<int>(coordinate.y() / (OSM_TILE_SIZE_Y * pow));
return QPoint(x, y);
}
return SceneCoordinate(x, y);
}
-void MapEngine::disableAutoCenteringIfRequired(SceneCoordinate sceneCoordinate)
+void MapEngine::disableAutoCenteringIfRequired(SceneCoordinate coordinate)
{
if (isAutoCenteringEnabled()) {
int zoomFactor = (1 << (OSM_MAX_ZOOM_LEVEL - m_zoomLevel));
SceneCoordinate oldPixelValue(m_lastAutomaticPosition.x() / zoomFactor,
m_lastAutomaticPosition.y() / zoomFactor);
- SceneCoordinate newPixelValue(sceneCoordinate.x() / zoomFactor,
- sceneCoordinate.y() / zoomFactor);
+ SceneCoordinate newPixelValue(coordinate.x() / zoomFactor,
+ coordinate.y() / zoomFactor);
if ((abs(oldPixelValue.x() - newPixelValue.x()) > AUTO_CENTERING_DISABLE_DISTANCE)
|| (abs(oldPixelValue.y() - newPixelValue.y()) > AUTO_CENTERING_DISABLE_DISTANCE)) {
m_mapScene->spanItems(m_zoomLevel, m_sceneCoordinate, m_viewSize);
}
-void MapEngine::getTiles(SceneCoordinate sceneCoordinate)
+void MapEngine::getTiles(SceneCoordinate coordinate)
{
qDebug() << __PRETTY_FUNCTION__;
- m_viewTilesGrid = calculateTileGrid(sceneCoordinate);
+ m_viewTilesGrid = calculateTileGrid(coordinate);
updateViewTilesSceneRect();
m_mapScene->setTilesGrid(m_viewTilesGrid);
QSettings settings(DIRECTORY_NAME, FILE_NAME);
- /// @todo remove
-// if (settings.value(MAP_LAST_POSITION, ERROR_VALUE_NOT_FOUND_ON_SETTINGS).toString()
-// == 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 = GeoCoordinate(MAP_DEFAULT_LATITUDE, MAP_DEFAULT_LONGITUDE);
-// 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,
-// ERROR_VALUE_NOT_FOUND_ON_SETTINGS).toPointF();
-// }
-
// init can be only done if both values exists in the settings
if (settings.contains(MAP_LAST_POSITION) && settings.contains(MAP_LAST_ZOOMLEVEL)) {
QVariant zoomLevel = settings.value(MAP_LAST_ZOOMLEVEL);
return m_autoCenteringEnabled;
}
-bool MapEngine::isCenterTileChanged(SceneCoordinate sceneCoordinate)
+bool MapEngine::isCenterTileChanged(SceneCoordinate coordinate)
{
qDebug() << __PRETTY_FUNCTION__;
- QPoint centerTile = convertSceneCoordinateToTileNumber(m_zoomLevel, sceneCoordinate);
+ QPoint centerTile = convertSceneCoordinateToTileNumber(m_zoomLevel, coordinate);
QPoint temp = m_centerTile;
m_centerTile = centerTile;
m_scrollStartedByGps = false;
}
-void MapEngine::scrollToPosition(SceneCoordinate scenePosition)
+void MapEngine::scrollToPosition(SceneCoordinate coordinate)
{
qDebug() << __PRETTY_FUNCTION__;
m_scroller->setEasingCurve(QEasingCurve::InOutQuart);
m_scroller->setDuration(SMOOTH_CENTERING_TIME_MS);
m_scroller->setStartValue(m_sceneCoordinate.toPointF());
- m_scroller->setEndValue(scenePosition.toPointF());
+ m_scroller->setEndValue(coordinate.toPointF());
m_smoothScrollRunning = true;
m_scroller->start();
}
m_autoCenteringEnabled = enabled;
}
-void MapEngine::setCenterPosition(SceneCoordinate scenePosition)
+void MapEngine::setCenterPosition(SceneCoordinate coordinate)
{
qDebug() << __PRETTY_FUNCTION__;
// jump to opposite side of the world if world horizontal limit is exceeded
- scenePosition.setX(normalize(scenePosition.x(), OSM_MAP_MIN_PIXEL_X, OSM_MAP_MAX_PIXEL_X));
+ coordinate.setX(normalize(coordinate.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(double(OSM_MAP_MIN_PIXEL_Y),
- scenePosition.y(),
+ coordinate.setY(qBound(double(OSM_MAP_MIN_PIXEL_Y),
+ coordinate.y(),
double(OSM_MAP_MAX_PIXEL_Y)));
if (!m_smoothScrollRunning)
- disableAutoCenteringIfRequired(scenePosition);
+ disableAutoCenteringIfRequired(coordinate);
- m_sceneCoordinate = scenePosition;
+ m_sceneCoordinate = coordinate;
emit locationChanged(m_sceneCoordinate);
- if (isCenterTileChanged(scenePosition)) {
- getTiles(scenePosition);
+ if (isCenterTileChanged(coordinate)) {
+ getTiles(coordinate);
m_mapScene->removeOutOfViewTiles(m_viewTilesGrid, m_zoomLevel);
}
*/
GeoCoordinate centerGeoCoordinate();
- /// @todo remove
-// /**
-// * @brief Convert latitude and longitude to scene coordinates.
-// *
-// * @param latLonCoordinate latitude and longitude values
-// * @return scene coordinate
-// */
-// static QPoint convertLatLonToSceneCoordinate(GeoCoordinate latLonCoordinate);
-
-// /**
-// * @brief converts scene coordinates to latitude and longitude
-// *
-// * @param zoomLevel current zoom level
-// * @param sceneCoordinate that will be converted
-// */
-// GeoCoordinate convertSceneCoordinateToLatLon(int zoomLevel, QPoint sceneCoordinate);
-
/**
* @brief Convert MapScene coordinate to tile x & y numbers.
*
* @param zoomLevel ZoomLevel
- * @param sceneCoordinate MapScene coordinate
+ * @param coordinate MapScene coordinate
* @return tile x & y numbers
*/
- static QPoint convertSceneCoordinateToTileNumber(int zoomLevel, SceneCoordinate sceneCoordinate);
+ static QPoint convertSceneCoordinateToTileNumber(int zoomLevel, SceneCoordinate coordinate);
/**
* @brief Convert tile x & y numbers to MapScene coordinates
/**
* @brief Center smoothly to given latitude and longitude coordinates.
*
- * @param latLonCoordinate Latitude & longitude coordinates for location
+ * @param coordinate Latitude & longitude coordinates for location
*/
- void centerToCoordinates(GeoCoordinate latLonCoordinate);
+ void centerToCoordinates(GeoCoordinate coordinate);
/**
* @brief Slot to catch user own location data
*
* Grid size is calculated from view size and scene's current center coordinate.
*
- * @param sceneCoordinate scene's current center coordinate
+ * @param coordinate scene's current center coordinate
* @return QRect grid of tile coordinates
*/
- QRect calculateTileGrid(SceneCoordinate sceneCoordinate);
+ QRect calculateTileGrid(SceneCoordinate coordinate);
/**
* @brief Request disabling of auto centering if centered too far from the real location.
*
- * @param sceneCoordinate scene's center coordinate
+ * @param coordinate scene's center coordinate
*/
- void disableAutoCenteringIfRequired(SceneCoordinate sceneCoordinate);
+ void disableAutoCenteringIfRequired(SceneCoordinate coordinate);
/**
* @brief Get new tiles.
*
* Calculates which tiles has to be fetched. Does emit fetchImage for tiles which
* aren't already in the scene.
- * @param sceneCoordinate scene's center coordinate
+ * @param coordinate scene's center coordinate
*/
- void getTiles(SceneCoordinate sceneCoordinate);
+ void getTiles(SceneCoordinate coordinate);
/**
* @brief Check if auto centering is enabled
/**
* @brief Check if center tile has changed.
*
- * @param sceneCoordinate scene's center coordinate
+ * @param coordinate scene's center coordinate
* @return bool true if center tile changed, false otherwise
*/
- bool isCenterTileChanged(SceneCoordinate sceneCoordinate);
+ bool isCenterTileChanged(SceneCoordinate coordinate);
/**
* @brief Calculate scale at the map center of the map in meters/pixel
/**
* @brief Scroll smoothly to given scene position
*
- * @param scenePosition Target position in the scene
+ * @param coordinate Target position in the scene
*/
- void scrollToPosition(SceneCoordinate scenePosition);
+ void scrollToPosition(SceneCoordinate coordinate);
/**
* @brief Set center point in the scene
*
* Does emit locationChanged signal.
- * @param scenePosition Scene coordinates for new position
+ * @param coordinate Scene coordinates for new position
*/
- void setCenterPosition(SceneCoordinate scenePosition);
+ void setCenterPosition(SceneCoordinate coordinate);
/**
* @brief Slot for actions after view zoom is finished
/**
* @brief Request view centering to new locaiton
*
- * @param sceneCoordinate New scene coordinates
+ * @param coordinate New scene coordinates
*/
- void locationChanged(SceneCoordinate sceneCoordinate);
+ void locationChanged(SceneCoordinate coordinate);
/**
* @brief Signal is emitted when location item is clicked.
m_zoomLevel = zoomLevel;
}
-void MapScene::spanItems(int zoomLevel, SceneCoordinate sceneCoordinate, QSize viewSize)
+void MapScene::spanItems(int zoomLevel, SceneCoordinate coordinate, QSize viewSize)
{
qDebug() << __PRETTY_FUNCTION__;
// calculate current horizontal area shown on the view
int viewSceneWidth = (1 << (OSM_MAX_ZOOM_LEVEL - zoomLevel)) * viewSize.width();
- int viewSceneLeft = sceneCoordinate.x() - viewSceneWidth / 2;
- int viewSceneRight = sceneCoordinate.x() + viewSceneWidth / 2;
+ int viewSceneLeft = coordinate.x() - viewSceneWidth / 2;
+ int viewSceneRight = coordinate.x() + viewSceneWidth / 2;
// limit rects to include only area which really must be moved
leftRect.setRight(-1 - (OMS_MAP_PIXELS_X - 1 - viewSceneRight));
* @brief Span items (others than MapTile) to opposite side of the scene
*
* @param zoomLevel Current zoom level
- * @param sceneCoordinate Scene coordinates of the current center point
+ * @param coordinate Scene coordinates of the current center point
* @param viewSize Current size of the view
*/
- void spanItems(int zoomLevel, SceneCoordinate sceneCoordinate, QSize viewSize);
+ void spanItems(int zoomLevel, SceneCoordinate coordinate, QSize viewSize);
/**
* @brief Save new tiles scene rect
this, SLOT(doubleTapZoomFinished()));
}
-void MapView::centerToSceneCoordinates(const SceneCoordinate &sceneCoordinate)
+void MapView::centerToSceneCoordinates(const SceneCoordinate &coordinate)
{
- qDebug() << __PRETTY_FUNCTION__ << "sceneCoordinate" << sceneCoordinate;
+ qDebug() << __PRETTY_FUNCTION__ << "coordinate" << coordinate;
- centerOn(sceneCoordinate.toPointF());
+ centerOn(coordinate.toPointF());
}
void MapView::doubleTapZoomFinished()
/**
* @brief Slot for centering view to new location
*
- * @param sceneCoordinate Scene coordinates of the new center point
+ * @param coordinate Scene coordinates of the new center point
*/
- void centerToSceneCoordinates(const SceneCoordinate &sceneCoordinate);
+ void centerToSceneCoordinates(const SceneCoordinate &coordinate);
/**
* @brief Set zoom level of the view
* @brief Signal for view scroll events
*
* Signal is emitted when view is scrolled.
- * @param sceneCoordinate Scene coordinates of the new center point of the view
+ * @param coordinate Scene coordinates of the new center point of the view
*/
- void viewScrolled(const SceneCoordinate &sceneCoordinate);
+ void viewScrolled(const SceneCoordinate &coordinate);
/**
* @brief Signal for informing that zooming animation is finished
/**
* @brief View should be centered to new location
*
- * @param sceneCoordinate Scene coordinates of the new center point
+ * @param coordinate Scene coordinates of the new center point
*/
- void centerToSceneCoordinates(const SceneCoordinate &sceneCoordinate);
+ void centerToSceneCoordinates(const SceneCoordinate &coordinate);
/**
* @brief Signal for enabling automatic location update.
/**
* @brief Forwarding signal from MapView to MapEngine
*
- * @param sceneCoordinate
+ * @param coordinate
*/
- void mapViewScrolled(const SceneCoordinate &sceneCoordinate);
+ void mapViewScrolled(const SceneCoordinate &coordinate);
/**
* @brief Forwarding signal from MapEngine to MapView