Skip to content

Class Quick3DTerrainProvider

ClassList > Quick3DTerrainProvider

More...

  • #include <quick3dterrainprovider.h>

Inherits the following classes: QObject

Public Properties

Type Name
property QgsRectangle extent
Geographic extent used for terrain data.
property bool forceSquareSize
Whether the extent's shorter side will be expanded to form a square terrain.
property QSize gridSize
Grid dimensions (width x height) for terrain sampling.
property bool isLoading
Whether terrain data is currently being loaded.
property bool isTransitioning
Whether a transition to apply pan/zoom offsets has begun.
property QgsQuickMapSettings * mapSettings
The map settings from which to get extent for terrain generation.
property QVariantList normalizedData
Normalized height data array [0.0-1.0] for terrain mesh generation.
property QgsRectangle normalizedDataExtent
Geographic extent used for terrain data.
property double offsetScale
Offset scale from the last generated terrain data.
property QVector3D offsetVector
Offset vector from the last generated terrain data.
property QgsProject * project
The project from which to read the terrain configuration and DEM layer.
property QSizeF size
Size of the terrain.

Public Signals

Type Name
signal void extentChanged
signal void forceSquareSizeChanged
signal void gridSizeChanged
signal void isLoadingChanged
signal void isTransitioningChanged
signal void mapSettingsChanged
signal void normalizedDataChanged
signal void offsetScaleChanged
signal void offsetVectorChanged
signal void projectChanged
signal void terrainDataReady
Emitted when terrain data has been successfully loaded and is ready for use.

Public Functions

Type Name
Quick3DTerrainProvider (QObject * parent=nullptr)
Creates a new terrain provider.
Q_INVOKABLE void beginTransition ()
Regenerates the extent and terrain data from current offset.
Q_INVOKABLE void endTransition ()
Applies offsets and reset values to zeros.
QgsRectangle extent () const
Returns the current extent taking into account offsets.
bool forceSquareSize () const
Q_INVOKABLE QVector3D geoTo3D (double geoX, double geoY, float heightOffset=0.0f) const
QSize gridSize () const
Returns the grid dimensions for terrain sampling.
Q_INVOKABLE double heightAt (double x, double y) const
bool isLoading () const
Returns TRUE if terrain data is currently being loaded.
bool isTransitioning () const
QgsQuickMapSettings * mapSettings () const
Returns the map settings.
QVariantList normalizedData () const
Returns the normalized height data array [0.0-1.0].
QgsRectangle normalizedDataExtent () const
Returns the geographic extent for the retrieved terrain data.
Q_INVOKABLE double normalizedHeightAt (double x, double y) const
double offsetScale () const
Returns the offset scale from the last generated terrain data.
QVector3D offsetVector () const
Returns the offset scale from the last generated terrain data.
Q_INVOKABLE void pan (double x, double z)
Applies X/Z offsets to the stored terrain based on pan action.
QgsProject * project () const
Returns the project from which to read terrain configuration and DEM layer.
void setForceSquareSize (bool forceSquareSize)
void setMapSettings (QgsQuickMapSettings * mapSettings)
Sets the map settings.
void setProject (QgsProject * project)
Sets the project.
QSizeF size () const
Returns the size of the terrain.
Q_INVOKABLE void zoom (double factor)
Applies scale offset to the stored terrain based on zoom action.
~Quick3DTerrainProvider () override

Detailed Description

Provides terrain elevation data for 3D visualization from DEM raster layers or online elevation services.

This class handles elevation data retrieval from either a project's DEM raster layer or falls back to QGIS terrain providers (e.g., online Terrarium tiles) when no DEM is available. The data is normalized and provided as height samples for terrain mesh generation in Qt Quick 3D.

Note:

QML Type: Quick3DTerrainProvider

Public Properties Documentation

property extent [1/2]

Geographic extent used for terrain data.

QgsRectangle Quick3DTerrainProvider::extent;

property forceSquareSize [1/2]

Whether the extent's shorter side will be expanded to form a square terrain.

bool Quick3DTerrainProvider::forceSquareSize;

property gridSize [1/2]

Grid dimensions (width x height) for terrain sampling.

QSize Quick3DTerrainProvider::gridSize;

property isLoading [1/2]

Whether terrain data is currently being loaded.

bool Quick3DTerrainProvider::isLoading;

property isTransitioning [1/2]

Whether a transition to apply pan/zoom offsets has begun.

bool Quick3DTerrainProvider::isTransitioning;

property mapSettings [1/2]

The map settings from which to get extent for terrain generation.

QgsQuickMapSettings * Quick3DTerrainProvider::mapSettings;

property normalizedData [1/2]

Normalized height data array [0.0-1.0] for terrain mesh generation.

QVariantList Quick3DTerrainProvider::normalizedData;

property normalizedDataExtent [1/2]

Geographic extent used for terrain data.

QgsRectangle Quick3DTerrainProvider::normalizedDataExtent;

property offsetScale [1/2]

Offset scale from the last generated terrain data.

double Quick3DTerrainProvider::offsetScale;

property offsetVector [1/2]

Offset vector from the last generated terrain data.

QVector3D Quick3DTerrainProvider::offsetVector;

property project [1/2]

The project from which to read the terrain configuration and DEM layer.

QgsProject * Quick3DTerrainProvider::project;

property size [1/2]

Size of the terrain.

QSizeF Quick3DTerrainProvider::size;

Public Signals Documentation

signal extentChanged

void Quick3DTerrainProvider::extentChanged;

signal forceSquareSizeChanged

void Quick3DTerrainProvider::forceSquareSizeChanged;

signal gridSizeChanged

void Quick3DTerrainProvider::gridSizeChanged;

signal isLoadingChanged

void Quick3DTerrainProvider::isLoadingChanged;

signal isTransitioningChanged

void Quick3DTerrainProvider::isTransitioningChanged;

signal mapSettingsChanged

void Quick3DTerrainProvider::mapSettingsChanged;

signal normalizedDataChanged

void Quick3DTerrainProvider::normalizedDataChanged;

signal offsetScaleChanged

void Quick3DTerrainProvider::offsetScaleChanged;

signal offsetVectorChanged

void Quick3DTerrainProvider::offsetVectorChanged;

signal projectChanged

void Quick3DTerrainProvider::projectChanged;

signal terrainDataReady

Emitted when terrain data has been successfully loaded and is ready for use.

void Quick3DTerrainProvider::terrainDataReady;

Public Functions Documentation

function Quick3DTerrainProvider

Creates a new terrain provider.

explicit Quick3DTerrainProvider::Quick3DTerrainProvider (
    QObject * parent=nullptr
) 

function beginTransition

Regenerates the extent and terrain data from current offset.

Q_INVOKABLE void Quick3DTerrainProvider::beginTransition () 

function endTransition

Applies offsets and reset values to zeros.

Q_INVOKABLE void Quick3DTerrainProvider::endTransition () 

function extent [2/2]

Returns the current extent taking into account offsets.

inline QgsRectangle Quick3DTerrainProvider::extent () const

function forceSquareSize [2/2]

bool Quick3DTerrainProvider::forceSquareSize () const

function geoTo3D

Q_INVOKABLE QVector3D Quick3DTerrainProvider::geoTo3D (
    double geoX,
    double geoY,
    float heightOffset=0.0f
) const

Converts geographic coordinates to a 3D scene position.

Parameters:

  • geoX X coordinate in map CRS
  • geoY Y coordinate in map CRS
  • heightOffset additional vertical offset (default 0)

Returns:

3D position in scene space, or a null vector if the extent is invalid


function gridSize [2/2]

Returns the grid dimensions for terrain sampling.

inline QSize Quick3DTerrainProvider::gridSize () const

function heightAt

Q_INVOKABLE double Quick3DTerrainProvider::heightAt (
    double x,
    double y
) const

Returns the real height value at the specified map coordinates.

Parameters:

  • x X coordinate in map CRS
  • y Y coordinate in map CRS

Returns:

Height in map units, or 0 if outside extent


function isLoading [2/2]

Returns TRUE if terrain data is currently being loaded.

bool Quick3DTerrainProvider::isLoading () const

function isTransitioning [2/2]

inline bool Quick3DTerrainProvider::isTransitioning () const

function mapSettings [2/2]

Returns the map settings.

QgsQuickMapSettings * Quick3DTerrainProvider::mapSettings () const

function normalizedData [2/2]

Returns the normalized height data array [0.0-1.0].

QVariantList Quick3DTerrainProvider::normalizedData () const

function normalizedDataExtent [2/2]

Returns the geographic extent for the retrieved terrain data.

inline QgsRectangle Quick3DTerrainProvider::normalizedDataExtent () const

function normalizedHeightAt

Q_INVOKABLE double Quick3DTerrainProvider::normalizedHeightAt (
    double x,
    double y
) const

Returns the normalized height value [0.0-1.0] at the specified map coordinates.

Parameters:

  • x X coordinate in map CRS
  • y Y coordinate in map CRS

Returns:

Normalized height between 0 and 1, or 0 if outside extent


function offsetScale [2/2]

Returns the offset scale from the last generated terrain data.

inline double Quick3DTerrainProvider::offsetScale () const

function offsetVector [2/2]

Returns the offset scale from the last generated terrain data.

inline QVector3D Quick3DTerrainProvider::offsetVector () const

function pan

Applies X/Z offsets to the stored terrain based on pan action.

Q_INVOKABLE void Quick3DTerrainProvider::pan (
    double x,
    double z
) 

function project [2/2]

Returns the project from which to read terrain configuration and DEM layer.

QgsProject * Quick3DTerrainProvider::project () const

function setForceSquareSize

void Quick3DTerrainProvider::setForceSquareSize (
    bool forceSquareSize
) 

function setMapSettings

Sets the map settings.

void Quick3DTerrainProvider::setMapSettings (
    QgsQuickMapSettings * mapSettings
) 

function setProject

Sets the project.

void Quick3DTerrainProvider::setProject (
    QgsProject * project
) 

function size [2/2]

Returns the size of the terrain.

inline QSizeF Quick3DTerrainProvider::size () const

function zoom

Applies scale offset to the stored terrain based on zoom action.

Q_INVOKABLE void Quick3DTerrainProvider::zoom (
    double factor
) 

function ~Quick3DTerrainProvider

Quick3DTerrainProvider::~Quick3DTerrainProvider () override


The documentation for this class was generated from the following file src/core/3d/quick3dterrainprovider.h