summaryrefslogtreecommitdiff
path: root/src/location/maps/qgeomap_p.h
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/location/maps/qgeomap_p.h
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/location/maps/qgeomap_p.h')
-rw-r--r--src/location/maps/qgeomap_p.h28
1 files changed, 8 insertions, 20 deletions
diff --git a/src/location/maps/qgeomap_p.h b/src/location/maps/qgeomap_p.h
index 09da93b4..b5e51014 100644
--- a/src/location/maps/qgeomap_p.h
+++ b/src/location/maps/qgeomap_p.h
@@ -51,6 +51,7 @@
#include <QtLocation/private/qgeomaptype_p.h>
#include <QtCore/QObject>
#include <QtPositioning/private/qdoublevector2d_p.h>
+#include <QtLocation/private/qgeoprojection_p.h>
QT_BEGIN_NAMESPACE
@@ -84,28 +85,15 @@ public:
void setActiveMapType(const QGeoMapType mapType);
const QGeoMapType activeMapType() const;
- virtual double minimumZoomAtViewportSize(int viewportWidth, int viewportHeight) const = 0;
- virtual double maximumCenterLatitudeAtZoom(double zoomLevel) const = 0;
+ // returns the minimum zoom at the current viewport size
+ double minimumZoom() const;
+ double maximumCenterLatitudeAtZoom(double zoomLevel) const;
- // The size of the underlying map, at the current zoom level. Unrelated to width()/height()/size().
- virtual double mapWidth() const = 0;
- virtual double mapHeight() const = 0;
+ // returns the size of the underlying map, at the current zoom level. Unrelated to width()/height()/size().
+ double mapWidth() const;
+ double mapHeight() const;
- // Conversion methods for QGeoCoordinate <-> screen.
- // This currently assumes that the "MapProjection" space is [0, 1][0, 1] for every type of possibly supported map projection
- virtual QDoubleVector2D geoToMapProjection(const QGeoCoordinate &coordinate) const = 0;
- virtual QGeoCoordinate mapProjectionToGeo(const QDoubleVector2D &projection) const = 0;
-
- virtual QDoubleVector2D wrapMapProjection(const QDoubleVector2D &projection) const = 0;
- virtual QDoubleVector2D unwrapMapProjection(const QDoubleVector2D &wrappedProjection) const = 0;
-
- virtual QDoubleVector2D wrappedMapProjectionToItemPosition(const QDoubleVector2D &wrappedProjection) const = 0;
- virtual QDoubleVector2D itemPositionToWrappedMapProjection(const QDoubleVector2D &itemPosition) const = 0;
-
- // Convenience methods to avoid the chain itemPositionToWrappedProjection(wrapProjection(geoToProjection()))
- // These also come with a default implementation that can, however, be overridden.
- virtual QGeoCoordinate itemPositionToCoordinate(const QDoubleVector2D &pos, bool clipToViewport = true) const;
- virtual QDoubleVector2D coordinateToItemPosition(const QGeoCoordinate &coordinate, bool clipToViewport = true) const;
+ const QGeoProjection &geoProjection() const;
virtual void prefetchData();
virtual void clearData();