summaryrefslogtreecommitdiff
path: root/src/imports/location
diff options
context:
space:
mode:
authorPaolo Angelelli <paolo.angelelli@qt.io>2016-12-02 18:22:12 +0100
committerPaolo Angelelli <paolo.angelelli@qt.io>2017-01-16 16:18:27 +0000
commit762dc9dd2b47f908c3739173aa1e108dd7386717 (patch)
tree201747076f1ee6deda535a6e58cafc4edaa37cbe /src/imports/location
parent45b1f2c23cf0e782c0b99f38e4d01a88da765753 (diff)
downloadqtlocation-762dc9dd2b47f908c3739173aa1e108dd7386717.tar.gz
Move the coordinate <-> item position conversion to QGeoProjection
This patch simplifies the QGeoMap API removing all the API necessary to convert to and from screen. This is now demanded to a specific QGeoProjection class, that will be independent of the map, except for using the same Geo projection (currently only WebMercator, or EPSG:3857, although we use a sphere instead of an ellipsoid, i believe) The benefits are - This relieves subclasses of QGeoMap from implementing a GeoProjection API, especially since QtLocation currently supports only WebMercator, and reimplementations would have to anyway produce the same results as the inbuilt one. - This avoids the several indirection steps previously necessary to perform a map projection (qgeotiledmap -> private->mapscene-> private). Since these operation are quite frequent one per map item coordinate at every redraw, shortening the indirection chain is beneficial - It simplifies the highly complex QGeoTiledMapScene, separating all the logic that is not needed to draw the scene, but only to perform geo coordinate <-> screen coordinate conversion Change-Id: I9e3ca5280166f2d6430a32deb44c030d02d9d4e1 Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'src/imports/location')
-rw-r--r--src/imports/location/qdeclarativecirclemapitem.cpp16
-rw-r--r--src/imports/location/qdeclarativegeomap.cpp26
-rw-r--r--src/imports/location/qdeclarativegeomapitembase.cpp2
-rw-r--r--src/imports/location/qdeclarativegeomapquickitem.cpp2
-rw-r--r--src/imports/location/qdeclarativepolygonmapitem.cpp8
-rw-r--r--src/imports/location/qdeclarativepolylinemapitem.cpp8
-rw-r--r--src/imports/location/qdeclarativerectanglemapitem.cpp8
-rw-r--r--src/imports/location/qgeomapitemgeometry.cpp4
-rw-r--r--src/imports/location/qquickgeomapgesturearea.cpp22
9 files changed, 49 insertions, 47 deletions
diff --git a/src/imports/location/qdeclarativecirclemapitem.cpp b/src/imports/location/qdeclarativecirclemapitem.cpp
index 077ba385..e107091c 100644
--- a/src/imports/location/qdeclarativecirclemapitem.cpp
+++ b/src/imports/location/qdeclarativecirclemapitem.cpp
@@ -150,7 +150,7 @@ void QGeoMapCircleGeometry::updateScreenPointsInvert(const QGeoMap &map)
return;
}
- QPointF origin = map.coordinateToItemPosition(srcOrigin_, false).toPointF();
+ QPointF origin = map.geoProjection().coordinateToItemPosition(srcOrigin_, false).toPointF();
QPainterPath ppi = srcPath_;
@@ -169,9 +169,9 @@ void QGeoMapCircleGeometry::updateScreenPointsInvert(const QGeoMap &map)
// calculate actual width of map on screen in pixels
QGeoCoordinate mapCenter(0, map.cameraData().center().longitude());
- QDoubleVector2D midPoint = map.coordinateToItemPosition(mapCenter, false);
+ QDoubleVector2D midPoint = map.geoProjection().coordinateToItemPosition(mapCenter, false);
QDoubleVector2D midPointPlusOne = QDoubleVector2D(midPoint.x() + 1.0, midPoint.y());
- QGeoCoordinate coord1 = map.itemPositionToCoordinate(midPointPlusOne, false);
+ QGeoCoordinate coord1 = map.geoProjection().itemPositionToCoordinate(midPointPlusOne, false);
double geoDistance = coord1.longitude() - map.cameraData().center().longitude();
if ( geoDistance < 0 )
geoDistance += 360.0;
@@ -568,7 +568,7 @@ void QDeclarativeCircleMapItem::geometryChanged(const QRectF &newGeometry, const
}
QDoubleVector2D newPoint = QDoubleVector2D(x(),y()) + QDoubleVector2D(width(), height()) / 2;
- QGeoCoordinate newCoordinate = map()->itemPositionToCoordinate(newPoint, false);
+ QGeoCoordinate newCoordinate = map()->geoProjection().itemPositionToCoordinate(newPoint, false);
if (newCoordinate.isValid())
setCenter(newCoordinate);
@@ -603,19 +603,19 @@ void QDeclarativeCircleMapItem::updateCirclePathForRendering(QList<QGeoCoordinat
return;
QList<int> wrapPathIndex;
// calculate actual width of map on screen in pixels
- QDoubleVector2D midPoint = map()->coordinateToItemPosition(map()->cameraData().center(), false);
+ QDoubleVector2D midPoint = map()->geoProjection().coordinateToItemPosition(map()->cameraData().center(), false);
QDoubleVector2D midPointPlusOne(midPoint.x() + 1.0, midPoint.y());
- QGeoCoordinate coord1 = map()->itemPositionToCoordinate(midPointPlusOne, false);
+ QGeoCoordinate coord1 = map()->geoProjection().itemPositionToCoordinate(midPointPlusOne, false);
qreal geoDistance = coord1.longitude() - map()->cameraData().center().longitude();
if ( geoDistance < 0 )
geoDistance += 360;
qreal mapWidth = 360.0 / geoDistance;
mapWidth = qMin(static_cast<int>(mapWidth), map()->viewportWidth());
- QDoubleVector2D prev = map()->coordinateToItemPosition(path.at(0), false);
+ QDoubleVector2D prev = map()->geoProjection().coordinateToItemPosition(path.at(0), false);
// find the points in path where wrapping occurs
for (int i = 1; i <= path.count(); ++i) {
int index = i % path.count();
- QDoubleVector2D point = map()->coordinateToItemPosition(path.at(index), false);
+ QDoubleVector2D point = map()->geoProjection().coordinateToItemPosition(path.at(index), false);
if ( (qAbs(point.x() - prev.x())) >= mapWidth/2.0 ) {
wrapPathIndex << index;
if (wrapPathIndex.size() == 2 || !(crossNorthPole && crossSouthPole))
diff --git a/src/imports/location/qdeclarativegeomap.cpp b/src/imports/location/qdeclarativegeomap.cpp
index 761fcdc5..d19f6929 100644
--- a/src/imports/location/qdeclarativegeomap.cpp
+++ b/src/imports/location/qdeclarativegeomap.cpp
@@ -311,7 +311,7 @@ void QDeclarativeGeoMap::initialize()
// try to keep center change signal in the end
bool centerHasChanged = false;
- setMinimumZoomLevel(m_map->minimumZoomAtViewportSize(width(), height()));
+ setMinimumZoomLevel(m_map->minimumZoom());
// set latitude bundary check
m_maximumViewportLatitude = m_map->maximumCenterLatitudeAtZoom(m_cameraData.zoomLevel());
@@ -638,8 +638,9 @@ void QDeclarativeGeoMap::setMinimumZoomLevel(qreal minimumZoomLevel)
qreal oldMinimumZoomLevel = this->minimumZoomLevel();
if (m_map) {
+
minimumZoomLevel = qBound(qreal(m_map->cameraCapabilities().minimumZoomLevelAt256()), minimumZoomLevel, maximumZoomLevel());
- double minimumViewportZoomLevel = m_map->minimumZoomAtViewportSize(width(),height());
+ double minimumViewportZoomLevel = m_map->minimumZoom();
if (minimumZoomLevel < minimumViewportZoomLevel)
minimumZoomLevel = minimumViewportZoomLevel;
}
@@ -840,8 +841,8 @@ QGeoShape QDeclarativeGeoMap::visibleRegion() const
if (!m_map || !width() || !height())
return m_region;
- QGeoCoordinate tl = m_map->itemPositionToCoordinate(QDoubleVector2D(0, 0));
- QGeoCoordinate br = m_map->itemPositionToCoordinate(QDoubleVector2D(width(), height()));
+ QGeoCoordinate tl = m_map->geoProjection().itemPositionToCoordinate(QDoubleVector2D(0, 0));
+ QGeoCoordinate br = m_map->geoProjection().itemPositionToCoordinate(QDoubleVector2D(width(), height()));
return QGeoRectangle(tl, br);
}
@@ -967,8 +968,8 @@ void QDeclarativeGeoMap::fitViewportToGeoShape()
return;
}
- QDoubleVector2D topLeftPoint = m_map->geoToMapProjection(topLeft);
- QDoubleVector2D bottomRightPoint = m_map->geoToMapProjection(bottomRight);
+ QDoubleVector2D topLeftPoint = m_map->geoProjection().geoToMapProjection(topLeft);
+ QDoubleVector2D bottomRightPoint = m_map->geoProjection().geoToMapProjection(bottomRight);
if (bottomRightPoint.x() < topLeftPoint.x()) // crossing the dateline
bottomRightPoint.setX(bottomRightPoint.x() + 1.0);
@@ -981,7 +982,7 @@ void QDeclarativeGeoMap::fitViewportToGeoShape()
// find center of the bounding box
QDoubleVector2D center = (topLeftPoint + bottomRightPoint) * 0.5;
center.setX(center.x() > 1.0 ? center.x() - 1.0 : center.x());
- QGeoCoordinate centerCoordinate = m_map->mapProjectionToGeo(center);
+ QGeoCoordinate centerCoordinate = m_map->geoProjection().mapProjectionToGeo(center);
// position camera to the center of bounding box
setCenter(centerCoordinate);
@@ -1023,7 +1024,7 @@ QQmlListProperty<QDeclarativeGeoMapType> QDeclarativeGeoMap::supportedMapTypes()
QGeoCoordinate QDeclarativeGeoMap::toCoordinate(const QPointF &position, bool clipToViewPort) const
{
if (m_map)
- return m_map->itemPositionToCoordinate(QDoubleVector2D(position), clipToViewPort);
+ return m_map->geoProjection().itemPositionToCoordinate(QDoubleVector2D(position), clipToViewPort);
else
return QGeoCoordinate();
}
@@ -1039,7 +1040,7 @@ QGeoCoordinate QDeclarativeGeoMap::toCoordinate(const QPointF &position, bool cl
QPointF QDeclarativeGeoMap::fromCoordinate(const QGeoCoordinate &coordinate, bool clipToViewPort) const
{
if (m_map)
- return m_map->coordinateToItemPosition(coordinate, clipToViewPort).toPointF();
+ return m_map->geoProjection().coordinateToItemPosition(coordinate, clipToViewPort).toPointF();
else
return QPointF(qQNaN(), qQNaN());
}
@@ -1061,7 +1062,8 @@ void QDeclarativeGeoMap::pan(int dx, int dy)
return;
if (dx == 0 && dy == 0)
return;
- QGeoCoordinate coord = m_map->itemPositionToCoordinate(
+
+ QGeoCoordinate coord = m_map->geoProjection().itemPositionToCoordinate(
QDoubleVector2D(m_map->viewportWidth() / 2 + dx,
m_map->viewportHeight() / 2 + dy));
setCenter(coord);
@@ -1428,7 +1430,7 @@ void QDeclarativeGeoMap::geometryChanged(const QRectF &newGeometry, const QRectF
if (!m_initialized) {
initialize();
} else {
- setMinimumZoomLevel(m_map->minimumZoomAtViewportSize(newGeometry.width(), newGeometry.height()));
+ setMinimumZoomLevel(m_map->minimumZoom());
// Update the center latitudinal threshold
double maximumCenterLatitudeAtZoom = m_map->maximumCenterLatitudeAtZoom(m_cameraData.zoomLevel());
@@ -1548,7 +1550,7 @@ void QDeclarativeGeoMap::fitViewportToMapItemsRefine(bool refine)
// position camera to the center of bounding box
QGeoCoordinate coordinate;
- coordinate = m_map->itemPositionToCoordinate(QDoubleVector2D(bboxCenterX, bboxCenterY), false);
+ coordinate = m_map->geoProjection().itemPositionToCoordinate(QDoubleVector2D(bboxCenterX, bboxCenterY), false);
setProperty("center", QVariant::fromValue(coordinate));
// adjust zoom
diff --git a/src/imports/location/qdeclarativegeomapitembase.cpp b/src/imports/location/qdeclarativegeomapitembase.cpp
index b4ba761d..84bf757d 100644
--- a/src/imports/location/qdeclarativegeomapitembase.cpp
+++ b/src/imports/location/qdeclarativegeomapitembase.cpp
@@ -177,7 +177,7 @@ void QDeclarativeGeoMapItemBase::setPositionOnMap(const QGeoCoordinate &coordina
if (!map_ || !quickMap_)
return;
- QPointF topLeft = map_->coordinateToItemPosition(coordinate, false).toPointF() - offset;
+ QPointF topLeft = map_->geoProjection().coordinateToItemPosition(coordinate, false).toPointF() - offset;
setPosition(topLeft);
}
diff --git a/src/imports/location/qdeclarativegeomapquickitem.cpp b/src/imports/location/qdeclarativegeomapquickitem.cpp
index 41f2a821..78fd4f8f 100644
--- a/src/imports/location/qdeclarativegeomapquickitem.cpp
+++ b/src/imports/location/qdeclarativegeomapquickitem.cpp
@@ -174,7 +174,7 @@ void QDeclarativeGeoMapQuickItem::geometryChanged(const QRectF &newGeometry, con
return;
}
- QGeoCoordinate newCoordinate = map()->itemPositionToCoordinate(QDoubleVector2D(x(), y()) + (scaleFactor() * QDoubleVector2D(anchorPoint_)), false);
+ QGeoCoordinate newCoordinate = map()->geoProjection().itemPositionToCoordinate(QDoubleVector2D(x(), y()) + (scaleFactor() * QDoubleVector2D(anchorPoint_)), false);
if (newCoordinate.isValid())
setCoordinate(newCoordinate);
diff --git a/src/imports/location/qdeclarativepolygonmapitem.cpp b/src/imports/location/qdeclarativepolygonmapitem.cpp
index ee603f8c..0e11db79 100644
--- a/src/imports/location/qdeclarativepolygonmapitem.cpp
+++ b/src/imports/location/qdeclarativepolygonmapitem.cpp
@@ -157,7 +157,7 @@ void QGeoMapPolygonGeometry::updateSourcePoints(const QGeoMap &map,
double unwrapBelowX = 0;
if (preserveGeometry_ )
- unwrapBelowX = map.coordinateToItemPosition(geoLeftBound_, false).x();
+ unwrapBelowX = map.geoProjection().coordinateToItemPosition(geoLeftBound_, false).x();
for (int i = 0; i < path.size(); ++i) {
const QGeoCoordinate &coord = path.at(i);
@@ -165,7 +165,7 @@ void QGeoMapPolygonGeometry::updateSourcePoints(const QGeoMap &map,
if (!coord.isValid())
continue;
- QDoubleVector2D point = map.coordinateToItemPosition(coord, false);
+ QDoubleVector2D point = map.geoProjection().coordinateToItemPosition(coord, false);
// We can get NaN if the map isn't set up correctly, or the projection
// is faulty -- probably best thing to do is abort
@@ -213,7 +213,7 @@ void QGeoMapPolygonGeometry::updateScreenPoints(const QGeoMap &map)
return;
}
- QDoubleVector2D origin = map.coordinateToItemPosition(srcOrigin_, false);
+ QDoubleVector2D origin = map.geoProjection().coordinateToItemPosition(srcOrigin_, false);
// Create the viewport rect in the same coordinate system
// as the actual points
@@ -613,7 +613,7 @@ void QDeclarativePolygonMapItem::geometryChanged(const QRectF &newGeometry, cons
}
QDoubleVector2D newPoint = QDoubleVector2D(x(),y()) + QDoubleVector2D(geometry_.firstPointOffset());
- QGeoCoordinate newCoordinate = map()->itemPositionToCoordinate(newPoint, false);
+ QGeoCoordinate newCoordinate = map()->geoProjection().itemPositionToCoordinate(newPoint, false);
if (newCoordinate.isValid()) {
double firstLongitude = path_.at(0).longitude();
double firstLatitude = path_.at(0).latitude();
diff --git a/src/imports/location/qdeclarativepolylinemapitem.cpp b/src/imports/location/qdeclarativepolylinemapitem.cpp
index 623629dc..5fe0535d 100644
--- a/src/imports/location/qdeclarativepolylinemapitem.cpp
+++ b/src/imports/location/qdeclarativepolylinemapitem.cpp
@@ -205,7 +205,7 @@ void QGeoMapPolylineGeometry::updateSourcePoints(const QGeoMap &map,
const double mapWidthHalf = map.viewportWidth()/2.0;
double unwrapBelowX = 0;
if (preserveGeometry_)
- unwrapBelowX = map.coordinateToItemPosition(geoLeftBound_, false).x();
+ unwrapBelowX = map.geoProjection().coordinateToItemPosition(geoLeftBound_, false).x();
for (int i = 0; i < path.size(); ++i) {
const QGeoCoordinate &coord = path.at(i);
@@ -213,7 +213,7 @@ void QGeoMapPolylineGeometry::updateSourcePoints(const QGeoMap &map,
if (!coord.isValid())
continue;
- QDoubleVector2D point = map.coordinateToItemPosition(coord, false);
+ QDoubleVector2D point = map.geoProjection().coordinateToItemPosition(coord, false);
// We can get NaN if the map isn't set up correctly, or the projection
// is faulty -- probably best thing to do is abort
@@ -391,7 +391,7 @@ void QGeoMapPolylineGeometry::updateScreenPoints(const QGeoMap &map,
if (!screenDirty_)
return;
- QPointF origin = map.coordinateToItemPosition(srcOrigin_, false).toPointF();
+ QPointF origin = map.geoProjection().coordinateToItemPosition(srcOrigin_, false).toPointF();
if (!qIsFinite(origin.x()) || !qIsFinite(origin.y())) {
clear();
@@ -825,7 +825,7 @@ void QDeclarativePolylineMapItem::geometryChanged(const QRectF &newGeometry, con
}
QDoubleVector2D newPoint = QDoubleVector2D(x(),y()) + QDoubleVector2D(geometry_.firstPointOffset());
- QGeoCoordinate newCoordinate = map()->itemPositionToCoordinate(newPoint, false);
+ QGeoCoordinate newCoordinate = map()->geoProjection().itemPositionToCoordinate(newPoint, false);
if (newCoordinate.isValid()) {
double firstLongitude = path_.at(0).longitude();
double firstLatitude = path_.at(0).latitude();
diff --git a/src/imports/location/qdeclarativerectanglemapitem.cpp b/src/imports/location/qdeclarativerectanglemapitem.cpp
index f50d0340..b91c4c08 100644
--- a/src/imports/location/qdeclarativerectanglemapitem.cpp
+++ b/src/imports/location/qdeclarativerectanglemapitem.cpp
@@ -131,8 +131,8 @@ void QGeoMapRectangleGeometry::updatePoints(const QGeoMap &map,
if (!screenDirty_ && !sourceDirty_)
return;
- QDoubleVector2D tl = map.coordinateToItemPosition(topLeft, false);
- QDoubleVector2D br = map.coordinateToItemPosition(bottomRight, false);
+ QDoubleVector2D tl = map.geoProjection().coordinateToItemPosition(topLeft, false);
+ QDoubleVector2D br = map.geoProjection().coordinateToItemPosition(bottomRight, false);
// We can get NaN if the map isn't set up correctly, or the projection
// is faulty -- probably best thing to do is abort
@@ -142,7 +142,7 @@ void QGeoMapRectangleGeometry::updatePoints(const QGeoMap &map,
return;
if ( preserveGeometry_ ) {
- double unwrapBelowX = map.coordinateToItemPosition(geoLeftBound_, false).x();
+ double unwrapBelowX = map.geoProjection().coordinateToItemPosition(geoLeftBound_, false).x();
if (br.x() < unwrapBelowX)
br.setX(tl.x() + screenBounds_.width());
}
@@ -418,7 +418,7 @@ void QDeclarativeRectangleMapItem::geometryChanged(const QRectF &newGeometry, co
}
QDoubleVector2D newTopLeftPoint = QDoubleVector2D(x(),y());
- QGeoCoordinate newTopLeft = map()->itemPositionToCoordinate(newTopLeftPoint, false);
+ QGeoCoordinate newTopLeft = map()->geoProjection().itemPositionToCoordinate(newTopLeftPoint, false);
if (newTopLeft.isValid()) {
// calculate new geo width while checking for dateline crossing
const double lonW = bottomRight_.longitude() > topLeft_.longitude() ?
diff --git a/src/imports/location/qgeomapitemgeometry.cpp b/src/imports/location/qgeomapitemgeometry.cpp
index a22be0af..ab90d0dd 100644
--- a/src/imports/location/qgeomapitemgeometry.cpp
+++ b/src/imports/location/qgeomapitemgeometry.cpp
@@ -125,14 +125,14 @@ double QGeoMapItemGeometry::geoDistanceToScreenWidth(const QGeoMap &map,
// Do not wrap around half the globe
Q_ASSERT(!qFuzzyCompare(fromCoord.longitude(), toCoord.longitude()));
- QGeoCoordinate mapMid = map.itemPositionToCoordinate(QDoubleVector2D(map.viewportWidth()/2.0, 0));
+ QGeoCoordinate mapMid = map.geoProjection().itemPositionToCoordinate(QDoubleVector2D(map.viewportWidth()/2.0, 0));
double halfGeoDist = toCoord.longitude() - fromCoord.longitude();
if (toCoord.longitude() < fromCoord.longitude())
halfGeoDist += 360;
halfGeoDist /= 2.0;
QGeoCoordinate geoDelta = QGeoCoordinate(0,
QLocationUtils::wrapLong(mapMid.longitude() + halfGeoDist));
- QDoubleVector2D halfScreenDist = map.coordinateToItemPosition(geoDelta, false)
+ QDoubleVector2D halfScreenDist = map.geoProjection().coordinateToItemPosition(geoDelta, false)
- QDoubleVector2D(map.viewportWidth()/2.0, 0);
return halfScreenDist.x() * 2.0;
}
diff --git a/src/imports/location/qquickgeomapgesturearea.cpp b/src/imports/location/qquickgeomapgesturearea.cpp
index fe5a04dd..50709292 100644
--- a/src/imports/location/qquickgeomapgesturearea.cpp
+++ b/src/imports/location/qquickgeomapgesturearea.cpp
@@ -691,12 +691,12 @@ void QQuickGeoMapGestureArea::handleWheelEvent(QWheelEvent *event)
if (!m_map)
return;
- QGeoCoordinate wheelGeoPos = m_map->itemPositionToCoordinate(QDoubleVector2D(event->posF()), false);
- QPointF preZoomPoint = m_map->coordinateToItemPosition(wheelGeoPos, false).toPointF();
+ QGeoCoordinate wheelGeoPos = m_map->geoProjection().itemPositionToCoordinate(QDoubleVector2D(event->posF()), false);
+ QPointF preZoomPoint = m_map->geoProjection().coordinateToItemPosition(wheelGeoPos, false).toPointF();
double zoomLevelDelta = event->angleDelta().y() * qreal(0.001);
m_declarativeMap->setZoomLevel(m_declarativeMap->zoomLevel() + zoomLevelDelta);
- QPointF postZoomPoint = m_map->coordinateToItemPosition(wheelGeoPos, false).toPointF();
+ QPointF postZoomPoint = m_map->geoProjection().coordinateToItemPosition(wheelGeoPos, false).toPointF();
if (preZoomPoint != postZoomPoint)
{
@@ -704,7 +704,7 @@ void QQuickGeoMapGestureArea::handleWheelEvent(QWheelEvent *event)
qreal dy = postZoomPoint.y() - preZoomPoint.y();
QPointF mapCenterPoint(m_map->viewportWidth() / 2.0 + dx, m_map->viewportHeight() / 2.0 + dy);
- QGeoCoordinate mapCenterCoordinate = m_map->itemPositionToCoordinate(QDoubleVector2D(mapCenterPoint), false);
+ QGeoCoordinate mapCenterCoordinate = m_map->geoProjection().itemPositionToCoordinate(QDoubleVector2D(mapCenterPoint), false);
m_declarativeMap->setCenter(mapCenterCoordinate);
}
event->accept();
@@ -810,7 +810,7 @@ void QQuickGeoMapGestureArea::touchPointStateMachine()
if (m_allPoints.count() == 0) {
m_touchPointState = touchPoints0;
} else if (m_allPoints.count() == 2) {
- m_touchCenterCoord = m_map->itemPositionToCoordinate(QDoubleVector2D(m_sceneCenter), false);
+ m_touchCenterCoord = m_map->geoProjection().itemPositionToCoordinate(QDoubleVector2D(m_sceneCenter), false);
startTwoTouchPoints();
m_touchPointState = touchPoints2;
}
@@ -819,7 +819,7 @@ void QQuickGeoMapGestureArea::touchPointStateMachine()
if (m_allPoints.count() == 0) {
m_touchPointState = touchPoints0;
} else if (m_allPoints.count() == 1) {
- m_touchCenterCoord = m_map->itemPositionToCoordinate(QDoubleVector2D(m_sceneCenter), false);
+ m_touchCenterCoord = m_map->geoProjection().itemPositionToCoordinate(QDoubleVector2D(m_sceneCenter), false);
startOneTouchPoint();
m_touchPointState = touchPoints1;
}
@@ -847,7 +847,7 @@ void QQuickGeoMapGestureArea::startOneTouchPoint()
m_sceneStartPoint1 = mapFromScene(m_allPoints.at(0).scenePos());
m_lastPos = m_sceneStartPoint1;
m_lastPosTime.start();
- QGeoCoordinate startCoord = m_map->itemPositionToCoordinate(QDoubleVector2D(m_sceneStartPoint1), false);
+ QGeoCoordinate startCoord = m_map->geoProjection().itemPositionToCoordinate(QDoubleVector2D(m_sceneStartPoint1), false);
// ensures a smooth transition for panning
m_startCoord.setLongitude(m_startCoord.longitude() + startCoord.longitude() -
m_touchCenterCoord.longitude());
@@ -875,7 +875,7 @@ void QQuickGeoMapGestureArea::startTwoTouchPoints()
QPointF startPos = (m_sceneStartPoint1 + m_sceneStartPoint2) * 0.5;
m_lastPos = startPos;
m_lastPosTime.start();
- QGeoCoordinate startCoord = m_map->itemPositionToCoordinate(QDoubleVector2D(startPos), false);
+ QGeoCoordinate startCoord = m_map->geoProjection().itemPositionToCoordinate(QDoubleVector2D(startPos), false);
m_startCoord.setLongitude(m_startCoord.longitude() + startCoord.longitude() -
m_touchCenterCoord.longitude());
m_startCoord.setLatitude(m_startCoord.latitude() + startCoord.latitude() -
@@ -1070,7 +1070,7 @@ void QQuickGeoMapGestureArea::panStateMachine()
case flickInactive:
if (canStartPan()) {
// Update startCoord_ to ensure smooth start for panning when going over startDragDistance
- QGeoCoordinate newStartCoord = m_map->itemPositionToCoordinate(QDoubleVector2D(m_sceneCenter), false);
+ QGeoCoordinate newStartCoord = m_map->geoProjection().itemPositionToCoordinate(QDoubleVector2D(m_sceneCenter), false);
m_startCoord.setLongitude(newStartCoord.longitude());
m_startCoord.setLatitude(newStartCoord.latitude());
m_declarativeMap->setKeepMouseGrab(true);
@@ -1145,13 +1145,13 @@ bool QQuickGeoMapGestureArea::canStartPan()
*/
void QQuickGeoMapGestureArea::updatePan()
{
- QPointF startPoint = m_map->coordinateToItemPosition(m_startCoord, false).toPointF();
+ QPointF startPoint = m_map->geoProjection().coordinateToItemPosition(m_startCoord, false).toPointF();
int dx = static_cast<int>(m_sceneCenter.x() - startPoint.x());
int dy = static_cast<int>(m_sceneCenter.y() - startPoint.y());
QPointF mapCenterPoint;
mapCenterPoint.setY(m_map->viewportHeight() / 2.0 - dy);
mapCenterPoint.setX(m_map->viewportWidth() / 2.0 - dx);
- QGeoCoordinate animationStartCoordinate = m_map->itemPositionToCoordinate(QDoubleVector2D(mapCenterPoint), false);
+ QGeoCoordinate animationStartCoordinate = m_map->geoProjection().itemPositionToCoordinate(QDoubleVector2D(mapCenterPoint), false);
m_declarativeMap->setCenter(animationStartCoordinate);
}