diff options
author | Michal Klocek <michal.klocek@theqtcompany.com> | 2016-06-27 08:33:20 +0200 |
---|---|---|
committer | Alex Blasche <alexander.blasche@qt.io> | 2016-07-28 08:08:04 +0000 |
commit | cd12d3c8eaf1c1a3dabfb50f88c635b9b1def3fc (patch) | |
tree | b5d196b1019b8d90c00b0c919c1cfb9180b5561a /src/location/maps/qgeotiledmap.cpp | |
parent | 04762a9eecafc80ebeb90c06258de551d451497f (diff) | |
download | qtlocation-cd12d3c8eaf1c1a3dabfb50f88c635b9b1def3fc.tar.gz |
Fix the fitViewportToGeoShape calculation
The current implementation is calculating the bounding box of
a geocircle based on moving along a circle of latitude by the
distance of a circle's radius. Unfortunately the distances
on a small circle of a sphere are greater than great circle
distances. Reimplement the calculation using tangential
points between a geocircle and meridians.
Do not center the viewport in the center of the geoshape,
use the center of the bounding box instead.
Simplify zoom level adjustment calculations, use the reference
world plane to get rid of longitude wrapping and rounding
erros.
Finally update a viewport unit test, adjust the minimum map
size to 256x256, so fitToViewport calls have chance to succeed.
Fix out of order test execution.
Task-number: QTBUG-54337
Change-Id: I61726a4eb7183470c493ceb03d101f3a75305121
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'src/location/maps/qgeotiledmap.cpp')
-rw-r--r-- | src/location/maps/qgeotiledmap.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/location/maps/qgeotiledmap.cpp b/src/location/maps/qgeotiledmap.cpp index 97747049..869a6f08 100644 --- a/src/location/maps/qgeotiledmap.cpp +++ b/src/location/maps/qgeotiledmap.cpp @@ -154,6 +154,20 @@ QDoubleVector2D QGeoTiledMap::coordinateToItemPosition(const QGeoCoordinate &coo return pos; } +QDoubleVector2D QGeoTiledMap::referenceCoordinateToItemPosition(const QGeoCoordinate &coordinate) const +{ + Q_D(const QGeoTiledMap); + QDoubleVector2D point = QGeoProjection::coordToMercator(coordinate); + return point * std::pow(2.0, d->m_cameraData.zoomLevel()) * d->m_cameraTiles->tileSize(); +} + +QGeoCoordinate QGeoTiledMap::referenceItemPositionToCoordinate(const QDoubleVector2D &pos) const +{ + Q_D(const QGeoTiledMap); + QDoubleVector2D point = pos / (std::pow(2.0, d->m_cameraData.zoomLevel()) * d->m_cameraTiles->tileSize()); + return QGeoProjection::mercatorToCoord(point); +} + QGeoTiledMapPrivate::QGeoTiledMapPrivate(QGeoTiledMappingManagerEngine *engine) : QGeoMapPrivate(engine), m_cache(engine->tileCache()), |