22 int numTiles =
static_cast<int>( pow( 2,
zoomLevel ) );
23 double z0xMin = -20037508.3427892, z0yMin = -20037508.3427892;
24 double z0xMax = 20037508.3427892, z0yMax = 20037508.3427892;
25 double s0 = 559082264.0287178;
29 tm.mMatrixWidth = numTiles;
30 tm.mMatrixHeight = numTiles;
31 tm.mTileXSpan = ( z0xMax - z0xMin ) / tm.mMatrixWidth;
32 tm.mTileYSpan = ( z0yMax - z0yMin ) / tm.mMatrixHeight;
33 tm.mExtent =
QgsRectangle( z0xMin, z0yMin, z0xMax, z0yMax );
34 tm.mScaleDenom = s0 / pow( 2,
zoomLevel );
40 double xMin = mExtent.
xMinimum() + mTileXSpan *
id.column();
41 double xMax = xMin + mTileXSpan;
42 double yMax = mExtent.
yMaximum() - mTileYSpan *
id.row();
43 double yMin = yMax - mTileYSpan;
49 double x = mExtent.
xMinimum() + mTileXSpan / 2 *
id.column();
50 double y = mExtent.
yMaximum() - mTileYSpan / 2 *
id.row();
60 if ( x0 >= x1 || y0 >= y1 )
63 double tileX1 = ( x0 - mExtent.
xMinimum() ) / mTileXSpan;
64 double tileX2 = ( x1 - mExtent.
xMinimum() ) / mTileXSpan;
65 double tileY1 = ( mExtent.
yMaximum() - y1 ) / mTileYSpan;
66 double tileY2 = ( mExtent.
yMaximum() - y0 ) / mTileYSpan;
68 QgsDebugMsgLevel( QStringLiteral(
"Tile range of edges [%1,%2] - [%3,%4]" ).arg( tileX1 ).arg( tileY1 ).arg( tileX2 ).arg( tileY2 ), 2 );
71 int startColumn = std::clamp(
static_cast<int>( floor( tileX1 ) ), 0, mMatrixWidth - 1 );
72 int endColumn = std::clamp(
static_cast<int>( floor( tileX2 ) ), 0, mMatrixWidth - 1 );
73 int startRow = std::clamp(
static_cast<int>( floor( tileY1 ) ), 0, mMatrixHeight - 1 );
74 int endRow = std::clamp(
static_cast<int>( floor( tileY2 ) ), 0, mMatrixHeight - 1 );
75 return QgsTileRange( startColumn, endColumn, startRow, endRow );
80 double dx = mapPoint.
x() - mExtent.
xMinimum();
81 double dy = mExtent.
yMaximum() - mapPoint.
y();
82 return QPointF( dx / mTileXSpan, dy / mTileYSpan );
A class to represent a 2D point.
A rectangle specified with double values.
double yMaximum() const SIP_HOLDGIL
Returns the y maximum value (top side of rectangle).
double xMaximum() const SIP_HOLDGIL
Returns the x maximum value (right side of rectangle).
double xMinimum() const SIP_HOLDGIL
Returns the x minimum value (left side of rectangle).
double yMinimum() const SIP_HOLDGIL
Returns the y minimum value (bottom side of rectangle).
Defines a matrix of tiles for a single zoom level: it is defined by its size (width *.
QgsRectangle tileExtent(QgsTileXYZ id) const
Returns extent of the given tile in this matrix.
QPointF mapToTileCoordinates(const QgsPointXY &mapPoint) const
Returns row/column coordinates (floating point number) from the given point in map coordinates.
QgsTileRange tileRangeFromExtent(const QgsRectangle &mExtent)
Returns tile range that fully covers the given extent.
static QgsTileMatrix fromWebMercator(int mZoomLevel)
Returns a tile matrix for the usual web mercator.
QgsPointXY tileCenter(QgsTileXYZ id) const
Returns center of the given tile in this matrix.
int zoomLevel() const
Returns zoom level of the tile matrix.
Range of tiles in a tile matrix to be rendered.
Stores coordinates of a tile in a tile matrix set.
#define QgsDebugMsgLevel(str, level)