Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix casting to long long
  • Loading branch information
alexbruy authored and nyalldawson committed May 17, 2023
1 parent 4fb41b6 commit 819d306
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/analysis/processing/qgsalgorithmdownloadvectortiles.cpp
Expand Up @@ -100,7 +100,7 @@ QVariantMap QgsDownloadVectorTilesAlgorithm::processAlgorithm( const QVariantMap

const QgsRectangle extent = parameterAsExtent( parameters, QStringLiteral( "EXTENT" ), context, layer->crs() );
int maxZoomLevel = parameterAsInt( parameters, QStringLiteral( "MAX_ZOOM" ), context );
const int tileLimit = parameterAsInt( parameters, QStringLiteral( "TILE_LIMIT" ), context );
const long long tileLimit = static_cast< long long >( parameterAsInt( parameters, QStringLiteral( "TILE_LIMIT" ), context ) );
const QString outputFile = parameterAsOutputLayer( parameters, QStringLiteral( "OUTPUT" ), context );

QgsVectorTileLayer *vtLayer = qobject_cast< QgsVectorTileLayer * >( layer );
Expand All @@ -120,11 +120,11 @@ QVariantMap QgsDownloadVectorTilesAlgorithm::processAlgorithm( const QVariantMap
QgsTileMatrix tileMatrix = tileMatrixSet.tileMatrix( i );
QgsTileRange tileRange = tileMatrix.tileRangeFromExtent( extent );
tileRanges.insert( i, tileRange );
tileCount += ( tileRange.endColumn() - tileRange.startColumn() + 1 ) * ( tileRange.endRow() - tileRange.startRow() + 1 );
if ( tileCount > tileLimit )
{
throw QgsProcessingException( QObject::tr( "Requested number of tiles exceeds limit of %1 tiles. Please, select a smaller extent, reduce maximum zoom level or increase tile limit." ).arg( tileLimit ) );
}
tileCount += static_cast< long long >( ( tileRange.endColumn() - tileRange.startColumn() + 1 ) * ( tileRange.endRow() - tileRange.startRow() + 1 ) );
}
if ( tileCount > tileLimit )
{
throw QgsProcessingException( QObject::tr( "Requested number of tiles %1 exceeds limit of %2 tiles. Please, select a smaller extent, reduce maximum zoom level or increase tile limit." ).arg( tileCount ).arg( tileLimit ) );
}

std::unique_ptr<QgsMbTiles> writer = std::make_unique<QgsMbTiles>( outputFile );
Expand All @@ -141,7 +141,7 @@ QVariantMap QgsDownloadVectorTilesAlgorithm::processAlgorithm( const QVariantMap
{
QgsCoordinateTransform ct( tileMatrixSet.rootMatrix().crs(), QgsCoordinateReferenceSystem( "EPSG:4326" ), context.transformContext() );
ct.setBallparkTransformsAreAppropriate( true );
QgsRectangle wgsExtent = ct.transform( extent );
QgsRectangle wgsExtent = ct.transformBoundingBox( extent );
QString boundsStr = QString( "%1,%2,%3,%4" )
.arg( wgsExtent.xMinimum() ).arg( wgsExtent.yMinimum() )
.arg( wgsExtent.xMaximum() ).arg( wgsExtent.yMaximum() );
Expand All @@ -166,7 +166,7 @@ QVariantMap QgsDownloadVectorTilesAlgorithm::processAlgorithm( const QVariantMap
multiStepFeedback.setCurrentStep( it.key() );

QgsTileMatrix tileMatrix = tileMatrixSet.tileMatrix( it.key() );
tileCount = ( it.value().endColumn() - it.value().startColumn() + 1 ) * ( it.value().endRow() - it.value().startRow() + 1 );
tileCount = static_cast< long long >( ( it.value().endColumn() - it.value().startColumn() + 1 ) * ( it.value().endRow() - it.value().startRow() + 1 ) );

const QPointF viewCenter = tileMatrix.mapToTileCoordinates( extent.center() );

Expand Down

0 comments on commit 819d306

Please sign in to comment.