* @param parent Parent
*/
MapEngine(QObject *parent = 0);
+
+ /**
+ * @brief MapEngine initializer
+ *
+ * Set initial location and zoom level for the engine. locationChanged and
+ * zoomLevelChanged signals are emitted, so init should be called after
+ * those signals are connected to MapView.
+ */
+ void init();
/**
* @brief Convert tile x & y numbers to MapScene coordinates
QGraphicsScene* scene();
/**
- * @brief Set view location
+ * @brief Helper for setting view location based on latitude and longitude
+ * coordinates
*
* @param latLonCoordinate Latitude & longitude coordinates for location
*/
* @param latLonCoordinate latitude and longitude values
* @return QPoint tile x,y value
*/
- static QPoint convertLatLonToTile(int zoomLevel, QPointF latLonCoordinate)
+ static QPointF convertLatLonToSceneCoordinate(QPointF latLonCoordinate)
{
+ /// @todo CREATE TEST CASE & CHECK CALCULATION
qDebug() << __PRETTY_FUNCTION__;
qreal longitude = latLonCoordinate.x();
qreal latitude = latLonCoordinate.y();
- if ((zoomLevel > MAX_ZOOM_LEVEL) || (zoomLevel < MIN_ZOOM_LEVEL))
- return QPoint(UNDEFINED, UNDEFINED);
if ((longitude > MAX_LONGITUDE) || (longitude < MIN_LONGITUDE))
return QPoint(UNDEFINED, UNDEFINED);
if ((latitude > MAX_LATITUDE) || (latitude < MIN_LATITUDE))
return QPoint(UNDEFINED, UNDEFINED);
- qreal z = static_cast<qreal>(1 << zoomLevel);
+ qreal z = static_cast<qreal>(1 << 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 QPoint(qFloor(x*z), qFloor(y*z));
+ return QPointF(x*z*TILE_SIZE_X, y*z*TILE_SIZE_Y);
}
private: