QGIS API Documentation  3.10.0-A Coruña (6c816b4204)
qgsterraindownloader.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsterraindownloader.h
3  --------------------------------------
4  Date : March 2019
5  Copyright : (C) 2019 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 QGSTERRAINDOWNLOADER_H
17 #define QGSTERRAINDOWNLOADER_H
18 
19 #include "qgis_3d.h"
20 
21 #include <memory>
22 #include <QByteArray>
23 #include <QImage>
24 
26 
27 class QgsRectangle;
29 class QgsRasterLayer;
31 
43 class _3D_EXPORT QgsTerrainDownloader
44 {
45 
46  public:
47 
52  QgsTerrainDownloader( const QgsCoordinateTransformContext &transformContext );
53 
55 
57  typedef struct
58  {
59  QString uri;
60  int zMin = 0;
61  int zMax = 0;
62  } DataSource;
63 
65  static DataSource defaultDataSource();
66 
68  void setDataSource( const DataSource &ds );
69 
71  DataSource dataSource() const { return mDataSource; }
72 
77  QByteArray getHeightMap( const QgsRectangle &extentOrig, int res, const QgsCoordinateReferenceSystem &destCrs, const QgsCoordinateTransformContext &context = QgsCoordinateTransformContext(), QString tmpFilenameImg = QString(), QString tmpFilenameTif = QString() );
78 
79  private:
80 
85  double findBestTileResolution( double requestedMupp );
86 
90  static void adjustExtentAndResolution( double mupp, const QgsRectangle &extentOrig, QgsRectangle &extent, int &res );
91 
96  static void tileImageToHeightMap( const QImage &img, QByteArray &heightMap );
97 
98  private:
99  DataSource mDataSource;
100  std::unique_ptr<QgsRasterLayer> mOnlineDtm;
101  double mXSpan = 0;
102 };
103 
104 #endif // QGSTERRAINDOWNLOADER_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.
QString uri
HTTP(S) template for XYZ tiles requests (e.g. http://example.com/{z}/{x}/{y}.png) ...
Definition of data source for terrain tiles (assuming "terrarium" data encoding with usual XYZ tiling...
DataSource dataSource() const
Returns currently configured data source.
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.
This class represents a coordinate reference system (CRS).