summaryrefslogtreecommitdiff
path: root/src/location/maps/qgeocameratiles.cpp
diff options
context:
space:
mode:
authorPaolo Angelelli <paolo.angelelli@qt.io>2018-11-11 14:16:49 +0100
committerPaolo Angelelli <paolo.angelelli@qt.io>2018-11-28 18:45:36 +0000
commitbe0658bfdb37de213f6b54837706aabc2d088d62 (patch)
tree99444eee90e4e69e787289c280218d2474f787aa /src/location/maps/qgeocameratiles.cpp
parent9307404d2dcb0b53d0dfcad6c28677cc2aba4a12 (diff)
downloadqtlocation-be0658bfdb37de213f6b54837706aabc2d088d62.tar.gz
Make tiled renderer and QGeoProjectionWebMercator debuggable
This patch introduces a new macro, QT_LOCATION_DEBUG, that, when fed via qmake command line, changes the scope of some members, adds some extra members and some extra data dumping into these members. In this way external code can inspect the state of the renderer in order to debug it. The patch also moves a few classes into separate files, as well as privately exporting them. Change-Id: I32a042863f78dcd10f94b0b7fe8b90f3fc486891 Reviewed-by: Paolo Angelelli <paolo.angelelli@qt.io>
Diffstat (limited to 'src/location/maps/qgeocameratiles.cpp')
-rw-r--r--src/location/maps/qgeocameratiles.cpp90
1 files changed, 19 insertions, 71 deletions
diff --git a/src/location/maps/qgeocameratiles.cpp b/src/location/maps/qgeocameratiles.cpp
index b7eac306..3a2732b2 100644
--- a/src/location/maps/qgeocameratiles.cpp
+++ b/src/location/maps/qgeocameratiles.cpp
@@ -34,6 +34,7 @@
**
****************************************************************************/
#include "qgeocameratiles_p.h"
+#include "qgeocameratiles_p_p.h"
#include "qgeocameradata_p.h"
#include "qgeotilespec_p.h"
#include "qgeomaptype_p.h"
@@ -63,76 +64,6 @@ static QDoubleVector3D toDoubleVector3D(const QVector3D& in)
QT_BEGIN_NAMESPACE
-struct Frustum
-{
- QDoubleVector3D apex;
- QDoubleVector3D topLeftNear;
- QDoubleVector3D topLeftFar;
- QDoubleVector3D topRightNear;
- QDoubleVector3D topRightFar;
- QDoubleVector3D bottomLeftNear;
- QDoubleVector3D bottomLeftFar;
- QDoubleVector3D bottomRightNear;
- QDoubleVector3D bottomRightFar;
-};
-
-typedef QVector<QDoubleVector3D> PolygonVector;
-
-class QGeoCameraTilesPrivate
-{
-public:
- QGeoCameraTilesPrivate();
- ~QGeoCameraTilesPrivate();
-
- QString m_pluginString;
- QGeoMapType m_mapType;
- int m_mapVersion;
- QGeoCameraData m_camera;
- QSize m_screenSize;
- QRectF m_visibleArea;
- int m_tileSize;
- QSet<QGeoTileSpec> m_tiles;
-
- int m_intZoomLevel;
- int m_sideLength;
-
- bool m_dirtyGeometry;
- bool m_dirtyMetadata;
-
- double m_viewExpansion;
- void updateMetadata();
- void updateGeometry();
-
- Frustum createFrustum(double viewExpansion) const;
-
- struct ClippedFootprint
- {
- ClippedFootprint(const PolygonVector &left_, const PolygonVector &mid_, const PolygonVector &right_)
- : left(left_), mid(mid_), right(right_)
- {}
- PolygonVector left;
- PolygonVector mid;
- PolygonVector right;
- };
-
- PolygonVector frustumFootprint(const Frustum &frustum) const;
-
- QPair<PolygonVector, PolygonVector> splitPolygonAtAxisValue(const PolygonVector &polygon, int axis, double value) const;
- ClippedFootprint clipFootprintToMap(const PolygonVector &footprint) const;
-
- QList<QPair<double, int> > tileIntersections(double p1, int t1, double p2, int t2) const;
- QSet<QGeoTileSpec> tilesFromPolygon(const PolygonVector &polygon) const;
-
- struct TileMap
- {
- TileMap();
-
- void add(int tileX, int tileY);
-
- QMap<int, QPair<int, int> > data;
- };
-};
-
QGeoCameraTiles::QGeoCameraTiles()
: d_ptr(new QGeoCameraTilesPrivate()) {}
@@ -277,12 +208,22 @@ void QGeoCameraTilesPrivate::updateGeometry()
// Find the frustum from the camera / screen / viewport information
// The larger frustum when stationary is a form of prefetching
Frustum f = createFrustum(m_viewExpansion);
+#ifdef QT_LOCATION_DEBUG
+ m_frustum = f;
+#endif
// Find the polygon where the frustum intersects the plane of the map
PolygonVector footprint = frustumFootprint(f);
+#ifdef QT_LOCATION_DEBUG
+ m_frustumFootprint = footprint;
+#endif
// Clip the polygon to the map, split it up if it cross the dateline
ClippedFootprint polygons = clipFootprintToMap(footprint);
+#ifdef QT_LOCATION_DEBUG
+ m_clippedFootprint = polygons;
+#endif
+
if (!polygons.left.isEmpty()) {
QSet<QGeoTileSpec> tilesLeft = tilesFromPolygon(polygons.left);
@@ -306,6 +247,10 @@ Frustum QGeoCameraTilesPrivate::createFrustum(double viewExpansion) const
if (m_camera.fieldOfView() != 90.0) //aperture(90 / 2) = 1
apertureSize = tan(QLocationUtils::radians(m_camera.fieldOfView()) * 0.5);
QDoubleVector3D center = m_sideLength * QWebMercator::coordToMercator(m_camera.center());
+#ifdef QT_LOCATION_DEBUG
+ m_createFrustum_center = center;
+#endif
+
double f = m_screenSize.height();
@@ -335,7 +280,7 @@ Frustum QGeoCameraTilesPrivate::createFrustum(double viewExpansion) const
side = QDoubleVector3D::normal(view, QDoubleVector3D(0.0, 1.0, 0.0));
up = QDoubleVector3D::normal(view, side2);
- double nearPlane = 1 / (4.0 * m_tileSize );
+ double nearPlane = 1.0 / 32.0; // The denominator used to be (4.0 * m_tileSize ), which produces an extremely narrow and tiny near plane.
// farPlane plays a role on how much gets clipped when the map gets tilted. It used to be altitude + 1.0
// The value of 8.0 has been chosen as an acceptable compromise.
// TODO: use m_camera.clipDistance(); when this will be introduced
@@ -367,6 +312,9 @@ Frustum QGeoCameraTilesPrivate::createFrustum(double viewExpansion) const
Frustum frustum;
frustum.apex = eye;
+#ifdef QT_LOCATION_DEBUG
+ m_createFrustum_eye = eye;
+#endif
QRectF va = m_visibleArea;
if (va.isNull())