24 const QMap<QString, QgsMapLayer *> &mapLayers = project->
mapLayers();
25 QList< QgsMapLayer * > layers;
26 layers.reserve( mapLayers.size() );
27 for ( QMap<QString, QgsMapLayer *>::const_iterator it = mapLayers.constBegin(); it != mapLayers.constEnd(); ++it )
38 double min = std::numeric_limits<double>::quiet_NaN();
39 double max = std::numeric_limits<double>::quiet_NaN();
43 if ( !currentLayer->elevationProperties() || !currentLayer->elevationProperties()->hasElevation() )
46 const QgsDoubleRange layerRange = currentLayer->elevationProperties()->calculateZRange( currentLayer );
50 if ( layerRange.
lower() > std::numeric_limits< double >::lowest() )
52 if ( std::isnan( min ) || layerRange.
lower() < min )
53 min = layerRange.
lower();
56 if ( layerRange.
upper() < std::numeric_limits< double >::max() )
58 if ( std::isnan( max ) || layerRange.
upper() > max )
59 max = layerRange.
upper();
63 return QgsDoubleRange( std::isnan( min ) ? std::numeric_limits< double >::lowest() : min, std::isnan( max ) ? std::numeric_limits< double >::max() : max );
68 const QMap<QString, QgsMapLayer *> &mapLayers = project->
mapLayers();
69 QList< QgsMapLayer * > layers;
70 for ( QMap<QString, QgsMapLayer *>::const_iterator it = mapLayers.constBegin(); it != mapLayers.constEnd(); ++it )
81 QSet< double > values;
85 if ( !currentLayer->elevationProperties() || !currentLayer->elevationProperties()->hasElevation() )
88 const QList< double > layerValues = currentLayer->elevationProperties()->significantZValues( currentLayer );
89 for (
double value : layerValues )
91 values.insert( value );
95 QList< double > res = qgis::setToList( values );
96 std::sort( res.begin(), res.end() );
107 switch ( layer->
type() )
113 properties->setEnabled(
true );
116 properties->setBandNumber( 1 );
@ RepresentsElevationSurface
Pixel values represent an elevation surface.
@ Group
Composite group layer. Added in QGIS 3.24.
@ Plugin
Plugin based layer.
@ TiledScene
Tiled scene layer. Added in QGIS 3.34.
@ Annotation
Contains freeform, georeferenced annotations. Added in QGIS 3.16.
@ VectorTile
Vector tile layer. Added in QGIS 3.14.
@ Mesh
Mesh layer. Added in QGIS 3.2.
@ PointCloud
Point cloud layer. Added in QGIS 3.18.
QgsRange which stores a range of double values.
bool isInfinite() const
Returns true if the range consists of all possible values.
static QList< double > significantZValuesForLayers(const QList< QgsMapLayer * > &layers)
Returns a list of significant elevation/z-values for the specified layers.
static QgsDoubleRange calculateZRangeForProject(QgsProject *project)
Calculates the elevation range for a project.
static bool enableElevationForLayer(QgsMapLayer *layer)
Automatically enables elevation for a map layer, using reasonable defaults.
static QList< double > significantZValuesForProject(QgsProject *project)
Returns a list of significant elevation/z-values for the specified project, using the values from lay...
static QgsDoubleRange calculateZRangeForLayers(const QList< QgsMapLayer * > &layers)
Calculates the elevation range for the specified layers.
static bool canEnableElevationForLayer(QgsMapLayer *layer)
Returns true if elevation can be enabled for a map layer.
Base class for all map layer types.
virtual QgsMapLayerElevationProperties * elevationProperties()
Returns the layer's elevation properties.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
QMap< QString, QgsMapLayer * > mapLayers(const bool validOnly=false) const
Returns a map of all registered layers by layer ID.
T lower() const
Returns the lower bound of the range.
T upper() const
Returns the upper bound of the range.
Raster layer specific subclass of QgsMapLayerElevationProperties.