Skip to content

Commit

Permalink
Minor cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jun 6, 2019
1 parent a36787c commit 345f3fe
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/providers/arcgisrest/qgsamsprovider.cpp
Expand Up @@ -337,8 +337,7 @@ QImage QgsAmsProvider::draw( const QgsRectangle &viewExtent, int pixelWidth, int
QgsDataSourceUri dataSource( dataSourceUri() );
const QString authcfg = dataSource.authConfigId();

// Use of tiles currently only implemented if service CRS is meter based
if ( mServiceInfo[QStringLiteral( "singleFusedMapCache" )].toBool() && mCrs.mapUnits() == QgsUnitTypes::DistanceMeters )
if ( mTiled )
{
mTileReqNo++;

Expand All @@ -349,7 +348,7 @@ QImage QgsAmsProvider::draw( const QgsRectangle &viewExtent, int pixelWidth, int
double targetRes = width / ( pixelWidth );

// Tiles available, assemble image from tiles
QVariantMap tileInfo = mServiceInfo[QStringLiteral( "tileInfo" )].toMap();
QVariantMap tileInfo = mServiceInfo.value( QStringLiteral( "tileInfo" ) ).toMap();
int tileWidth = tileInfo[QStringLiteral( "cols" )].toInt();
int tileHeight = tileInfo[QStringLiteral( "rows" )].toInt();
QVariantMap origin = tileInfo[QStringLiteral( "origin" )].toMap();
Expand Down Expand Up @@ -388,10 +387,10 @@ QImage QgsAmsProvider::draw( const QgsRectangle &viewExtent, int pixelWidth, int
// Get necessary tiles to fill extent
// tile_x = ox + i * (resolution * tileWidth)
// tile_y = oy - j * (resolution * tileHeight)
int ixStart = std::floor( ( viewExtent.xMinimum() - ox ) / ( tileWidth * resolution ) );
int iyStart = std::floor( ( oy - viewExtent.yMaximum() ) / ( tileHeight * resolution ) );
int ixEnd = std::ceil( ( viewExtent.xMaximum() - ox ) / ( tileWidth * resolution ) );
int iyEnd = std::ceil( ( oy - viewExtent.yMinimum() ) / ( tileHeight * resolution ) );
int ixStart = static_cast< int >( std::floor( ( viewExtent.xMinimum() - ox ) / ( tileWidth * resolution ) ) );
int iyStart = static_cast< int >( std::floor( ( oy - viewExtent.yMaximum() ) / ( tileHeight * resolution ) ) );
int ixEnd = static_cast< int >( std::ceil( ( viewExtent.xMaximum() - ox ) / ( tileWidth * resolution ) ) );
int iyEnd = static_cast< int >( std::ceil( ( oy - viewExtent.yMinimum() ) / ( tileHeight * resolution ) ) );
double imX = ( viewExtent.xMinimum() - ox ) / resolution;
double imY = ( oy - viewExtent.yMaximum() ) / resolution;

Expand Down Expand Up @@ -426,6 +425,9 @@ QImage QgsAmsProvider::draw( const QgsRectangle &viewExtent, int pixelWidth, int
image.fill( Qt::transparent );

TileRequests requestsFinal;
tileImages.reserve( requests.size() );
missing.reserve( requests.size() );
requestsFinal.reserve( requests.size() );
for ( const TileRequest &r : qgis::as_const( requests ) )
{
QImage localImage;
Expand Down

0 comments on commit 345f3fe

Please sign in to comment.