QGIS API Documentation  3.10.0-A Coruña (6c816b4204)
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 "qgsrectangle.h"
35 #include "qgsterraintileloader_p.h"
36 #include "qgstilingscheme.h"
37 
39 class QgsRasterLayer;
41 
47 class QgsDemTerrainTileLoader : public QgsTerrainTileLoader
48 {
49  Q_OBJECT
50  public:
52  QgsDemTerrainTileLoader( QgsTerrainEntity *terrain, QgsChunkNode *node );
53 
54  Qt3DCore::QEntity *createEntity( Qt3DCore::QEntity *parent ) override;
55 
56  private slots:
57  void onHeightMapReady( int jobId, const QByteArray &heightMap );
58 
59  private:
60 
61  int mHeightMapJobId;
62  QByteArray mHeightMap;
63  int mResolution;
64  float mSkirtHeight;
65 };
66 
67 
69 
75 class QgsDemHeightMapGenerator : public QObject
76 {
77  Q_OBJECT
78  public:
79 
84  QgsDemHeightMapGenerator( QgsRasterLayer *dtm, const QgsTilingScheme &tilingScheme, int resolution, const QgsCoordinateTransformContext &transformContext );
85  ~QgsDemHeightMapGenerator() override;
86 
88  int render( int x, int y, int z );
89 
91  QByteArray renderSynchronously( int x, int y, int z );
92 
94  int resolution() const { return mResolution; }
95 
97  float heightAt( double x, double y );
98 
99  signals:
101  void heightMapReady( int jobId, const QByteArray &heightMap );
102 
103  private slots:
104  void onFutureFinished();
105 
106  private:
108  QgsRasterLayer *mDtm = nullptr;
109 
111  QgsRasterDataProvider *mClonedProvider = nullptr;
112 
113  QgsTilingScheme mTilingScheme;
114 
115  int mResolution;
116 
117  int mLastJobId;
118 
119  std::unique_ptr<QgsTerrainDownloader> mDownloader;
120 
121  struct JobData
122  {
123  int jobId;
124  QgsRectangle extent;
125  QFuture<QByteArray> future;
126  QFutureWatcher<QByteArray> *fw;
127  QElapsedTimer timer;
128  };
129 
130  QHash<QFutureWatcher<QByteArray>*, JobData> mJobs;
131 
133  QByteArray mDtmCoarseData;
134 };
135 
137 
138 #endif // QGSDEMTERRAINTILELOADER_P_H
A rectangle specified with double values.
Definition: qgsrectangle.h:41
This class provides qgis with the ability to render raster datasets onto the mapcanvas.
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.