Skip to content

Commit 493b17c

Browse files
committedJun 7, 2019
On zooming too far into a mapserver layer, just use best available
resolution tiles and don't abort renderering
1 parent 393af83 commit 493b17c

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed
 

‎src/providers/arcgisrest/qgsamsprovider.cpp

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -448,13 +448,16 @@ QImage QgsAmsProvider::draw( const QgsRectangle &viewExtent, int pixelWidth, int
448448
double oy = origin[QStringLiteral( "y" )].toDouble();
449449

450450
// Search matching resolution (tile resolution <= targetRes)
451-
const QList<QVariant> lodEntries = tileInfo[QStringLiteral( "lods" )].toList();
451+
QList<QVariant> lodEntries = tileInfo[QStringLiteral( "lods" )].toList();
452452
if ( lodEntries.isEmpty() )
453453
{
454454
return QImage();
455455
}
456+
std::sort( lodEntries.begin(), lodEntries.end(), []( const QVariant & a, const QVariant & b )
457+
{
458+
return a.toMap().value( QStringLiteral( "resolution" ) ).toDouble() > b.toMap().value( QStringLiteral( "resolution" ) ).toDouble();
459+
} );
456460
int level = 0;
457-
double resolution = lodEntries.front().toMap()[QStringLiteral( "resolution" )].toDouble();
458461
int foundLevel = -1;
459462

460463
QMap< int, double > levelToResMap;
@@ -463,14 +466,22 @@ QImage QgsAmsProvider::draw( const QgsRectangle &viewExtent, int pixelWidth, int
463466
QVariantMap lodEntryMap = lodEntry.toMap();
464467

465468
level = lodEntryMap[QStringLiteral( "level" )].toInt();
466-
resolution = lodEntryMap[QStringLiteral( "resolution" )].toDouble();
469+
double resolution = lodEntryMap[QStringLiteral( "resolution" )].toDouble();
467470
levelToResMap.insert( level, resolution );
468471
if ( foundLevel < 0 && resolution <= 1.5 * targetRes )
469472
{
470473
foundLevel = level;
471474
}
472475
}
473-
level = foundLevel;
476+
if ( foundLevel >= 0 )
477+
{
478+
level = foundLevel;
479+
}
480+
else
481+
{
482+
// just use best resolution available
483+
level = lodEntries.constLast().toMap().value( QStringLiteral( "level" ) ).toInt();
484+
}
474485

475486
auto getRequests = [&levelToResMap, &viewExtent, tileWidth, tileHeight, ox, oy, targetRes, &dataSource]( int level, TileRequests & requests )
476487
{

0 commit comments

Comments
 (0)
Please sign in to comment.