diff options
author | Paolo Angelelli <paolo.angelelli@qt.io> | 2016-12-11 20:44:17 +0100 |
---|---|---|
committer | Paolo Angelelli <paolo.angelelli@qt.io> | 2017-01-26 14:45:48 +0000 |
commit | c57d42b47004623db9b934d0688180ec6dc1a73e (patch) | |
tree | ba4cd0bb2f332db2ad2ad4d144cc2fa3227f3fc2 /src/imports/location/qgeomapitemgeometry.cpp | |
parent | a33f9131a3f5b07831ea9565cb0dc22e078f9475 (diff) | |
download | qtlocation-c57d42b47004623db9b934d0688180ec6dc1a73e.tar.gz |
Add clipping for rotated/tilted Map Items
This patch adds proper rotation/tilting support to Map Items.
To do so, clipping is now performed in wrapped mercator space
instead of screen space.
This prevents projection of geo coordinates that ended behind
the camera, and that would be projected incorrectly by the
projection transformation.
This patch therefore does not use the screen clipping code
any longer (clipPathToRect), since the geometry has already
been clipped.
The downside is that updateSourcePoints is now necessary for
any viewport change.
This would be necessary anyway in presence of tilt or rotation.
NB: Handling of MapQuickItems with zoomLevel set is still TODO.
Future work:
1) Optimize updateSourcePoints by pre-computing the mercator
projection of the geometry, and let updateSourcePoints do only
the wrapping/clipping/projection-to-screen operations.
2) Remove updateScreenPoints altogether
Change-Id: Ie0d3dbef68d48ac97a596d40240d0ac126c0efaf
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Reviewed-by: Paolo Angelelli <paolo.angelelli@qt.io>
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Diffstat (limited to 'src/imports/location/qgeomapitemgeometry.cpp')
-rw-r--r-- | src/imports/location/qgeomapitemgeometry.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/imports/location/qgeomapitemgeometry.cpp b/src/imports/location/qgeomapitemgeometry.cpp index ab90d0dd..1b7e7d17 100644 --- a/src/imports/location/qgeomapitemgeometry.cpp +++ b/src/imports/location/qgeomapitemgeometry.cpp @@ -100,7 +100,15 @@ QRectF QGeoMapItemGeometry::translateToCommonOrigin(const QList<QGeoMapItemGeome // first get max offset QPointF maxOffset = geoms.at(0)->firstPointOffset(); foreach (QGeoMapItemGeometry *g, geoms) { - Q_ASSERT(g->origin() == origin); +#ifndef QT_NO_DEBUG + //Q_ASSERT(g->origin() == origin); // this might fail on clipper clipping inaccuracies, so better to remove it in production + if (!qFuzzyCompare(origin.latitude(), g->origin().latitude())) { + qWarning("translateToCommonOrigin: Origins differ!"); + } + if (!qFuzzyCompare(origin.longitude(), g->origin().longitude())) { + qWarning("translateToCommonOrigin: Origins differ!"); + } +#endif QPointF o = g->firstPointOffset(); maxOffset.setX(qMax(o.x(), maxOffset.x())); maxOffset.setY(qMax(o.y(), maxOffset.y())); |