QGIS API Documentation 3.28.0-Firenze (ed3ad0430f)
Public Member Functions | Static Public Member Functions | List of all members
QgsElevationMap Class Reference

Stores digital elevation model in a raster image which may get updated as a part of map layer rendering process. More...

#include <qgselevationmap.h>

Public Member Functions

 QgsElevationMap (const QSize &size)
 Constructs an elevation map with the given width and height. More...
 
void applyEyeDomeLighting (QImage &img, int distance, float strength, float rendererScale)
 Applies eye dome lighting effect to the given image. More...
 
QPainter * painter () const
 Returns painter to the underlying QImage with elevations. More...
 
QImage rawElevationImage () const
 Returns raw elevation image with elevations encoded as color values. More...
 

Static Public Member Functions

static float decodeElevation (QRgb colorRaw)
 Converts a color back to elevation value. More...
 
static QRgb encodeElevation (float z)
 Converts elevation value to an actual color. More...
 
static std::unique_ptr< QgsElevationMapfromRasterBlock (QgsRasterBlock *block)
 Creates an elevation map based on data from the given raster block. More...
 

Detailed Description

Stores digital elevation model in a raster image which may get updated as a part of map layer rendering process.

Afterwards the elevations can be used for post-processing effects of the rendered color map image.

Elevations are encoded as colors in QImage, thanks to this it is not only possible to set elevation for each pixel, but also to use QPainter for more complex updates of elevations. We encode elevations to 24 bits in range of [-8000, 8777] with precision of three decimal digits, which should give millimiter precision and enough range for elevation values in meters.

Since
QGIS 3.28

Definition at line 42 of file qgselevationmap.h.

Constructor & Destructor Documentation

◆ QgsElevationMap()

QgsElevationMap::QgsElevationMap ( const QSize &  size)
explicit

Constructs an elevation map with the given width and height.

Definition at line 29 of file qgselevationmap.cpp.

Member Function Documentation

◆ applyEyeDomeLighting()

void QgsElevationMap::applyEyeDomeLighting ( QImage &  img,
int  distance,
float  strength,
float  rendererScale 
)

Applies eye dome lighting effect to the given image.

The effect makes angled surfaces darker and adds silhouettes in case of larger differences of elevations between neighboring pixels.

The distance parameter tells how many pixels away from the original pixel to sample neighboring pixels. Normally distance of 2 pixels gives good results.

The strength parameter adjusts how strong the added shading will be. Good default for this value seems to be 1000.

The zScale parameter adjusts scale of elevation values. It is recommended to set this to the map's scale denominator to get similarly looking results at different map scales.

Definition at line 68 of file qgselevationmap.cpp.

◆ decodeElevation()

float QgsElevationMap::decodeElevation ( QRgb  colorRaw)
static

Converts a color back to elevation value.

Definition at line 44 of file qgselevationmap.cpp.

◆ encodeElevation()

QRgb QgsElevationMap::encodeElevation ( float  z)
static

Converts elevation value to an actual color.

Definition at line 37 of file qgselevationmap.cpp.

◆ fromRasterBlock()

std::unique_ptr< QgsElevationMap > QgsElevationMap::fromRasterBlock ( QgsRasterBlock block)
static

Creates an elevation map based on data from the given raster block.

Definition at line 50 of file qgselevationmap.cpp.

◆ painter()

QPainter * QgsElevationMap::painter ( ) const
inline

Returns painter to the underlying QImage with elevations.

Definition at line 69 of file qgselevationmap.h.

◆ rawElevationImage()

QImage QgsElevationMap::rawElevationImage ( ) const
inline

Returns raw elevation image with elevations encoded as color values.

Definition at line 66 of file qgselevationmap.h.


The documentation for this class was generated from the following files: