Skip to content
Permalink
Browse files
Make QgsTileMatrix::tileRangeFromExtent() const
Because there is no reason for it not to be.
  • Loading branch information
joto committed Oct 23, 2021
1 parent 496bd6f commit 9329891f6b6152415713ef1347bf2fdf19c36d50
Showing with 6 additions and 6 deletions.
  1. +1 −1 python/core/auto_generated/qgstiles.sip.in
  2. +1 −1 src/core/qgstiles.cpp
  3. +1 −1 src/core/qgstiles.h
  4. +2 −2 src/core/vectortile/qgsvectortilewriter.cpp
  5. +1 −1 src/gui/qgsmaptoolidentify.cpp
@@ -165,7 +165,7 @@ Returns extent of the given tile in this matrix
Returns center of the given tile in this matrix
%End

QgsTileRange tileRangeFromExtent( const QgsRectangle &mExtent );
QgsTileRange tileRangeFromExtent( const QgsRectangle &mExtent ) const;
%Docstring
Returns tile range that fully covers the given extent
%End
@@ -93,7 +93,7 @@ QgsPointXY QgsTileMatrix::tileCenter( QgsTileXYZ id ) const
return QgsPointXY( x, y );
}

QgsTileRange QgsTileMatrix::tileRangeFromExtent( const QgsRectangle &r )
QgsTileRange QgsTileMatrix::tileRangeFromExtent( const QgsRectangle &r ) const
{
double x0 = std::clamp( r.xMinimum(), mExtent.xMinimum(), mExtent.xMaximum() );
double y0 = std::clamp( r.yMinimum(), mExtent.yMinimum(), mExtent.yMaximum() );
@@ -140,7 +140,7 @@ class CORE_EXPORT QgsTileMatrix
QgsPointXY tileCenter( QgsTileXYZ id ) const;

//! Returns tile range that fully covers the given extent
QgsTileRange tileRangeFromExtent( const QgsRectangle &mExtent );
QgsTileRange tileRangeFromExtent( const QgsRectangle &mExtent ) const;

//! Returns row/column coordinates (floating point number) from the given point in map coordinates
QPointF mapToTileCoordinates( const QgsPointXY &mapPoint ) const;
@@ -106,7 +106,7 @@ bool QgsVectorTileWriter::writeTiles( QgsFeedback *feedback )
int tilesToCreate = 0;
for ( int zoomLevel = mMinZoom; zoomLevel <= mMaxZoom; ++zoomLevel )
{
QgsTileMatrix tileMatrix = QgsTileMatrix::fromTileMatrix( zoomLevel, mRootTileMatrix );
const QgsTileMatrix tileMatrix = QgsTileMatrix::fromTileMatrix( zoomLevel, mRootTileMatrix );

QgsTileRange tileRange = tileMatrix.tileRangeFromExtent( outputExtent );
tilesToCreate += ( tileRange.endRow() - tileRange.startRow() + 1 ) *
@@ -168,7 +168,7 @@ bool QgsVectorTileWriter::writeTiles( QgsFeedback *feedback )
int tilesCreated = 0;
for ( int zoomLevel = mMinZoom; zoomLevel <= mMaxZoom; ++zoomLevel )
{
QgsTileMatrix tileMatrix = QgsTileMatrix::fromTileMatrix( zoomLevel, mRootTileMatrix );
const QgsTileMatrix tileMatrix = QgsTileMatrix::fromTileMatrix( zoomLevel, mRootTileMatrix );

QgsTileRange tileRange = tileMatrix.tileRangeFromExtent( outputExtent );
for ( int row = tileRange.startRow(); row <= tileRange.endRow(); ++row )
@@ -453,7 +453,7 @@ bool QgsMapToolIdentify::identifyVectorTileLayer( QList<QgsMapToolIdentify::Iden
}

int tileZoom = QgsVectorTileUtils::scaleToZoomLevel( mCanvas->scale(), layer->sourceMinZoom(), layer->sourceMaxZoom() );
QgsTileMatrix tileMatrix = QgsTileMatrix::fromWebMercator( tileZoom );
const QgsTileMatrix tileMatrix = QgsTileMatrix::fromWebMercator( tileZoom );
QgsTileRange tileRange = tileMatrix.tileRangeFromExtent( r );

for ( int row = tileRange.startRow(); row <= tileRange.endRow(); ++row )

0 comments on commit 9329891

Please sign in to comment.