QGIS API Documentation 4.0.0-Norrköping (1ddcee3d0e4)
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
31#include "qgschunknode.h"
33#include "qgsrectangle.h"
35#include "qgstilingscheme.h"
36
37#include <QElapsedTimer>
38#include <QFutureWatcher>
39#include <QMutex>
40
41#define SIP_NO_FILE
42
44class QgsRasterLayer;
45class QgsRasterBlock;
48
53class QgsDemTerrainTileLoader : public QgsTerrainTileLoader
54{
55 Q_OBJECT
56 public:
58 QgsDemTerrainTileLoader( QgsTerrainEntity *terrain, QgsChunkNode *node, QgsTerrainGenerator *terrainGenerator );
59
60 void start() override;
61
62 Qt3DCore::QEntity *createEntity( Qt3DCore::QEntity *parent ) override;
63
64 private slots:
65 void onHeightMapReady( int jobId, const QByteArray &heightMap );
66
67 private:
68 int mHeightMapJobId = -1;
69 QByteArray mHeightMap;
70 int mResolution = 0;
71 float mSkirtHeight = 0;
72 QgsTerrainGenerator *mTerrainGenerator;
73};
74
75
77
82class QgsDemHeightMapGenerator : public QObject
83{
84 Q_OBJECT
85 public:
90 QgsDemHeightMapGenerator( QgsRasterLayer *dtm, const QgsTilingScheme &tilingScheme, int resolution, const QgsCoordinateTransformContext &transformContext );
91 ~QgsDemHeightMapGenerator() override;
92
94 int render( const QgsChunkNodeId &nodeId );
95
97 void waitForFinished();
98
100 int resolution() const { return mResolution; }
101
103 float heightAt( double x, double y );
104
105 signals:
107 void heightMapReady( int jobId, const QByteArray &heightMap );
108
109 private slots:
110 void onFutureFinished();
111
112 private:
114 const QgsRectangle mDtmExtent;
115
117 QgsRasterDataProvider *mClonedProvider = nullptr;
118
119 QgsTilingScheme mTilingScheme;
120
121 int mResolution;
122
123 int mLastJobId = 0;
124
125 std::unique_ptr<QgsTerrainDownloader> mDownloader;
126
127 struct JobData
128 {
129 int jobId;
130 QgsChunkNodeId tileId;
131 QgsRectangle extent;
132 QFuture<QByteArray> future;
133 QElapsedTimer timer;
134 };
135
136 QHash<QFutureWatcher<QByteArray> *, JobData> mJobs;
137
138 void lazyLoadDtmCoarseData( int res, const QgsRectangle &rect );
139 mutable QMutex mLazyLoadDtmCoarseDataMutex;
141 std::unique_ptr<QgsRasterBlock> mDtmCoarseRasterBlock;
142
143 QgsCoordinateTransformContext mTransformContext;
144};
145
147
148#endif // QGSDEMTERRAINTILELOADER_P_H
Contains information about the context in which a coordinate transform is executed.
Raster data container.
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.