QGIS API Documentation 4.3.0-Master (16eddb2670e)
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 if ( std::isfinite( scale ) )
305 {
306 switch ( mScaleToTileZoomMethod )
307 {
309 tileZoom = static_cast<int>( round( scaleToZoom( scale ) ) );
310 break;
312 tileZoom = static_cast<int>( floor( scaleToZoom( scale ) ) );
313 break;
314 }
315 }
316
317 return clamp ? std::clamp( tileZoom, minimumZoom(), maximumZoom() ) : tileZoom;
318}
319
321{
322 return calculateTileScaleForMap( context.rendererScale(), context.coordinateTransform().destinationCrs(), context.mapExtent(), context.outputSize(), context.painter()->device()->logicalDpiX() );
323}
324
325double QgsTileMatrixSet::calculateTileScaleForMap( double actualMapScale, const QgsCoordinateReferenceSystem &mapCrs, const QgsRectangle &mapExtent, const QSize mapSize, const double mapDpi ) const
326{
327 switch ( mScaleToTileZoomMethod )
328 // cppcheck-suppress missingReturn
329 {
331 return actualMapScale;
332
334 if ( mapCrs.isGeographic() )
335 {
336 // ESRI calculates the scale for geographic CRS ***ALWAYS*** at the equator, regardless of map extent!
337 // see https://support.esri.com/en/technical-article/000007211, https://gis.stackexchange.com/questions/33270/how-does-arcmap-calculate-scalebar-inside-a-wgs84-layout
338 constexpr double METERS_PER_DEGREE = M_PI / 180.0 * 6378137;
339 constexpr double INCHES_PER_METER = 39.370078;
340 const double mapWidthInches = mapExtent.width() * METERS_PER_DEGREE * INCHES_PER_METER;
341
342 double scale = mapWidthInches * mapDpi / static_cast< double >( mapSize.width() );
343
344 // Note: I **think** there's also some magic which ESRI applies when rendering tiles ON SCREEN,
345 // which may be something like adjusting the scale based on the ratio between the map DPI and 96 DPI,
346 // e.g. scale *= mapDpi / 96.0;
347 // BUT the same adjustment isn't applied when exporting maps. This needs further investigation!
348
349 return scale;
350 }
351 else
352 {
353 return actualMapScale;
354 }
355 }
357}
358
359bool QgsTileMatrixSet::readXml( const QDomElement &element, QgsReadWriteContext & )
360{
361 mTileMatrices.clear();
362
363 mScaleToTileZoomMethod = qgsEnumKeyToValue( element.attribute( u"scaleToZoomMethod"_s ), Qgis::ScaleToTileZoomLevelMethod::MapBox );
364
365 auto readMatrixFromElement = []( const QDomElement &matrixElement ) -> QgsTileMatrix {
366 QgsTileMatrix matrix;
367 matrix.mZoomLevel = matrixElement.attribute( u"zoomLevel"_s ).toInt();
368 matrix.mMatrixWidth = matrixElement.attribute( u"matrixWidth"_s ).toInt();
369 matrix.mMatrixHeight = matrixElement.attribute( u"matrixHeight"_s ).toInt();
370 matrix.mExtent = QgsRectangle(
371 matrixElement.attribute( u"xMin"_s ).toDouble(), matrixElement.attribute( u"yMin"_s ).toDouble(), matrixElement.attribute( u"xMax"_s ).toDouble(), matrixElement.attribute( u"yMax"_s ).toDouble()
372 );
373
374 matrix.mScaleDenom = matrixElement.attribute( u"scale"_s ).toDouble();
375 matrix.mTileXSpan = matrixElement.attribute( u"tileXSpan"_s ).toDouble();
376 matrix.mTileYSpan = matrixElement.attribute( u"tileYSpan"_s ).toDouble();
377 matrix.mCrs.readXml( matrixElement );
378 return matrix;
379 };
380
381 const QDomNodeList children = element.childNodes();
382 for ( int i = 0; i < children.size(); i++ )
383 {
384 const QDomElement matrixElement = children.at( i ).toElement();
385 if ( matrixElement.tagName() == "rootMatrix"_L1 )
386 continue;
387
388 QgsTileMatrix matrix = readMatrixFromElement( matrixElement );
389 if ( matrix.zoomLevel() == 0 ) // old project compatibility
390 mRootMatrix = matrix;
391
392 addMatrix( matrix );
393 }
394
395 const QDomElement rootElement = element.firstChildElement( u"rootMatrix"_s );
396 if ( !rootElement.isNull() )
397 {
398 mRootMatrix = readMatrixFromElement( rootElement );
399 }
400
401 return true;
402}
403
404QDomElement QgsTileMatrixSet::writeXml( QDomDocument &document, const QgsReadWriteContext & ) const
405{
406 QDomElement setElement = document.createElement( u"matrixSet"_s );
407 setElement.setAttribute( u"scaleToZoomMethod"_s, qgsEnumValueToKey( mScaleToTileZoomMethod ) );
408
409 auto writeMatrixToElement = [&document]( const QgsTileMatrix &matrix, QDomElement &matrixElement ) {
410 matrixElement.setAttribute( u"zoomLevel"_s, matrix.zoomLevel() );
411 matrixElement.setAttribute( u"matrixWidth"_s, matrix.matrixWidth() );
412 matrixElement.setAttribute( u"matrixHeight"_s, matrix.matrixHeight() );
413
414 matrixElement.setAttribute( u"xMin"_s, qgsDoubleToString( matrix.mExtent.xMinimum() ) );
415 matrixElement.setAttribute( u"xMax"_s, qgsDoubleToString( matrix.mExtent.xMaximum() ) );
416 matrixElement.setAttribute( u"yMin"_s, qgsDoubleToString( matrix.mExtent.yMinimum() ) );
417 matrixElement.setAttribute( u"yMax"_s, qgsDoubleToString( matrix.mExtent.yMaximum() ) );
418
419 matrixElement.setAttribute( u"scale"_s, qgsDoubleToString( matrix.scale() ) );
420 matrixElement.setAttribute( u"tileXSpan"_s, qgsDoubleToString( matrix.mTileXSpan ) );
421 matrixElement.setAttribute( u"tileYSpan"_s, qgsDoubleToString( matrix.mTileYSpan ) );
422
423 matrix.crs().writeXml( matrixElement, document );
424 };
425
426 for ( auto it = mTileMatrices.constBegin(); it != mTileMatrices.constEnd(); ++it )
427 {
428 QDomElement matrixElement = document.createElement( u"matrix"_s );
429 writeMatrixToElement( *it, matrixElement );
430 setElement.appendChild( matrixElement );
431 }
432
433 QDomElement rootElement = document.createElement( u"rootMatrix"_s );
434 writeMatrixToElement( mRootMatrix, rootElement );
435 setElement.appendChild( rootElement );
436
437 return setElement;
438}
439
440QVector<QgsTileXYZ> QgsTileMatrixSet::tilesInRange( QgsTileRange range, int zoomLevel ) const
441{
442 QVector<QgsTileXYZ> tiles;
443 tiles.reserve( ( range.endColumn() - range.startColumn() + 1 ) * ( range.endRow() - range.startRow() + 1 ) );
444
445 for ( int tileRow = range.startRow(); tileRow <= range.endRow(); ++tileRow )
446 {
447 for ( int tileColumn = range.startColumn(); tileColumn <= range.endColumn(); ++tileColumn )
448 {
449 QgsTileXYZ tile( tileColumn, tileRow, zoomLevel );
450 QgsTileXYZ replacement;
451 switch ( mTileReplacementFunction( tile, replacement ) )
452 {
454 break;
455
459 if ( !tiles.contains( replacement ) )
460 tiles.append( replacement );
461 break;
462 }
463 }
464 }
465 return tiles;
466}
@ 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:404
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:320
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:440
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:359
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:325
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:8036
QString qgsDoubleToString(double a, int precision=17)
Returns a string representation of a double.
Definition qgis.h:7650
QString qgsEnumValueToKey(const T &value, bool *returnOk=nullptr)
Returns the value for the given key of an enum.
Definition qgis.h:8017
#define BUILTIN_UNREACHABLE
Definition qgis.h:8415
#define QgsDebugMsgLevel(str, level)
Definition qgslogger.h:80