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 = qBound( 0,
static_cast<int>( floor( tileX1 ) ), mMatrixWidth - 1 );
72 int endColumn = qBound( 0,
static_cast<int>( floor( tileX2 ) ), mMatrixWidth - 1 );
73 int startRow = qBound( 0,
static_cast<int>( floor( tileY1 ) ), mMatrixHeight - 1 );
74 int endRow = qBound( 0,
static_cast<int>( floor( tileY2 ) ), 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 );