QGIS API Documentation 3.99.0-Master (26c88405ac0)
Loading...
Searching...
No Matches
qgsonlineterraingenerator.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsonlineterraingenerator.cpp
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
17
18#include <memory>
19
21
22#include "moc_qgsonlineterraingenerator.cpp"
23
25
27
28QgsChunkLoader *QgsOnlineTerrainGenerator::createChunkLoader( QgsChunkNode *node ) const
29{
30 return new QgsDemTerrainTileLoader( mTerrain, node, const_cast<QgsOnlineTerrainGenerator *>( this ) );
31}
32
34{
36 cloned->setTerrain( mTerrain );
37 cloned->mCrs = mCrs;
38 cloned->mExtent = mExtent;
39 cloned->mResolution = mResolution;
40 cloned->mSkirtHeight = mSkirtHeight;
41 cloned->updateGenerator();
42 return cloned;
43}
44
49
51{
52 return mTerrainTilingScheme.tileToExtent( 0, 0, 0 );
53}
54
55float QgsOnlineTerrainGenerator::heightAt( double x, double y, const Qgs3DRenderContext &context ) const
56{
57 Q_UNUSED( context )
58 if ( mHeightMapGenerator )
59 return mHeightMapGenerator->heightAt( x, y );
60 else
61 return 0;
62}
63
68
70{
71 mCrs = crs;
72 mTransformContext = context;
73 updateGenerator();
74}
75
77{
78 if ( mExtent == extent )
79 return;
80
81 mExtent = extent;
82 updateGenerator();
83}
84
85void QgsOnlineTerrainGenerator::updateGenerator()
86{
87 if ( mExtent.isNull() )
88 {
90 }
91 else
92 {
93 // the real extent will be a square where the given extent fully fits
94 mTerrainTilingScheme = QgsTilingScheme( mExtent, mCrs );
95 }
96
97 mHeightMapGenerator = std::make_unique<QgsDemHeightMapGenerator>( nullptr, mTerrainTilingScheme, mResolution, mTransformContext );
98}
Rendering context for preparation of 3D entities.
Represents a coordinate reference system (CRS).
Contains information about the context in which a coordinate transform is executed.
void setCrs(const QgsCoordinateReferenceSystem &crs, const QgsCoordinateTransformContext &context) override
Sets the CRS associated with the terrain.
void setExtent(const QgsRectangle &extent) override
sets the extent of the terrain in terrain's CRS
QgsChunkLoader * createChunkLoader(QgsChunkNode *node) const override
static QgsTerrainGenerator * create()
Creates a new instance of a QgsOnlineTerrainGenerator object.
float heightAt(double x, double y, const Qgs3DRenderContext &context) const override
Returns height at (x,y) in map's CRS.
~QgsOnlineTerrainGenerator() override
QgsTerrainGenerator * clone() const override
Makes a copy of the current instance.
QgsCoordinateReferenceSystem crs() const override
Returns CRS of the terrain.
QgsRectangle rootChunkExtent() const override
extent of the terrain's root chunk in terrain's CRS
Type type() const override
What texture generator implementation is this.
A rectangle specified with double values.
Base class for generators of terrain.
Type
Enumeration of the available terrain generators.
@ Online
Terrain is built from downloaded tiles with digital elevation model.
QgsTilingScheme mTerrainTilingScheme
Tiling scheme of the terrain.
QgsTerrainEntity * mTerrain
virtual void setTerrain(QgsTerrainEntity *t)
Sets terrain entity for the generator (does not transfer ownership).
Encapsulates tiling schemes (just like with WMTS / TMS / XYZ layers).