Skip to content

Commit c56915c

Browse files
committedSep 16, 2016
Added {q} for XYZ tile layers to support Bing maps
(cherry picked from commit 2e1abda)
1 parent 5be1591 commit c56915c

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed
 

‎src/providers/wms/qgswmsprovider.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,6 +1093,25 @@ void QgsWmsProvider::createTileRequestsWMTS( const QgsWmtsTileMatrix* tm, const
10931093
}
10941094

10951095

1096+
// support for Bing Maps tile system
1097+
// https://msdn.microsoft.com/en-us/library/bb259689.aspx
1098+
static QString _tile2quadkey( int tileX, int tileY, int z )
1099+
{
1100+
QString quadKey;
1101+
for ( int i = z; i > 0; i-- )
1102+
{
1103+
char digit = '0';
1104+
int mask = 1 << ( i - 1 );
1105+
if ( tileX & mask )
1106+
digit++;
1107+
if ( tileY & mask )
1108+
digit += 2;
1109+
quadKey.append( QChar( digit ) );
1110+
}
1111+
return quadKey;
1112+
}
1113+
1114+
10961115
void QgsWmsProvider::createTileRequestsXYZ( const QgsWmtsTileMatrix* tm, const QgsWmsProvider::TilePositions& tiles, QgsWmsProvider::TileRequests& requests )
10971116
{
10981117
int z = tm->identifier.toInt();
@@ -1102,6 +1121,10 @@ void QgsWmsProvider::createTileRequestsXYZ( const QgsWmtsTileMatrix* tm, const Q
11021121
{
11031122
++i;
11041123
QString turl( url );
1124+
1125+
if ( turl.contains( "{q}" ) ) // used in Bing maps
1126+
turl.replace( "{q}", _tile2quadkey( tile.col, tile.row, z ) );
1127+
11051128
turl.replace( "{x}", QString::number( tile.col ), Qt::CaseInsensitive );
11061129
turl.replace( "{y}", QString::number( tile.row ), Qt::CaseInsensitive );
11071130
turl.replace( "{z}", QString::number( z ), Qt::CaseInsensitive );

0 commit comments

Comments
 (0)
Please sign in to comment.