#include "facebookservice/facebookauthentication.h"
#include "gps/gpsposition.h"
#include "map/mapengine.h"
+#include "routing/routingservice.h"
+ #include "mce.h"
+ #include "network/networkaccessmanager.h"
#include "situareservice/situareservice.h"
#include "ui/mainwindow.h"
- #include "network/networkaccessmanager.h"
- #include "mce.h"
- #include <cmath>
#include "engine.h"
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_sceneCoordinate(SceneCoordinate(GeoCoordinate(MAP_DEFAULT_LATITUDE, MAP_DEFAULT_LONGITUDE))),
m_tilesGridSize(QSize(0, 0)),
- m_viewSize(QSize(DEFAULT_SCREEN_WIDTH, DEFAULT_SCREEN_HEIGHT))
+ m_viewSize(QSize(DEFAULT_SCREEN_WIDTH, DEFAULT_SCREEN_HEIGHT)),
+ m_mapRouteItem(0)
{
qDebug() << __PRETTY_FUNCTION__;
return QRect(topLeft, m_tilesGridSize);
}
+void MapEngine::centerAndZoomTo(QRect rect)
+{
+ const int MARGIN_HORIZONTAL = 50;
+ const int MARGIN_VERTICAL = 5;
+
+ // calculate the usable size of the view
+ int viewUsableHeight = m_viewSize.height() - 2 * MARGIN_VERTICAL;
+ int viewUsableWidth = m_viewSize.width() - 2 * MARGIN_HORIZONTAL;
+
+ // calculate how many levels must be zoomed out from the closest zoom level to get the rect
+ // fit inside the usable view area
+ int shift = 0;
+ while ((rect.height() > (viewUsableHeight * (1 << shift)))
+ || (rect.width() > (viewUsableWidth * (1 << shift))))
+ shift++;
+
+ scrollToPosition(rect.center());
+
+ int zoomLevel = qBound(MIN_VIEW_ZOOM_LEVEL, MAX_MAP_ZOOM_LEVEL - shift, MAX_MAP_ZOOM_LEVEL);
+ setZoomLevel(zoomLevel);
+}
+
- QPointF MapEngine::centerGeoCoordinate()
- {
- qDebug() << __PRETTY_FUNCTION__;
-
- return convertSceneCoordinateToLatLon(m_zoomLevel, m_sceneCoordinate);
- }
-
- void MapEngine::centerToCoordinates(QPointF latLonCoordinate)
+ GeoCoordinate MapEngine::centerGeoCoordinate()
{
qDebug() << __PRETTY_FUNCTION__;
#include <QtCore>
+#include "routing/route.h"
+ #include "coordinates/geocoordinate.h"
+ #include "coordinates/scenecoordinate.h"
class QGraphicsScene;
*
* 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(QPoint sceneCoordinate);
+ QRect calculateTileGrid(SceneCoordinate coordinate);
/**
+ * @brief Center and zoom to given rect
+ *
+ * Map is centered to center point of the rect and zoomed so that whole rect is visible
+ * as big as possible.
+ *
+ * @param rect Target rect
+ */
+ void centerAndZoomTo(QRect rect);
+
+ /**
* @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(QPoint sceneCoordinate);
+ void disableAutoCenteringIfRequired(SceneCoordinate coordinate);
/**
* @brief Get new tiles.
* @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(QPoint scenePosition);
+ void setCenterPosition(SceneCoordinate coordinate);
/**
+ * @brief Builds and sets route, also centers it
+ *
+ * @param route Route route information
+ */
+ void setRoute(Route &route);
+
+ /**
* @brief Slot for actions after view zoom is finished
*
* Does run removeOutOfViewTiles
user/user.cpp \
ui/fullscreenbutton.cpp \
engine/mce.cpp \
+ routing/routingservice.cpp \
+ routing/routesegment.cpp \
+ routing/route.cpp \
- map/maprouteitem.cpp
++ map/maprouteitem.cpp \
+ coordinates/scenecoordinate.cpp \
+ coordinates/geocoordinate.cpp \
+ ui/listview.cpp \
+ ui/listitem.cpp \
+ ui/listitemdelegate.cpp \
+ ui/friendlistitemdelegate.cpp
HEADERS += application.h \
common.h \
engine/engine.h \
user/user.h \
ui/fullscreenbutton.h \
engine/mce.h \
+ routing/routingservice.h \
+ routing/routingcommon.h \
+ routing/routesegment.h \
+ routing/route.h \
- map/maprouteitem.h
++ map/maprouteitem.h \
+ map/osm.h \
+ coordinates/scenecoordinate.h \
+ coordinates/geocoordinate.h \
+ ui/listview.h \
+ ui/listitem.h \
+ ui/listitemdelegate.h \
+ ui/friendlistitemdelegate.h \
+ ui/listcommon.h
QT += network \
webkit