25 delete mHeightMapGenerator;
36 return qobject_cast<QgsRasterLayer *>( mLayer.
layer.data() );
42 mTransformContext = context;
51 cloned->mLayer = mLayer;
52 cloned->mResolution = mResolution;
53 cloned->mSkirtHeight = mSkirtHeight;
55 cloned->updateGenerator();
72 if ( mHeightMapGenerator )
73 return mHeightMapGenerator->heightAt( x, y );
80 elem.setAttribute( QStringLiteral(
"layer" ), mLayer.
layerId );
81 elem.setAttribute( QStringLiteral(
"resolution" ), mResolution );
82 elem.setAttribute( QStringLiteral(
"skirt-height" ), mSkirtHeight );
89 mLayer =
QgsMapLayerRef( elem.attribute( QStringLiteral(
"layer" ) ) );
90 mResolution = elem.attribute( QStringLiteral(
"resolution" ) ).toInt();
91 mSkirtHeight = elem.attribute( QStringLiteral(
"skirt-height" ) ).toFloat();
119 if ( mCrs != mLayer->
crs() )
129 QgsDebugMsg( QStringLiteral(
"Transformation of layer extent to terrain crs failed." ) );
137void QgsDemTerrainGenerator::updateGenerator()
143 delete mHeightMapGenerator;
144 mHeightMapGenerator =
new QgsDemHeightMapGenerator( dem,
mTerrainTilingScheme, mResolution, mTransformContext );
150 delete mHeightMapGenerator;
151 mHeightMapGenerator =
nullptr;
This class represents a coordinate reference system (CRS).
Contains information about the context in which a coordinate transform is executed.
Custom exception class for Coordinate Reference System related exceptions.
float heightAt(double x, double y, const Qgs3DMapSettings &map) const override
Returns height at (x,y) in terrain's CRS.
~QgsDemTerrainGenerator() override
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.
void setCrs(const QgsCoordinateReferenceSystem &crs, const QgsCoordinateTransformContext &context)
Sets CRS of the terrain.
void readXml(const QDomElement &elem) override
Read terrain generator's configuration from XML.
QgsTerrainGenerator * clone() const override
Makes a copy of the current instance.
void resolveReferences(const QgsProject &project) override
After read of XML, resolve references to any layers that have been read as layer IDs.
QgsRasterLayer * layer() const
Returns raster layer with elevation model to be used for terrain generation.
void setExtent(const QgsRectangle &extent) override
sets the extent of the terrain in terrain's CRS
void writeXml(QDomElement &elem) const override
Write terrain generator's configuration to XML.
QgsChunkLoader * createChunkLoader(QgsChunkNode *node) const override
void setLayer(QgsRasterLayer *layer)
Sets raster layer with elevation model to be used for terrain generation.
QgsDemTerrainGenerator()=default
Constructor for QgsDemTerrainGenerator.
virtual QgsRectangle extent() const
Returns the extent of the layer.
QgsCoordinateReferenceSystem crs
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
Q_INVOKABLE QgsMapLayer * mapLayer(const QString &layerId) const
Retrieve a pointer to a registered layer by layer ID.
Represents a raster layer.
A rectangle specified with double values.
QgsRectangle intersect(const QgsRectangle &rect) const
Returns the intersection with the given rectangle.
Type
Enumeration of the available terrain generators.
@ Dem
Terrain is built from raster layer with digital elevation model.
QgsTilingScheme mTerrainTilingScheme
Tiling scheme of the terrain.
QgsCoordinateReferenceSystem crs() const
Returns CRS of the terrain.
virtual QgsRectangle extent() const
extent of the terrain in terrain's CRS, might be non-square and smaller than rootChunkExtent()
QgsTerrainEntity * mTerrain
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.
_LayerRef< QgsMapLayer > QgsMapLayerRef
const QgsCoordinateReferenceSystem & crs
QPointer< TYPE > layer
Weak pointer to map layer.
QString layerId
Original layer ID.