QGIS API Documentation  3.12.1-BucureČ™ti (121cc00ff0)
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 #include <QtConcurrent/QtConcurrentRun>
31 #include <QFutureWatcher>
32 #include <QElapsedTimer>
33 
34 #include "qgschunknode_p.h"
35 #include "qgsrectangle.h"
36 #include "qgsterraintileloader_p.h"
37 #include "qgstilingscheme.h"
38 
40 class QgsRasterLayer;
42 
48 class QgsDemTerrainTileLoader : public QgsTerrainTileLoader
49 {
50  Q_OBJECT
51  public:
53  QgsDemTerrainTileLoader( QgsTerrainEntity *terrain, QgsChunkNode *node );
54 
55  Qt3DCore::QEntity *createEntity( Qt3DCore::QEntity *parent ) override;
56 
57  private slots:
58  void onHeightMapReady( int jobId, const QByteArray &heightMap );
59 
60  private:
61 
62  int mHeightMapJobId;
63  QByteArray mHeightMap;
64  int mResolution;
65  float mSkirtHeight;
66 };
67 
68 
70 
76 class QgsDemHeightMapGenerator : public QObject
77 {
78  Q_OBJECT
79  public:
80 
85  QgsDemHeightMapGenerator( QgsRasterLayer *dtm, const QgsTilingScheme &tilingScheme, int resolution, const QgsCoordinateTransformContext &transformContext );
86  ~QgsDemHeightMapGenerator() override;
87 
89  int render( int x, int y, int z );
90 
92  QByteArray renderSynchronously( int x, int y, int z );
93 
95  int resolution() const { return mResolution; }
96 
98  float heightAt( double x, double y );
99 
100  signals:
102  void heightMapReady( int jobId, const QByteArray &heightMap );
103 
104  private slots:
105  void onFutureFinished();
106 
107  private:
109  QgsRasterLayer *mDtm = nullptr;
110 
112  QgsRasterDataProvider *mClonedProvider = nullptr;
113 
114  QgsTilingScheme mTilingScheme;
115 
116  int mResolution;
117 
118  int mLastJobId;
119 
120  std::unique_ptr<QgsTerrainDownloader> mDownloader;
121 
122  struct JobData
123  {
124  int jobId;
125  QgsChunkNodeId tileId;
126  QgsRectangle extent;
127  QFuture<QByteArray> future;
128  QFutureWatcher<QByteArray> *fw;
129  QElapsedTimer timer;
130  };
131 
132  QHash<QFutureWatcher<QByteArray>*, JobData> mJobs;
133 
135  QByteArray mDtmCoarseData;
136 };
137 
139 
140 #endif // QGSDEMTERRAINTILELOADER_P_H
A rectangle specified with double values.
Definition: qgsrectangle.h:41
Represents a raster layer.
Contains information about the context in which a coordinate transform is executed.
3 Takes care of downloading terrain data from a publicly available data source.
3 The class encapsulates tiling scheme (just like with WMTS / TMS / XYZ layers).
Base class for raster data providers.