QGIS API Documentation 3.99.0-Master (21b3aa880ba)
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 "qgschunknode.h"
34#include "qgsrectangle.h"
36#include "qgstilingscheme.h"
37
38#include <QElapsedTimer>
39#include <QFutureWatcher>
40#include <QMutex>
41#include <QtConcurrent/QtConcurrentRun>
42
44class QgsRasterLayer;
47
52class QgsDemTerrainTileLoader : public QgsTerrainTileLoader
53{
54 Q_OBJECT
55 public:
57 QgsDemTerrainTileLoader( QgsTerrainEntity *terrain, QgsChunkNode *node, QgsTerrainGenerator *terrainGenerator );
58
59 void start() override;
60
61 Qt3DCore::QEntity *createEntity( Qt3DCore::QEntity *parent ) override;
62
63 private slots:
64 void onHeightMapReady( int jobId, const QByteArray &heightMap );
65
66 private:
67 int mHeightMapJobId = -1;
68 QByteArray mHeightMap;
69 int mResolution = 0;
70 float mSkirtHeight = 0;
71 QgsTerrainGenerator *mTerrainGenerator;
72};
73
74
76
81class QgsDemHeightMapGenerator : public QObject
82{
83 Q_OBJECT
84 public:
89 QgsDemHeightMapGenerator( QgsRasterLayer *dtm, const QgsTilingScheme &tilingScheme, int resolution, const QgsCoordinateTransformContext &transformContext );
90 ~QgsDemHeightMapGenerator() override;
91
93 int render( const QgsChunkNodeId &nodeId );
94
96 void waitForFinished();
97
99 int resolution() const { return mResolution; }
100
102 float heightAt( double x, double y );
103
104 signals:
106 void heightMapReady( int jobId, const QByteArray &heightMap );
107
108 private slots:
109 void onFutureFinished();
110
111 private:
113 const QgsRectangle mDtmExtent;
114
116 QgsRasterDataProvider *mClonedProvider = nullptr;
117
118 QgsTilingScheme mTilingScheme;
119
120 int mResolution;
121
122 int mLastJobId = 0;
123
124 std::unique_ptr<QgsTerrainDownloader> mDownloader;
125
126 struct JobData
127 {
128 int jobId;
129 QgsChunkNodeId tileId;
130 QgsRectangle extent;
131 QFuture<QByteArray> future;
132 QElapsedTimer timer;
133 };
134
135 QHash<QFutureWatcher<QByteArray> *, JobData> mJobs;
136
137 void lazyLoadDtmCoarseData( int res, const QgsRectangle &rect );
138 mutable QMutex mLazyLoadDtmCoarseDataMutex;
140 QByteArray mDtmCoarseData;
141
142 QgsCoordinateTransformContext mTransformContext;
143};
144
146
147#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.
Takes care of downloading terrain data from a publicly available data source.
Base class for generators of terrain.