QGIS API Documentation 3.41.0-Master (3440c17df1d)
Loading...
Searching...
No Matches
qgstiles.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgstiles.cpp
3 --------------------------------------
4 Date : March 2020
5 Copyright : (C) 2020 by Martin Dobias
6 Email : wonder dot sk at gmail dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
16#include "qgstiles.h"
17
18#include "qgslogger.h"
20#include "qgsrendercontext.h"
21#include "qgsunittypes.h"
22
24{
25 constexpr double z0xMin = -20037508.3427892;
26 constexpr double z0yMax = 20037508.3427892;
27
28 return fromCustomDef( zoomLevel, QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3857" ) ), QgsPointXY( z0xMin, z0yMax ), 2 * z0yMax );
29}
30
32 const QgsPointXY &z0TopLeftPoint, double z0Dimension, int z0MatrixWidth, int z0MatrixHeight )
33{
34 // Square extent calculation
35 double z0xMin = z0TopLeftPoint.x();
36 double z0yMax = z0TopLeftPoint.y();
37 double z0xMax = z0xMin + z0MatrixWidth * z0Dimension;
38 double z0yMin = z0yMax - z0MatrixHeight * z0Dimension;
39
40 // Constant for scale denominator calculation
41 constexpr double TILE_SIZE = 256.0;
42 constexpr double PIXELS_TO_M = 2.8 / 10000.0; // WMS/WMTS define "standardized rendering pixel size" as 0.28mm
44 // Scale denominator calculation
45 const double scaleDenom0 = ( z0Dimension / TILE_SIZE ) * ( unitToMeters / PIXELS_TO_M );
46
47 int numTiles = static_cast<int>( pow( 2, zoomLevel ) ); // assuming we won't ever go over 30 zoom levels
48
50 tm.mCrs = crs;
51 tm.mZoomLevel = zoomLevel;
52 tm.mMatrixWidth = z0MatrixWidth * numTiles;
53 tm.mMatrixHeight = z0MatrixHeight * numTiles;
54 tm.mTileXSpan = ( z0xMax - z0xMin ) / tm.mMatrixWidth;
55 tm.mTileYSpan = ( z0yMax - z0yMin ) / tm.mMatrixHeight;
56 tm.mExtent = QgsRectangle( z0xMin, z0yMin, z0xMax, z0yMax );
57 tm.mScaleDenom = scaleDenom0 / pow( 2, zoomLevel );
58 return tm;
59}
60
61QgsTileMatrix QgsTileMatrix::fromTileMatrix( const int zoomLevel, const QgsTileMatrix &tileMatrix )
62{
64 int numTiles = static_cast<int>( pow( 2, zoomLevel ) ); // assuming we won't ever go over 30 zoom levels
65 int aZoomLevel = tileMatrix.zoomLevel();
66 int aNumTiles = static_cast<int>( pow( 2, aZoomLevel ) );
67 int aMatrixWidth = tileMatrix.matrixWidth();
68 int aMatrixHeight = tileMatrix.matrixHeight();
69 QgsRectangle aExtent = tileMatrix.extent();
70 tm.mCrs = tileMatrix.crs();
71 tm.mZoomLevel = zoomLevel;
72 tm.mMatrixWidth = aMatrixWidth * numTiles / aNumTiles;
73 tm.mMatrixHeight = aMatrixHeight * numTiles / aNumTiles;
74 tm.mTileXSpan = aExtent.width() / tm.mMatrixWidth;
75 tm.mTileYSpan = aExtent.height() / tm.mMatrixHeight;
76 tm.mExtent = aExtent;
77 tm.mScaleDenom = tileMatrix.scale() * pow( 2, aZoomLevel ) / pow( 2, zoomLevel );
78 return tm;
79}
80
82{
83 double xMin = mExtent.xMinimum() + mTileXSpan * id.column();
84 double xMax = xMin + mTileXSpan;
85 double yMax = mExtent.yMaximum() - mTileYSpan * id.row();
86 double yMin = yMax - mTileYSpan;
87 return QgsRectangle( xMin, yMin, xMax, yMax );
88}
89
91{
92 double x = mExtent.xMinimum() + mTileXSpan * id.column() + mTileXSpan / 2;
93 double y = mExtent.yMaximum() - mTileYSpan * id.row() - mTileYSpan / 2;
94 return QgsPointXY( x, y );
95}
96
98{
99 double x0 = std::clamp( r.xMinimum(), mExtent.xMinimum(), mExtent.xMaximum() );
100 double y0 = std::clamp( r.yMinimum(), mExtent.yMinimum(), mExtent.yMaximum() );
101 double x1 = std::clamp( r.xMaximum(), mExtent.xMinimum(), mExtent.xMaximum() );
102 double y1 = std::clamp( r.yMaximum(), mExtent.yMinimum(), mExtent.yMaximum() );
103 if ( x0 >= x1 || y0 >= y1 )
104 return QgsTileRange(); // nothing to display
105
106 double tileX1 = ( x0 - mExtent.xMinimum() ) / mTileXSpan;
107 double tileX2 = ( x1 - mExtent.xMinimum() ) / mTileXSpan;
108 double tileY1 = ( mExtent.yMaximum() - y1 ) / mTileYSpan;
109 double tileY2 = ( mExtent.yMaximum() - y0 ) / mTileYSpan;
110
111 QgsDebugMsgLevel( QStringLiteral( "Tile range of edges [%1,%2] - [%3,%4]" ).arg( tileX1 ).arg( tileY1 ).arg( tileX2 ).arg( tileY2 ), 2 );
112
113 // figure out tile range from zoom
114 int startColumn = std::clamp( static_cast<int>( floor( tileX1 ) ), 0, mMatrixWidth - 1 );
115 int endColumn = std::clamp( static_cast<int>( floor( tileX2 ) ), 0, mMatrixWidth - 1 );
116 int startRow = std::clamp( static_cast<int>( floor( tileY1 ) ), 0, mMatrixHeight - 1 );
117 int endRow = std::clamp( static_cast<int>( floor( tileY2 ) ), 0, mMatrixHeight - 1 );
118 return QgsTileRange( startColumn, endColumn, startRow, endRow );
119}
120
121QPointF QgsTileMatrix::mapToTileCoordinates( const QgsPointXY &mapPoint ) const
122{
123 double dx = mapPoint.x() - mExtent.xMinimum();
124 double dy = mExtent.yMaximum() - mapPoint.y();
125 return QPointF( dx / mTileXSpan, dy / mTileYSpan );
126}
127
128//
129// QgsTileMatrixSet
130//
131
137
139{
140 return mTileMatrices.isEmpty();
141}
142
143void QgsTileMatrixSet::addGoogleCrs84QuadTiles( int minimumZoom, int maximumZoom )
144{
145 if ( maximumZoom < minimumZoom )
146 std::swap( minimumZoom, maximumZoom );
147
148 for ( int zoom = minimumZoom; zoom <= maximumZoom; ++zoom )
149 {
151 }
152
154}
155
157{
158 return mTileMatrices.value( zoom );
159}
160
165
167{
168 mRootMatrix = matrix;
169}
170
172{
173 mTileMatrices.insert( matrix.zoomLevel(), matrix );
174}
175
177{
178 int res = -1;
179 for ( auto it = mTileMatrices.constBegin(); it != mTileMatrices.constEnd(); ++it )
180 {
181 if ( res == -1 || it->zoomLevel() < res )
182 res = it->zoomLevel();
183 }
184 return res;
185}
186
188{
189 int res = -1;
190 for ( auto it = mTileMatrices.constBegin(); it != mTileMatrices.constEnd(); ++it )
191 {
192 if ( res == -1 || it->zoomLevel() > res )
193 res = it->zoomLevel();
194 }
195 return res;
196}
197
198void QgsTileMatrixSet::dropMatricesOutsideZoomRange( int minimumZoom, int maximumZoom )
199{
200 for ( auto it = mTileMatrices.begin(); it != mTileMatrices.end(); )
201 {
202 if ( it->zoomLevel() < minimumZoom || it->zoomLevel() > maximumZoom )
203 {
204 it = mTileMatrices.erase( it );
205 }
206 else
207 {
208 ++it;
209 }
210 }
211}
212
217
219{
220 if ( mTileMatrices.empty() )
222
223 return mTileMatrices.value( minimumZoom() ).crs();
224}
225
226double QgsTileMatrixSet::scaleToZoom( double scale ) const
227{
228 int zoomUnder = -1;
229 int zoomOver = -1;
230 double scaleUnder = 0;
231 double scaleOver = 0;
232
233 switch ( mScaleToTileZoomMethod )
234 {
236 {
237 // TODO: it seems that map scale is double (is that because of high-dpi screen?)
238 // (this TODO was taken straight from QgsVectorTileUtils::scaleToZoom!)
239 scale *= 2;
240 break;
241 }
243 break;
244 }
245
246 for ( auto it = mTileMatrices.constBegin(); it != mTileMatrices.constEnd(); ++it )
247 {
248 if ( it->scale() > scale && ( zoomUnder == -1 || zoomUnder < it->zoomLevel() ) )
249 {
250 zoomUnder = it->zoomLevel();
251 scaleUnder = it->scale();
252 }
253 if ( it->scale() < scale && ( zoomOver == -1 || zoomOver > it->zoomLevel() ) )
254 {
255 zoomOver = it->zoomLevel();
256 scaleOver = it->scale();
257 }
258 }
259
260 if ( zoomUnder < 0 )
261 return zoomOver;
262 if ( zoomOver < 0 )
263 {
264 // allow overzooming, so the styling is applied correctly
265 scaleOver = tileMatrix( maximumZoom() ).scale() / 2;
266 zoomOver = maximumZoom() + 1;
267 while ( true )
268 {
269 if ( scaleOver < scale && scale < scaleUnder )
270 {
271 return ( scaleUnder - scale ) / ( scaleUnder - scaleOver ) * ( zoomOver - zoomUnder ) + zoomUnder;
272 }
273 scaleUnder = scaleOver;
274 zoomUnder = zoomOver;
275 scaleOver = scaleOver / 2;
276 zoomOver += 1;
277 }
278 }
279 else
280 return ( scaleUnder - scale ) / ( scaleUnder - scaleOver ) * ( zoomOver - zoomUnder ) + zoomUnder;
281}
282
283int QgsTileMatrixSet::scaleToZoomLevel( double scale, bool clamp ) const
284{
285 int tileZoom = 0;
286 switch ( mScaleToTileZoomMethod )
287 {
289 tileZoom = static_cast<int>( round( scaleToZoom( scale ) ) );
290 break;
292 tileZoom = static_cast<int>( floor( scaleToZoom( scale ) ) );
293 break;
294 }
295
296 return clamp ? std::clamp( tileZoom, minimumZoom(), maximumZoom() ) : tileZoom;
297}
298
300{
301 return calculateTileScaleForMap( context.rendererScale(),
303 context.mapExtent(),
304 context.outputSize(),
305 context.painter()->device()->logicalDpiX() );
306}
307
308double QgsTileMatrixSet::calculateTileScaleForMap( double actualMapScale, const QgsCoordinateReferenceSystem &mapCrs, const QgsRectangle &mapExtent, const QSize mapSize, const double mapDpi ) const
309{
310 switch ( mScaleToTileZoomMethod )
311 // cppcheck-suppress missingReturn
312 {
314 return actualMapScale;
315
317 if ( mapCrs.isGeographic() )
318 {
319 // ESRI calculates the scale for geographic CRS ***ALWAYS*** at the equator, regardless of map extent!
320 // see https://support.esri.com/en/technical-article/000007211, https://gis.stackexchange.com/questions/33270/how-does-arcmap-calculate-scalebar-inside-a-wgs84-layout
321 constexpr double METERS_PER_DEGREE = M_PI / 180.0 * 6378137;
322 constexpr double INCHES_PER_METER = 39.370078;
323 const double mapWidthInches = mapExtent.width() * METERS_PER_DEGREE * INCHES_PER_METER;
324
325 double scale = mapWidthInches * mapDpi / static_cast< double >( mapSize.width() );
326
327 // Note: I **think** there's also some magic which ESRI applies when rendering tiles ON SCREEN,
328 // which may be something like adjusting the scale based on the ratio between the map DPI and 96 DPI,
329 // e.g. scale *= mapDpi / 96.0;
330 // BUT the same adjustment isn't applied when exporting maps. This needs further investigation!
331
332 return scale;
333 }
334 else
335 {
336 return actualMapScale;
337 }
338 }
340}
341
342bool QgsTileMatrixSet::readXml( const QDomElement &element, QgsReadWriteContext & )
343{
344 mTileMatrices.clear();
345
346 mScaleToTileZoomMethod = qgsEnumKeyToValue( element.attribute( QStringLiteral( "scaleToZoomMethod" ) ), Qgis::ScaleToTileZoomLevelMethod::MapBox );
347
348 auto readMatrixFromElement = []( const QDomElement & matrixElement )->QgsTileMatrix
349 {
350 QgsTileMatrix matrix;
351 matrix.mZoomLevel = matrixElement.attribute( QStringLiteral( "zoomLevel" ) ).toInt();
352 matrix.mMatrixWidth = matrixElement.attribute( QStringLiteral( "matrixWidth" ) ).toInt();
353 matrix.mMatrixHeight = matrixElement.attribute( QStringLiteral( "matrixHeight" ) ).toInt();
354 matrix.mExtent = QgsRectangle(
355 matrixElement.attribute( QStringLiteral( "xMin" ) ).toDouble(),
356 matrixElement.attribute( QStringLiteral( "yMin" ) ).toDouble(),
357 matrixElement.attribute( QStringLiteral( "xMax" ) ).toDouble(),
358 matrixElement.attribute( QStringLiteral( "yMax" ) ).toDouble()
359 );
360
361 matrix.mScaleDenom = matrixElement.attribute( QStringLiteral( "scale" ) ).toDouble();
362 matrix.mTileXSpan = matrixElement.attribute( QStringLiteral( "tileXSpan" ) ).toDouble();
363 matrix.mTileYSpan = matrixElement.attribute( QStringLiteral( "tileYSpan" ) ).toDouble();
364 matrix.mCrs.readXml( matrixElement );
365 return matrix;
366 };
367
368 const QDomNodeList children = element.childNodes();
369 for ( int i = 0; i < children.size(); i++ )
370 {
371 const QDomElement matrixElement = children.at( i ).toElement();
372 if ( matrixElement.tagName() == QLatin1String( "rootMatrix" ) )
373 continue;
374
375 QgsTileMatrix matrix = readMatrixFromElement( matrixElement );
376 if ( matrix.zoomLevel() == 0 ) // old project compatibility
377 mRootMatrix = matrix;
378
379 addMatrix( matrix );
380 }
381
382 const QDomElement rootElement = element.firstChildElement( QStringLiteral( "rootMatrix" ) );
383 if ( !rootElement.isNull() )
384 {
385 mRootMatrix = readMatrixFromElement( rootElement );
386 }
387
388 return true;
389}
390
391QDomElement QgsTileMatrixSet::writeXml( QDomDocument &document, const QgsReadWriteContext & ) const
392{
393 QDomElement setElement = document.createElement( QStringLiteral( "matrixSet" ) );
394 setElement.setAttribute( QStringLiteral( "scaleToZoomMethod" ), qgsEnumValueToKey( mScaleToTileZoomMethod ) );
395
396 auto writeMatrixToElement = [&document]( const QgsTileMatrix & matrix, QDomElement & matrixElement )
397 {
398 matrixElement.setAttribute( QStringLiteral( "zoomLevel" ), matrix.zoomLevel() );
399 matrixElement.setAttribute( QStringLiteral( "matrixWidth" ), matrix.matrixWidth() );
400 matrixElement.setAttribute( QStringLiteral( "matrixHeight" ), matrix.matrixHeight() );
401
402 matrixElement.setAttribute( QStringLiteral( "xMin" ), qgsDoubleToString( matrix.mExtent.xMinimum() ) );
403 matrixElement.setAttribute( QStringLiteral( "xMax" ), qgsDoubleToString( matrix.mExtent.xMaximum() ) );
404 matrixElement.setAttribute( QStringLiteral( "yMin" ), qgsDoubleToString( matrix.mExtent.yMinimum() ) );
405 matrixElement.setAttribute( QStringLiteral( "yMax" ), qgsDoubleToString( matrix.mExtent.yMaximum() ) );
406
407 matrixElement.setAttribute( QStringLiteral( "scale" ), qgsDoubleToString( matrix.scale() ) );
408 matrixElement.setAttribute( QStringLiteral( "tileXSpan" ), qgsDoubleToString( matrix.mTileXSpan ) );
409 matrixElement.setAttribute( QStringLiteral( "tileYSpan" ), qgsDoubleToString( matrix.mTileYSpan ) );
410
411 matrix.crs().writeXml( matrixElement, document );
412 };
413
414 for ( auto it = mTileMatrices.constBegin(); it != mTileMatrices.constEnd(); ++it )
415 {
416 QDomElement matrixElement = document.createElement( QStringLiteral( "matrix" ) );
417 writeMatrixToElement( *it, matrixElement );
418 setElement.appendChild( matrixElement );
419 }
420
421 QDomElement rootElement = document.createElement( QStringLiteral( "rootMatrix" ) );
422 writeMatrixToElement( mRootMatrix, rootElement );
423 setElement.appendChild( rootElement );
424
425 return setElement;
426}
427
428QVector<QgsTileXYZ> QgsTileMatrixSet::tilesInRange( QgsTileRange range, int zoomLevel ) const
429{
430 QVector<QgsTileXYZ> tiles;
431 tiles.reserve( ( range.endColumn() - range.startColumn() + 1 ) * ( range.endRow() - range.startRow() + 1 ) );
432
433 for ( int tileRow = range.startRow(); tileRow <= range.endRow(); ++tileRow )
434 {
435 for ( int tileColumn = range.startColumn(); tileColumn <= range.endColumn(); ++tileColumn )
436 {
437 QgsTileXYZ tile( tileColumn, tileRow, zoomLevel );
438 QgsTileXYZ replacement;
439 switch ( mTileReplacementFunction( tile, replacement ) )
440 {
442 break;
443
447 if ( !tiles.contains( replacement ) )
448 tiles.append( replacement );
449 break;
450 }
451 }
452 }
453 return tiles;
454}
455
@ Esri
No scale doubling, always rounds down when matching to available tile levels.
@ MapBox
Uses a scale doubling approach to account for hi-DPI tiles, and rounds to the nearest tile level for ...
TileAvailability
Possible availability states for a tile within a tile matrix.
Definition qgis.h:5205
@ UseLowerZoomLevelTile
Tile is not available at the requested zoom level, it should be replaced by a tile from a lower zoom ...
@ NotAvailable
Tile is not available within the matrix, e.g. there is no content for the tile.
@ AvailableNoChildren
Tile is available within the matrix, and is known to have no children (ie no higher zoom level tiles ...
@ Available
Tile is available within the matrix.
This class represents a coordinate reference system (CRS).
bool readXml(const QDomNode &node)
Restores state from the given DOM node.
bool writeXml(QDomNode &node, QDomDocument &doc) const
Stores state to the given Dom node in the given document.
QgsCoordinateReferenceSystem destinationCrs() const
Returns the destination coordinate reference system, which the transform will transform coordinates t...
A class to represent a 2D point.
Definition qgspointxy.h:60
double y
Definition qgspointxy.h:64
double x
Definition qgspointxy.h:63
The class is used as a container of context for various read/write operations on other objects.
A rectangle specified with double values.
double xMinimum
double yMinimum
double xMaximum
double yMaximum
Contains information about the context of a rendering operation.
QPainter * painter()
Returns the destination QPainter for the render operation.
double rendererScale() const
Returns the renderer map scale.
QSize outputSize() const
Returns the size of the resulting rendered image, in pixels.
QgsRectangle mapExtent() const
Returns the original extent of the map being rendered.
QgsCoordinateTransform coordinateTransform() const
Returns the current coordinate transform for the context.
virtual QDomElement writeXml(QDomDocument &document, const QgsReadWriteContext &context) const
Writes the set to an XML element.
Definition qgstiles.cpp:391
Qgis::ScaleToTileZoomLevelMethod mScaleToTileZoomMethod
Definition qgstiles.h:412
void addGoogleCrs84QuadTiles(int minimumZoom=0, int maximumZoom=14)
Adds tile matrices corresponding to the standard web mercator/GoogleCRS84Quad setup.
Definition qgstiles.cpp:143
QgsCoordinateReferenceSystem crs() const
Returns the coordinate reference system associated with the tiles.
Definition qgstiles.cpp:218
std::function< Qgis::TileAvailability(QgsTileXYZ id) > mTileAvailabilityFunction
Definition qgstiles.h:406
double scaleForRenderContext(const QgsRenderContext &context) const
Calculates the correct scale to use for the tiles when rendered using the specified render context.
Definition qgstiles.cpp:299
int minimumZoom() const
Returns the minimum zoom level for tiles present in the set.
Definition qgstiles.cpp:176
double scaleToZoom(double scale) const
Calculates a fractional zoom level given a map scale denominator.
Definition qgstiles.cpp:226
QMap< int, QgsTileMatrix > mTileMatrices
Definition qgstiles.h:411
QVector< QgsTileXYZ > tilesInRange(QgsTileRange range, int zoomLevel) const
Returns a list of tiles in the given tile range.
Definition qgstiles.cpp:428
int maximumZoom() const
Returns the maximum zoom level for tiles present in the set.
Definition qgstiles.cpp:187
QgsTileMatrix tileMatrix(int zoom) const
Returns the tile matrix corresponding to the specified zoom.
Definition qgstiles.cpp:156
Qgis::TileAvailability tileAvailability(QgsTileXYZ id) const
Returns the availability of the given tile in this matrix.
Definition qgstiles.cpp:213
QgsTileMatrix rootMatrix() const
Returns the root tile matrix (usually corresponding to zoom level 0).
Definition qgstiles.cpp:161
virtual bool readXml(const QDomElement &element, QgsReadWriteContext &context)
Reads the set from an XML element.
Definition qgstiles.cpp:342
void addMatrix(const QgsTileMatrix &matrix)
Adds a matrix to the set.
Definition qgstiles.cpp:171
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.
Definition qgstiles.cpp:308
void dropMatricesOutsideZoomRange(int minimumZoom, int maximumZoom)
Deletes any existing matrices which fall outside the zoom range specified by minimumZoom to maximumZo...
Definition qgstiles.cpp:198
bool isEmpty() const
Returns true if the matrix set is empty.
Definition qgstiles.cpp:138
QgsTileMatrix mRootMatrix
Definition qgstiles.h:410
void setRootMatrix(const QgsTileMatrix &matrix)
Sets the root tile matrix (usually corresponding to zoom level 0).
Definition qgstiles.cpp:166
std::function< Qgis::TileAvailability(QgsTileXYZ id, QgsTileXYZ &replacement) > mTileReplacementFunction
Definition qgstiles.h:407
int scaleToZoomLevel(double scale, bool clamp=true) const
Finds the best fitting (integer) zoom level given a map scale denominator.
Definition qgstiles.cpp:283
Defines a matrix of tiles for a single zoom level: it is defined by its size (width *.
Definition qgstiles.h:136
QgsRectangle tileExtent(QgsTileXYZ id) const
Returns extent of the given tile in this matrix.
Definition qgstiles.cpp:81
QPointF mapToTileCoordinates(const QgsPointXY &mapPoint) const
Returns row/column coordinates (floating point number) from the given point in map coordinates.
Definition qgstiles.cpp:121
QgsTileRange tileRangeFromExtent(const QgsRectangle &mExtent) const
Returns tile range that fully covers the given extent.
Definition qgstiles.cpp:97
static QgsTileMatrix fromWebMercator(int zoomLevel)
Returns a tile matrix for the usual web mercator.
Definition qgstiles.cpp:23
QgsRectangle extent() const
Returns extent of the tile matrix.
Definition qgstiles.h:191
int matrixWidth() const
Returns number of columns of the tile matrix.
Definition qgstiles.h:185
QgsCoordinateReferenceSystem crs() const
Returns the crs of the tile matrix.
Definition qgstiles.h:159
double scale() const
Returns scale denominator of the tile matrix.
Definition qgstiles.h:198
QgsPointXY tileCenter(QgsTileXYZ id) const
Returns center of the given tile in this matrix.
Definition qgstiles.cpp:90
int matrixHeight() const
Returns number of rows of the tile matrix.
Definition qgstiles.h:188
static QgsTileMatrix fromTileMatrix(int zoomLevel, const QgsTileMatrix &tileMatrix)
Returns a tile matrix based on another one.
Definition qgstiles.cpp:61
int zoomLevel() const
Returns the zoom level of the tile matrix.
Definition qgstiles.h:174
static QgsTileMatrix fromCustomDef(int zoomLevel, const QgsCoordinateReferenceSystem &crs, const QgsPointXY &z0TopLeftPoint, double z0Dimension, int z0MatrixWidth=1, int z0MatrixHeight=1)
Returns a tile matrix for a specific CRS, top left point, zoom level 0 dimension in CRS units.
Definition qgstiles.cpp:31
Range of tiles in a tile matrix to be rendered.
Definition qgstiles.h:99
int endColumn() const
Returns index of the last column in the range.
Definition qgstiles.h:111
int endRow() const
Returns index of the last row in the range.
Definition qgstiles.h:115
int startRow() const
Returns index of the first row in the range.
Definition qgstiles.h:113
int startColumn() const
Returns index of the first column in the range.
Definition qgstiles.h:109
Stores coordinates of a tile in a tile matrix set.
Definition qgstiles.h:40
static Q_INVOKABLE double fromUnitToUnitFactor(Qgis::DistanceUnit fromUnit, Qgis::DistanceUnit toUnit)
Returns the conversion factor between the specified distance units.
T qgsEnumKeyToValue(const QString &key, const T &defaultValue, bool tryValueAsKey=true, bool *returnOk=nullptr)
Returns the value corresponding to the given key of an enum.
Definition qgis.h:6168
QString qgsDoubleToString(double a, int precision=17)
Returns a string representation of a double.
Definition qgis.h:5875
QString qgsEnumValueToKey(const T &value, bool *returnOk=nullptr)
Returns the value for the given key of an enum.
Definition qgis.h:6149
#define BUILTIN_UNREACHABLE
Definition qgis.h:6612
#define QgsDebugMsgLevel(str, level)
Definition qgslogger.h:39
const QgsCoordinateReferenceSystem & crs