Re-factored coordinate parameter names, clean-up
authorSami Rämö <sami.ramo@ixonos.com>
Mon, 19 Jul 2010 12:05:48 +0000 (15:05 +0300)
committerSami Rämö <sami.ramo@ixonos.com>
Mon, 19 Jul 2010 12:11:27 +0000 (15:11 +0300)
12 files changed:
src/gps/gpscommon.h
src/gps/gpsposition.h
src/map/frienditemshandler.cpp
src/map/gpslocationitem.cpp
src/map/gpslocationitem.h
src/map/mapengine.cpp
src/map/mapengine.h
src/map/mapscene.cpp
src/map/mapscene.h
src/map/mapview.cpp
src/map/mapview.h
src/ui/mainwindow.h

index 47247a8..bbc3b3e 100644 (file)
@@ -25,7 +25,4 @@
 
 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
index b140fbc..35be50d 100644 (file)
@@ -136,7 +136,7 @@ signals:
     /**
     * @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);
index 7dd20e5..b96a3b3 100644 (file)
@@ -27,7 +27,6 @@
 #include "friendgroupitem.h"
 #include "friendlocationitem.h"
 #include "mapcommon.h"
-/// @todo remove #include "mapengine.h"
 #include "mapscene.h"
 #include "user/user.h"
 
index df9293c..73010f2 100644 (file)
@@ -56,11 +56,11 @@ void GPSLocationItem::setEnabled(bool enable)
 
 }
 
-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
index 8093291..c3bf316 100644 (file)
@@ -56,10 +56,10 @@ public:
       *
       * 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
index beb6858..cd9d23d 100644 (file)
@@ -56,7 +56,6 @@ MapEngine::MapEngine(QObject *parent)
       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))
@@ -115,11 +114,11 @@ MapEngine::~MapEngine()
     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));
@@ -135,59 +134,20 @@ GeoCoordinate MapEngine::centerGeoCoordinate()
     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);
 }
@@ -203,7 +163,7 @@ SceneCoordinate MapEngine::convertTileNumberToSceneCoordinate(int zoomLevel, QPo
     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));
@@ -211,8 +171,8 @@ void MapEngine::disableAutoCenteringIfRequired(SceneCoordinate sceneCoordinate)
         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)) {
@@ -229,11 +189,11 @@ void MapEngine::friendsPositionsUpdated()
     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);
 
@@ -293,19 +253,6 @@ void MapEngine::init()
 
     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);
@@ -330,11 +277,11 @@ bool MapEngine::isAutoCenteringEnabled()
     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;
 
@@ -432,7 +379,7 @@ void MapEngine::scrollerStateChanged(QAbstractAnimation::State newState)
     m_scrollStartedByGps = false;
 }
 
-void MapEngine::scrollToPosition(SceneCoordinate scenePosition)
+void MapEngine::scrollToPosition(SceneCoordinate coordinate)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
@@ -440,7 +387,7 @@ void MapEngine::scrollToPosition(SceneCoordinate scenePosition)
     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();
 }
@@ -452,26 +399,26 @@ void MapEngine::setAutoCentering(bool enabled)
     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);
     }
 
index 393102a..7b09da3 100644 (file)
@@ -82,31 +82,14 @@ public:
      */
     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
@@ -187,9 +170,9 @@ public slots:
     /**
      * @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
@@ -235,26 +218,26 @@ private:
      *
      * 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
@@ -266,10 +249,10 @@ private:
     /**
      * @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
@@ -347,17 +330,17 @@ private slots:
     /**
     * @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
@@ -414,9 +397,9 @@ signals:
     /**
      * @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.
index 1a1e7ca..5837eca 100644 (file)
@@ -244,7 +244,7 @@ void MapScene::setZoomLevel(int zoomLevel)
     m_zoomLevel = zoomLevel;
 }
 
-void MapScene::spanItems(int zoomLevel, SceneCoordinate sceneCoordinate, QSize viewSize)
+void MapScene::spanItems(int zoomLevel, SceneCoordinate coordinate, QSize viewSize)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
@@ -256,8 +256,8 @@ void MapScene::spanItems(int zoomLevel, SceneCoordinate sceneCoordinate, QSize v
 
     // 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));
index 6ee3d1f..95ee0cf 100644 (file)
@@ -149,10 +149,10 @@ public:
       * @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
index 90c8e66..748d9a2 100644 (file)
@@ -66,11 +66,11 @@ MapView::MapView(QWidget *parent)
             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()
index ac9adfc..cd1cc7b 100644 (file)
@@ -132,9 +132,9 @@ public slots:
     /**
     * @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
@@ -182,9 +182,9 @@ signals:
     * @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
index 810c130..5a97afb 100644 (file)
@@ -413,9 +413,9 @@ signals:
     /**
     * @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.
@@ -497,9 +497,9 @@ signals:
     /**
       * @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