QGIS API Documentation 3.41.0-Master (cea29feecf2)
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#include "moc_qgsonlineterraingenerator.cpp"
18
20
21
23
25
26QgsChunkLoader *QgsOnlineTerrainGenerator::createChunkLoader( QgsChunkNode *node ) const
27{
28 return new QgsDemTerrainTileLoader( mTerrain, node, const_cast<QgsOnlineTerrainGenerator *>( this ) );
29}
30
32{
34 cloned->setTerrain( mTerrain );
35 cloned->mCrs = mCrs;
36 cloned->mExtent = mExtent;
37 cloned->mResolution = mResolution;
38 cloned->mSkirtHeight = mSkirtHeight;
39 cloned->updateGenerator();
40 return cloned;
41}
42
47
52
53float QgsOnlineTerrainGenerator::heightAt( double x, double y, const Qgs3DRenderContext &context ) const
54{
55 Q_UNUSED( context )
56 if ( mHeightMapGenerator )
57 return mHeightMapGenerator->heightAt( x, y );
58 else
59 return 0;
60}
61
66
68{
69 mCrs = crs;
70 mTransformContext = context;
71 updateGenerator();
72}
73
75{
76 if ( mExtent == extent )
77 return;
78
79 mExtent = extent;
80 updateGenerator();
81}
82
83void QgsOnlineTerrainGenerator::updateGenerator()
84{
85 if ( mExtent.isNull() )
86 {
88 }
89 else
90 {
91 // the real extent will be a square where the given extent fully fits
93 }
94
95 mHeightMapGenerator.reset( new QgsDemHeightMapGenerator( nullptr, mTerrainTilingScheme, mResolution, mTransformContext ) );
96}
This class 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
float heightAt(double x, double y, const Qgs3DRenderContext &context) const override
Returns height at (x,y) in map's CRS.
QgsTerrainGenerator * clone() const override SIP_FACTORY
Makes a copy of the current instance.
~QgsOnlineTerrainGenerator() override
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.
static QgsTerrainGenerator * create() SIP_FACTORY
Creates a new instance of a QgsOnlineTerrainGenerator object.
QgsChunkLoader * createChunkLoader(QgsChunkNode *node) const override SIP_FACTORY
A rectangle specified with double values.
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)
QgsRectangle tileToExtent(int x, int y, int z) const
Returns map coordinates of the extent of a tile.
const QgsCoordinateReferenceSystem & crs