summaryrefslogtreecommitdiffstats
path: root/src/imports/location/qdeclarativepolygonmapitem.cpp
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/qdeclarativepolygonmapitem.cpp
parent45b1f2c23cf0e782c0b99f38e4d01a88da765753 (diff)
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/qdeclarativepolygonmapitem.cpp')
-rw-r--r--src/imports/location/qdeclarativepolygonmapitem.cpp8
1 files changed, 4 insertions, 4 deletions
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();