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