Skip to content

Commit

Permalink
On zooming too far into a mapserver layer, just use best available
Browse files Browse the repository at this point in the history
resolution tiles and don't abort renderering
  • Loading branch information
nyalldawson committed Jun 7, 2019
1 parent 393af83 commit 493b17c
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/providers/arcgisrest/qgsamsprovider.cpp
Expand Up @@ -448,13 +448,16 @@ QImage QgsAmsProvider::draw( const QgsRectangle &viewExtent, int pixelWidth, int
double oy = origin[QStringLiteral( "y" )].toDouble();

// Search matching resolution (tile resolution <= targetRes)
const QList<QVariant> lodEntries = tileInfo[QStringLiteral( "lods" )].toList();
QList<QVariant> lodEntries = tileInfo[QStringLiteral( "lods" )].toList();
if ( lodEntries.isEmpty() )
{
return QImage();
}
std::sort( lodEntries.begin(), lodEntries.end(), []( const QVariant & a, const QVariant & b )
{
return a.toMap().value( QStringLiteral( "resolution" ) ).toDouble() > b.toMap().value( QStringLiteral( "resolution" ) ).toDouble();
} );
int level = 0;
double resolution = lodEntries.front().toMap()[QStringLiteral( "resolution" )].toDouble();
int foundLevel = -1;

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

level = lodEntryMap[QStringLiteral( "level" )].toInt();
resolution = lodEntryMap[QStringLiteral( "resolution" )].toDouble();
double resolution = lodEntryMap[QStringLiteral( "resolution" )].toDouble();
levelToResMap.insert( level, resolution );
if ( foundLevel < 0 && resolution <= 1.5 * targetRes )
{
foundLevel = level;
}
}
level = foundLevel;
if ( foundLevel >= 0 )
{
level = foundLevel;
}
else
{
// just use best resolution available
level = lodEntries.constLast().toMap().value( QStringLiteral( "level" ) ).toInt();
}

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

0 comments on commit 493b17c

Please sign in to comment.