43 : mColumn( tc ), mRow( tr ), mZoomLevel( tz )
48 int column()
const {
return mColumn; }
50 int row()
const {
return mRow; }
55 QString
toString()
const {
return QStringLiteral(
"X=%1 Y=%2 Z=%3" ).arg( mColumn ).arg( mRow ).arg( mZoomLevel ); }
57 bool operator==(
const QgsTileXYZ &other )
const {
return mColumn == other.mColumn && mRow == other.mRow && mZoomLevel == other.mZoomLevel; }
61 SIP_PYOBJECT __repr__();
63 const QString str = QStringLiteral(
"<QgsTileXYZ: %1, %2, %3>" ).arg( sipCpp->column() ).arg( sipCpp->row() ).arg( sipCpp->zoomLevel() );
64 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
75#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) || defined(__clang__)
76#pragma GCC diagnostic push
77#pragma GCC diagnostic ignored "-Wattributes"
78#elif defined(_MSC_VER)
79__pragma( warning( push ) )
80__pragma( warning( disable: 4273 ) )
91 const uint h1 =
qHash(
static_cast< quint64
>(
id.column( ) ) );
92 const uint h2 =
qHash(
static_cast< quint64
>(
id.row() ) );
93 const uint h3 =
qHash(
static_cast< quint64
>(
id.zoomLevel() ) );
94 return h1 ^ ( h2 << 1 ) ^ ( h3 << 2 );
98#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) || defined(__clang__)
99#pragma GCC diagnostic pop
100#elif defined(_MSC_VER)
101__pragma( warning( pop ) )
118 : mStartColumn( c1 ), mEndColumn( c2 ), mStartRow( r1 ), mEndRow( r2 ) {}
121 bool isValid()
const {
return mStartColumn >= 0 && mEndColumn >= 0 && mStartRow >= 0 && mEndRow >= 0; }
137 int count()
const {
return isValid() ? ( mEndRow - mStartRow + 1 ) * ( mEndColumn - mStartColumn + 1 ) : 0; }
140 int mStartColumn = -1;
170 const QgsPointXY &z0TopLeftPoint,
double z0Dimension,
171 int z0MatrixWidth = 1,
int z0MatrixHeight = 1 );
220 double scale()
const {
return mScaleDenom; }
240 QPointF mapToTileCoordinates(
const QgsPointXY &mapPoint )
const;
251 int mMatrixWidth = 0;
253 int mMatrixHeight = 0;
257 double mScaleDenom = 0;
259 double mTileXSpan = 0;
261 double mTileYSpan = 0;
425 QVector<QgsTileXYZ> tilesInRange(
QgsTileRange range,
int zoomLevel )
const;
ScaleToTileZoomLevelMethod
Available methods for converting map scales to tile zoom levels.
@ MapBox
Uses a scale doubling approach to account for hi-DPI tiles, and rounds to the nearest tile level for ...
TileAvailability
Possible availability states for a tile within a tile matrix.
Represents a coordinate reference system (CRS).
A container for the context for various read/write operations on objects.
A rectangle specified with double values.
Contains information about the context of a rendering operation.
virtual QDomElement writeXml(QDomDocument &document, const QgsReadWriteContext &context) const
Writes the set to an XML element.
Qgis::ScaleToTileZoomLevelMethod mScaleToTileZoomMethod
void addGoogleCrs84QuadTiles(int minimumZoom=0, int maximumZoom=14)
Adds tile matrices corresponding to the standard web mercator/GoogleCRS84Quad setup.
QgsCoordinateReferenceSystem crs() const
Returns the coordinate reference system associated with the tiles.
std::function< Qgis::TileAvailability(QgsTileXYZ id) > mTileAvailabilityFunction
double scaleForRenderContext(const QgsRenderContext &context) const
Calculates the correct scale to use for the tiles when rendered using the specified render context.
int minimumZoom() const
Returns the minimum zoom level for tiles present in the set.
double scaleToZoom(double scale) const
Calculates a fractional zoom level given a map scale denominator.
QMap< int, QgsTileMatrix > mTileMatrices
int maximumZoom() const
Returns the maximum zoom level for tiles present in the set.
QgsTileMatrix tileMatrix(int zoom) const
Returns the tile matrix corresponding to the specified zoom.
Qgis::TileAvailability tileAvailability(QgsTileXYZ id) const
Returns the availability of the given tile in this matrix.
QgsTileMatrix rootMatrix() const
Returns the root tile matrix (usually corresponding to zoom level 0).
virtual bool readXml(const QDomElement &element, QgsReadWriteContext &context)
Reads the set from an XML element.
void addMatrix(const QgsTileMatrix &matrix)
Adds a matrix to the set.
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.
void dropMatricesOutsideZoomRange(int minimumZoom, int maximumZoom)
Deletes any existing matrices which fall outside the zoom range specified by minimumZoom to maximumZo...
virtual ~QgsTileMatrixSet()=default
bool isEmpty() const
Returns true if the matrix set is empty.
QgsTileMatrix mRootMatrix
void setRootMatrix(const QgsTileMatrix &matrix)
Sets the root tile matrix (usually corresponding to zoom level 0).
Qgis::ScaleToTileZoomLevelMethod scaleToTileZoomMethod() const
Returns the scale to tile zoom method.
void setScaleToTileZoomMethod(Qgis::ScaleToTileZoomLevelMethod method)
Sets the scale to tile zoom method.
std::function< Qgis::TileAvailability(QgsTileXYZ id, QgsTileXYZ &replacement) > mTileReplacementFunction
int scaleToZoomLevel(double scale, bool clamp=true) const
Finds the best fitting (integer) zoom level given a map scale denominator.
Defines a matrix of tiles for a single zoom level: it is defined by its size (width *.
void setCrs(const QgsCoordinateReferenceSystem &crs)
Sets the crs of the tile matrix.
static QgsTileMatrix fromWebMercator(int zoomLevel)
Returns a tile matrix for the usual web mercator.
void setScale(double scale)
Sets the scale denominator of the tile matrix.
QgsRectangle extent() const
Returns extent of the tile matrix.
friend class QgsTileMatrixSet
int matrixWidth() const
Returns number of columns of the tile matrix.
QgsCoordinateReferenceSystem crs() const
Returns the crs of the tile matrix.
bool isRootTileMatrix() const
Returns the root status of the tile matrix (zoom level == 0).
double scale() const
Returns scale denominator of the tile matrix.
void setZoomLevel(int level)
Sets the zoom level of the tile matrix.
int matrixHeight() const
Returns number of rows of the tile matrix.
static QgsTileMatrix fromTileMatrix(int zoomLevel, const QgsTileMatrix &tileMatrix)
Returns a tile matrix based on another one.
int zoomLevel() const
Returns the zoom level of the tile matrix.
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.
A range of tiles in a tile matrix.
int endColumn() const
Returns index of the last column in the range.
QgsTileRange(int c1=-1, int c2=-1, int r1=-1, int r2=-1)
Constructs a range of tiles from given span of columns and rows.
int endRow() const
Returns index of the last row in the range.
int startRow() const
Returns index of the first row in the range.
int startColumn() const
Returns index of the first column in the range.
bool isValid() const
Returns whether the range is valid (when all row/column numbers are not negative).
int count() const
Returns the total number of tiles in the range.
Stores coordinates of a tile in a tile matrix set.
QString toString() const
Returns tile coordinates in a formatted string.
int zoomLevel() const
Returns tile's zoom level (Z).
QgsTileXYZ(int tc=-1, int tr=-1, int tz=-1)
Constructs a tile identifier from given column, row and zoom level indices.
bool operator==(const QgsTileXYZ &other) const
int column() const
Returns tile's column index (X).
bool operator!=(const QgsTileXYZ &other) const
int row() const
Returns tile's row index (Y).
CORE_EXPORT uint qHash(QgsTileXYZ id)
Returns a hash for a tile id.