QGIS API Documentation  3.14.0-Pi (9f7028fd23)
qgsdemterraintileloader_p.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsdemterraintileloader_p.h
3  --------------------------------------
4  Date : July 2017
5  Copyright : (C) 2017 by Martin Dobias
6  Email : wonder dot sk at gmail dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 #ifndef QGSDEMTERRAINTILELOADER_P_H
17 #define QGSDEMTERRAINTILELOADER_P_H
18 
20 
21 //
22 // W A R N I N G
23 // -------------
24 //
25 // This file is not part of the QGIS API. It exists purely as an
26 // implementation detail. This header file may change from version to
27 // version without notice, or even be removed.
28 //
29 
30 #define SIP_NO_FILE
31 
32 #include <QtConcurrent/QtConcurrentRun>
33 #include <QFutureWatcher>
34 #include <QElapsedTimer>
35 
36 #include "qgschunknode_p.h"
37 #include "qgsrectangle.h"
38 #include "qgsterraintileloader_p.h"
39 #include "qgstilingscheme.h"
40 
42 class QgsRasterLayer;
44 
50 class QgsDemTerrainTileLoader : public QgsTerrainTileLoader
51 {
52  Q_OBJECT
53  public:
55  QgsDemTerrainTileLoader( QgsTerrainEntity *terrain, QgsChunkNode *node );
56 
57  Qt3DCore::QEntity *createEntity( Qt3DCore::QEntity *parent ) override;
58 
59  private slots:
60  void onHeightMapReady( int jobId, const QByteArray &heightMap );
61 
62  private:
63 
64  int mHeightMapJobId;
65  QByteArray mHeightMap;
66  int mResolution;
67  float mSkirtHeight;
68 };
69 
70 
72 
78 class QgsDemHeightMapGenerator : public QObject
79 {
80  Q_OBJECT
81  public:
82 
87  QgsDemHeightMapGenerator( QgsRasterLayer *dtm, const QgsTilingScheme &tilingScheme, int resolution, const QgsCoordinateTransformContext &transformContext );
88  ~QgsDemHeightMapGenerator() override;
89 
91  int render( int x, int y, int z );
92 
94  QByteArray renderSynchronously( int x, int y, int z );
95 
97  int resolution() const { return mResolution; }
98 
100  float heightAt( double x, double y );
101 
102  signals:
104  void heightMapReady( int jobId, const QByteArray &heightMap );
105 
106  private slots:
107  void onFutureFinished();
108 
109  private:
111  QgsRasterLayer *mDtm = nullptr;
112 
114  QgsRasterDataProvider *mClonedProvider = nullptr;
115 
116  QgsTilingScheme mTilingScheme;
117 
118  int mResolution;
119 
120  int mLastJobId;
121 
122  std::unique_ptr<QgsTerrainDownloader> mDownloader;
123 
124  struct JobData
125  {
126  int jobId;
127  QgsChunkNodeId tileId;
128  QgsRectangle extent;
129  QFuture<QByteArray> future;
130  QElapsedTimer timer;
131  };
132 
133  QHash<QFutureWatcher<QByteArray>*, JobData> mJobs;
134 
136  QByteArray mDtmCoarseData;
137 };
138 
140 
141 #endif // QGSDEMTERRAINTILELOADER_P_H
QgsCoordinateTransformContext
Definition: qgscoordinatetransformcontext.h:57
qgsrectangle.h
QgsTerrainDownloader
Definition: qgsterraindownloader.h:48
qgschunknode_p.h
QgsRectangle
Definition: qgsrectangle.h:41
QgsRasterLayer
Definition: qgsrasterlayer.h:72
qgsterraintileloader_p.h
QgsTilingScheme
Definition: qgstilingscheme.h:35
qgstilingscheme.h
QgsRasterDataProvider
Definition: qgsrasterdataprovider.h:88