QGIS API Documentation 3.99.0-Master (8e76e220402)
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
43class QgsRasterLayer;
46
51class QgsDemTerrainTileLoader : public QgsTerrainTileLoader
52{
53 Q_OBJECT
54 public:
56 QgsDemTerrainTileLoader( QgsTerrainEntity *terrain, QgsChunkNode *node, QgsTerrainGenerator *terrainGenerator );
57
58 void start() override;
59
60 Qt3DCore::QEntity *createEntity( Qt3DCore::QEntity *parent ) override;
61
62 private slots:
63 void onHeightMapReady( int jobId, const QByteArray &heightMap );
64
65 private:
66 int mHeightMapJobId = -1;
67 QByteArray mHeightMap;
68 int mResolution = 0;
69 float mSkirtHeight = 0;
70 QgsTerrainGenerator *mTerrainGenerator;
71};
72
73
75
80class QgsDemHeightMapGenerator : public QObject
81{
82 Q_OBJECT
83 public:
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 = 0;
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.
Takes care of downloading terrain data from a publicly available data source.
Base class for generators of terrain.