QGIS API Documentation 3.41.0-Master (45a0abf3bec)
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | List of all members
QgsTileMatrixSet Class Reference

Defines a set of tile matrices for multiple zoom levels. More...

#include <qgstiles.h>

Inheritance diagram for QgsTileMatrixSet:
Inheritance graph
[legend]

Public Member Functions

 QgsTileMatrixSet ()
 
virtual ~QgsTileMatrixSet ()=default
 
void addGoogleCrs84QuadTiles (int minimumZoom=0, int maximumZoom=14)
 Adds tile matrices corresponding to the standard web mercator/GoogleCRS84Quad setup.
 
void addMatrix (const QgsTileMatrix &matrix)
 Adds a matrix to the set.
 
double calculateTileScaleForMap (double actualMapScale, const QgsCoordinateReferenceSystem &mapCrs, const QgsRectangle &mapExtent, const QSize mapSize, const double mapDpi) const
 Calculates the correct scale to use for the tiles when rendered using the specified map properties.
 
QgsCoordinateReferenceSystem crs () const
 Returns the coordinate reference system associated with the tiles.
 
void dropMatricesOutsideZoomRange (int minimumZoom, int maximumZoom)
 Deletes any existing matrices which fall outside the zoom range specified by minimumZoom to maximumZoom, inclusive.
 
bool isEmpty () const
 Returns true if the matrix set is empty.
 
int maximumZoom () const
 Returns the maximum zoom level for tiles present in the set.
 
int minimumZoom () const
 Returns the minimum zoom level for tiles present in the set.
 
virtual bool readXml (const QDomElement &element, QgsReadWriteContext &context)
 Reads the set from an XML element.
 
QgsTileMatrix rootMatrix () const
 Returns the root tile matrix (usually corresponding to zoom level 0).
 
double scaleForRenderContext (const QgsRenderContext &context) const
 Calculates the correct scale to use for the tiles when rendered using the specified render context.
 
Qgis::ScaleToTileZoomLevelMethod scaleToTileZoomMethod () const
 Returns the scale to tile zoom method.
 
double scaleToZoom (double scale) const
 Calculates a fractional zoom level given a map scale denominator.
 
int scaleToZoomLevel (double scale, bool clamp=true) const
 Finds the best fitting (integer) zoom level given a map scale denominator.
 
void setRootMatrix (const QgsTileMatrix &matrix)
 Sets the root tile matrix (usually corresponding to zoom level 0).
 
void setScaleToTileZoomMethod (Qgis::ScaleToTileZoomLevelMethod method)
 Sets the scale to tile zoom method.
 
Qgis::TileAvailability tileAvailability (QgsTileXYZ id) const
 Returns the availability of the given tile in this matrix.
 
QgsTileMatrix tileMatrix (int zoom) const
 Returns the tile matrix corresponding to the specified zoom.
 
QVector< QgsTileXYZtilesInRange (QgsTileRange range, int zoomLevel) const
 Returns a list of tiles in the given tile range.
 
virtual QDomElement writeXml (QDomDocument &document, const QgsReadWriteContext &context) const
 Writes the set to an XML element.
 

Protected Attributes

QgsTileMatrix mRootMatrix
 
Qgis::ScaleToTileZoomLevelMethod mScaleToTileZoomMethod = Qgis::ScaleToTileZoomLevelMethod::MapBox
 
std::function< Qgis::TileAvailability(QgsTileXYZ id) > mTileAvailabilityFunction
 
QMap< int, QgsTileMatrixmTileMatrices
 
std::function< Qgis::TileAvailability(QgsTileXYZ id, QgsTileXYZ &replacement) > mTileReplacementFunction
 

Detailed Description

Defines a set of tile matrices for multiple zoom levels.

Since
QGIS 3.22.6

Definition at line 251 of file qgstiles.h.

Constructor & Destructor Documentation

◆ QgsTileMatrixSet()

QgsTileMatrixSet::QgsTileMatrixSet ( )

Definition at line 132 of file qgstiles.cpp.

◆ ~QgsTileMatrixSet()

virtual QgsTileMatrixSet::~QgsTileMatrixSet ( )
virtualdefault

Member Function Documentation

◆ addGoogleCrs84QuadTiles()

void QgsTileMatrixSet::addGoogleCrs84QuadTiles ( int  minimumZoom = 0,
int  maximumZoom = 14 
)

Adds tile matrices corresponding to the standard web mercator/GoogleCRS84Quad setup.

Definition at line 143 of file qgstiles.cpp.

◆ addMatrix()

void QgsTileMatrixSet::addMatrix ( const QgsTileMatrix matrix)

Adds a matrix to the set.

Any existing matrix with the same QgsTileMatrix::zoomLevel() will be replaced.

Definition at line 171 of file qgstiles.cpp.

◆ calculateTileScaleForMap()

double QgsTileMatrixSet::calculateTileScaleForMap ( double  actualMapScale,
const QgsCoordinateReferenceSystem mapCrs,
const QgsRectangle mapExtent,
const QSize  mapSize,
const double  mapDpi 
) const

Calculates the correct scale to use for the tiles when rendered using the specified map properties.

Since
QGIS 3.26

Definition at line 308 of file qgstiles.cpp.

◆ crs()

QgsCoordinateReferenceSystem QgsTileMatrixSet::crs ( ) const

Returns the coordinate reference system associated with the tiles.

In the case of a tile set containing mixed CRS at different zoom levels this method will return the crs of the minimum zoom tile matrix.

Definition at line 218 of file qgstiles.cpp.

◆ dropMatricesOutsideZoomRange()

void QgsTileMatrixSet::dropMatricesOutsideZoomRange ( int  minimumZoom,
int  maximumZoom 
)

Deletes any existing matrices which fall outside the zoom range specified by minimumZoom to maximumZoom, inclusive.

Definition at line 198 of file qgstiles.cpp.

◆ isEmpty()

bool QgsTileMatrixSet::isEmpty ( ) const

Returns true if the matrix set is empty.

Definition at line 138 of file qgstiles.cpp.

◆ maximumZoom()

int QgsTileMatrixSet::maximumZoom ( ) const

Returns the maximum zoom level for tiles present in the set.

See also
minimumZoom()

Definition at line 187 of file qgstiles.cpp.

◆ minimumZoom()

int QgsTileMatrixSet::minimumZoom ( ) const

Returns the minimum zoom level for tiles present in the set.

See also
maximumZoom()

Definition at line 176 of file qgstiles.cpp.

◆ readXml()

bool QgsTileMatrixSet::readXml ( const QDomElement &  element,
QgsReadWriteContext context 
)
virtual

Reads the set from an XML element.

See also
writeXml()

Definition at line 342 of file qgstiles.cpp.

◆ rootMatrix()

QgsTileMatrix QgsTileMatrixSet::rootMatrix ( ) const

Returns the root tile matrix (usually corresponding to zoom level 0).

Since
QGIS 3.28

Definition at line 161 of file qgstiles.cpp.

◆ scaleForRenderContext()

double QgsTileMatrixSet::scaleForRenderContext ( const QgsRenderContext context) const

Calculates the correct scale to use for the tiles when rendered using the specified render context.

Since
QGIS 3.26

Definition at line 299 of file qgstiles.cpp.

◆ scaleToTileZoomMethod()

Qgis::ScaleToTileZoomLevelMethod QgsTileMatrixSet::scaleToTileZoomMethod ( ) const
inline

Returns the scale to tile zoom method.

See also
setScaleToTileZoomMethod()

Definition at line 389 of file qgstiles.h.

◆ scaleToZoom()

double QgsTileMatrixSet::scaleToZoom ( double  scale) const

Calculates a fractional zoom level given a map scale denominator.

The zoom level will be linearly interpolated between zoom levels present in the set.

Definition at line 226 of file qgstiles.cpp.

◆ scaleToZoomLevel()

int QgsTileMatrixSet::scaleToZoomLevel ( double  scale,
bool  clamp = true 
) const

Finds the best fitting (integer) zoom level given a map scale denominator.

An optional clamp parameter can be set to false to disable clamping zoom level to the tile matrix set's minimum and maximum zoom level.

Values are constrained to the zoom levels between minimumZoom() and maximumZoom().

Definition at line 283 of file qgstiles.cpp.

◆ setRootMatrix()

void QgsTileMatrixSet::setRootMatrix ( const QgsTileMatrix matrix)

Sets the root tile matrix (usually corresponding to zoom level 0).

Since
QGIS 3.28

Definition at line 166 of file qgstiles.cpp.

◆ setScaleToTileZoomMethod()

void QgsTileMatrixSet::setScaleToTileZoomMethod ( Qgis::ScaleToTileZoomLevelMethod  method)
inline

Sets the scale to tile zoom method.

See also
scaleToTileZoomMethod()

Definition at line 396 of file qgstiles.h.

◆ tileAvailability()

Qgis::TileAvailability QgsTileMatrixSet::tileAvailability ( QgsTileXYZ  id) const

Returns the availability of the given tile in this matrix.

This method can be used to determine whether a particular tile actually exists within the matrix, or is not available (e.g. due to holes within the matrix).

This method returns Qgis::TileAvailability::Available by default, unless specific tile availability is known for the given id.

Since
QGIS 3.32

Definition at line 213 of file qgstiles.cpp.

◆ tileMatrix()

QgsTileMatrix QgsTileMatrixSet::tileMatrix ( int  zoom) const

Returns the tile matrix corresponding to the specified zoom.

Definition at line 156 of file qgstiles.cpp.

◆ tilesInRange()

QVector< QgsTileXYZ > QgsTileMatrixSet::tilesInRange ( QgsTileRange  range,
int  zoomLevel 
) const

Returns a list of tiles in the given tile range.

Since
QGIS 3.32

Definition at line 428 of file qgstiles.cpp.

◆ writeXml()

QDomElement QgsTileMatrixSet::writeXml ( QDomDocument &  document,
const QgsReadWriteContext context 
) const
virtual

Writes the set to an XML element.

Definition at line 391 of file qgstiles.cpp.

Member Data Documentation

◆ mRootMatrix

QgsTileMatrix QgsTileMatrixSet::mRootMatrix
protected

Definition at line 410 of file qgstiles.h.

◆ mScaleToTileZoomMethod

Qgis::ScaleToTileZoomLevelMethod QgsTileMatrixSet::mScaleToTileZoomMethod = Qgis::ScaleToTileZoomLevelMethod::MapBox
protected

Definition at line 412 of file qgstiles.h.

◆ mTileAvailabilityFunction

std::function< Qgis::TileAvailability( QgsTileXYZ id ) > QgsTileMatrixSet::mTileAvailabilityFunction
protected

Definition at line 406 of file qgstiles.h.

◆ mTileMatrices

QMap< int, QgsTileMatrix > QgsTileMatrixSet::mTileMatrices
protected

Definition at line 411 of file qgstiles.h.

◆ mTileReplacementFunction

std::function< Qgis::TileAvailability( QgsTileXYZ id, QgsTileXYZ &replacement ) > QgsTileMatrixSet::mTileReplacementFunction
protected

Definition at line 407 of file qgstiles.h.


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