QGIS API Documentation 3.41.0-Master (fda2aa46e9a)
Loading...
Searching...
No Matches
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#include <QMutex>
36
37#include "qgschunknode.h"
39#include "qgsrectangle.h"
41#include "qgstilingscheme.h"
42
44class QgsRasterLayer;
47
52class QgsDemTerrainTileLoader : public QgsTerrainTileLoader
53{
54 Q_OBJECT
55 public:
57 QgsDemTerrainTileLoader( QgsTerrainEntity *terrain, QgsChunkNode *node, QgsTerrainGenerator *terrainGenerator );
58
59 Qt3DCore::QEntity *createEntity( Qt3DCore::QEntity *parent ) override;
60
61 private slots:
62 void onHeightMapReady( int jobId, const QByteArray &heightMap );
63
64 private:
65
66 int mHeightMapJobId;
67 QByteArray mHeightMap;
68 int mResolution;
69 float mSkirtHeight;
70};
71
72
74
79class QgsDemHeightMapGenerator : public QObject
80{
81 Q_OBJECT
82 public:
83
88 QgsDemHeightMapGenerator( QgsRasterLayer *dtm, const QgsTilingScheme &tilingScheme, int resolution, const QgsCoordinateTransformContext &transformContext );
89 ~QgsDemHeightMapGenerator() override;
90
92 int render( const QgsChunkNodeId &nodeId );
93
95 void waitForFinished();
96
98 int resolution() const { return mResolution; }
99
101 float heightAt( double x, double y );
102
103 signals:
105 void heightMapReady( int jobId, const QByteArray &heightMap );
106
107 private slots:
108 void onFutureFinished();
109
110 private:
112 const QgsRectangle mDtmExtent;
113
115 QgsRasterDataProvider *mClonedProvider = nullptr;
116
117 QgsTilingScheme mTilingScheme;
118
119 int mResolution;
120
121 int mLastJobId;
122
123 std::unique_ptr<QgsTerrainDownloader> mDownloader;
124
125 struct JobData
126 {
127 int jobId;
128 QgsChunkNodeId tileId;
129 QgsRectangle extent;
130 QFuture<QByteArray> future;
131 QElapsedTimer timer;
132 };
133
134 QHash<QFutureWatcher<QByteArray>*, JobData> mJobs;
135
136 void lazyLoadDtmCoarseData( int res, const QgsRectangle &rect );
137 mutable QMutex mLazyLoadDtmCoarseDataMutex;
139 QByteArray mDtmCoarseData;
140
141 QgsCoordinateTransformContext mTransformContext;
142};
143
145
146#endif // QGSDEMTERRAINTILELOADER_P_H
Contains information about the context in which a coordinate transform is executed.
Base class for raster data providers.
Represents a raster layer.
A rectangle specified with double values.