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