Skip to content

Commit ccd5d75

Browse files
committed
[bugfix] Fix broken inverted Y support in XYZ layers
This follows the convention used by OpenLayers, where an inverted axis is indicated by {-y} in the URL definition. Fixes #15927 Needs backporting.
1 parent 11475c6 commit ccd5d75

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/providers/wms/qgswmsprovider.cpp

+15-1
Original file line numberDiff line numberDiff line change
@@ -1130,7 +1130,15 @@ void QgsWmsProvider::createTileRequestsXYZ( const QgsWmtsTileMatrix *tm, const Q
11301130
turl.replace( QLatin1String( "{q}" ), _tile2quadkey( tile.col, tile.row, z ) );
11311131

11321132
turl.replace( QLatin1String( "{x}" ), QString::number( tile.col ), Qt::CaseInsensitive );
1133-
turl.replace( QLatin1String( "{y}" ), QString::number( tile.row ), Qt::CaseInsensitive );
1133+
// inverted Y axis
1134+
if ( turl.contains( QLatin1String( "{-y}" ) ) )
1135+
{
1136+
turl.replace( QLatin1String( "{-y}" ), QString::number( tm->matrixHeight - tile.row - 1 ), Qt::CaseInsensitive );
1137+
}
1138+
else
1139+
{
1140+
turl.replace( QLatin1String( "{y}" ), QString::number( tile.row ), Qt::CaseInsensitive );
1141+
}
11341142
turl.replace( QLatin1String( "{z}" ), QString::number( z ), Qt::CaseInsensitive );
11351143

11361144
QgsDebugMsgLevel( QString( "tileRequest %1 %2/%3 (%4,%5): %6" ).arg( mTileReqNo ).arg( i ).arg( tiles.count() ).arg( tile.row ).arg( tile.col ).arg( turl ), 2 );
@@ -3413,6 +3421,12 @@ QgsImageFetcher *QgsWmsProvider::getLegendGraphicFetcher( const QgsMapSettings *
34133421
mapExtent = extent();
34143422
}
34153423

3424+
if ( mSettings.mXyz )
3425+
{
3426+
// we are working with XYZ tiles: no legend graphics available
3427+
return nullptr;
3428+
}
3429+
34163430
QUrl url = getLegendGraphicFullURL( scale, mapExtent );
34173431
if ( !url.isValid() )
34183432
return nullptr;

0 commit comments

Comments
 (0)