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