diff options
author | Paolo Angelelli <paolo.angelelli@qt.io> | 2016-11-16 17:05:15 +0100 |
---|---|---|
committer | Paolo Angelelli <paolo.angelelli@qt.io> | 2016-12-07 11:59:33 +0000 |
commit | 2906563af414810a71d704db7b4d5f7c882c3667 (patch) | |
tree | 90eaf69e4cc66cd971cbd3667c8de65824b40880 /src/location/maps/qgeotiledmap_p.h | |
parent | 7656821275de8b932c75063adfcdf8deb968db84 (diff) | |
download | qtlocation-2906563af414810a71d704db7b4d5f7c882c3667.tar.gz |
Refactor QGeoMap API: split coordinate <-> itemPosition calls
This patch splits the two calls coordinateToItemPosition and
itemPositionToCoordinate into 3 separate steps:
- coordinate to map projection. Map projection has always to be in [0,1]
[0,1] range.
In case of QGeoTiledMap, the only map projection supported is
WebMercator, thus this call is currently equivalent to
coordinateToMercator.
- wrap map projection. Due to the longitude-wrapping-around nature of
QGeoMap/QDeclarativeGeoMap, coordinates which are greater than others
might end up before the others on the X axis of the projection.
This stage takes care of this aspect
- finally wrapped map projection to item position. this maps a wrapped
coordinate to screen.
Equivalent calls to do the inverse conversion are also provided.
The benefits of splitting the conversion in 3 are:
- possibility to precompute the map projection of item coordinates,
thus having to simply re-wrap them (2 ifs and one sum) upon camera
change.
- Possibility to bake the last step into a 4x4 matrix and offload
this to GPU
- support for rotation and tilting cameras. Without, it would be
impossible to "unwrapBelowX" item coordinates in presence of
rotation and tilt, while now it would be possible to do this before
the final projection to screen that peforms the tilting/rotation.
Change-Id: I9b6a06ff051bbfd09e6d3584485acdcebdceb7bd
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'src/location/maps/qgeotiledmap_p.h')
-rw-r--r-- | src/location/maps/qgeotiledmap_p.h | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/location/maps/qgeotiledmap_p.h b/src/location/maps/qgeotiledmap_p.h index b148b59c..7bb9b210 100644 --- a/src/location/maps/qgeotiledmap_p.h +++ b/src/location/maps/qgeotiledmap_p.h @@ -84,14 +84,23 @@ public: void updateTile(const QGeoTileSpec &spec); void setPrefetchStyle(PrefetchStyle style); - QGeoCoordinate itemPositionToCoordinate(const QDoubleVector2D &pos, bool clipToViewport = true) const Q_DECL_OVERRIDE; - QDoubleVector2D coordinateToItemPosition(const QGeoCoordinate &coordinate, bool clipToViewport = true) const Q_DECL_OVERRIDE; double minimumZoomAtViewportSize(int viewportWidth, int viewportHeight) const Q_DECL_OVERRIDE; double maximumCenterLatitudeAtZoom(double zoomLevel) const Q_DECL_OVERRIDE; + double mapWidth() const Q_DECL_OVERRIDE; + double mapHeight() const Q_DECL_OVERRIDE; + + QDoubleVector2D geoToMapProjection(const QGeoCoordinate &coordinate) const Q_DECL_OVERRIDE; + QGeoCoordinate mapProjectionToGeo(const QDoubleVector2D &projection) const Q_DECL_OVERRIDE; + + QDoubleVector2D wrapMapProjection(const QDoubleVector2D &projection) const Q_DECL_OVERRIDE; + QDoubleVector2D unwrapMapProjection(const QDoubleVector2D &wrappedProjection) const Q_DECL_OVERRIDE; - QDoubleVector2D referenceCoordinateToItemPosition(const QGeoCoordinate &coordinate) const Q_DECL_OVERRIDE; - QGeoCoordinate referenceItemPositionToCoordinate(const QDoubleVector2D &pos) const Q_DECL_OVERRIDE; + QDoubleVector2D wrappedMapProjectionToItemPosition(const QDoubleVector2D &wrappedProjection) const Q_DECL_OVERRIDE; + QDoubleVector2D itemPositionToWrappedMapProjection(const QDoubleVector2D &itemPosition) const Q_DECL_OVERRIDE; + + QGeoCoordinate itemPositionToCoordinate(const QDoubleVector2D &pos, bool clipToViewport = true) const Q_DECL_OVERRIDE; + QDoubleVector2D coordinateToItemPosition(const QGeoCoordinate &coordinate, bool clipToViewport = true) const Q_DECL_OVERRIDE; void prefetchData() Q_DECL_OVERRIDE; void clearData() Q_DECL_OVERRIDE; |