Skip to content

Commit

Permalink
Added {q} for XYZ tile layers to support Bing maps
Browse files Browse the repository at this point in the history
  • Loading branch information
wonder-sk committed Sep 16, 2016
1 parent 75269d6 commit 2e1abda
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/providers/wms/qgswmsprovider.cpp
Expand Up @@ -1097,6 +1097,25 @@ void QgsWmsProvider::createTileRequestsWMTS( const QgsWmtsTileMatrix* tm, const
}


// support for Bing Maps tile system
// https://msdn.microsoft.com/en-us/library/bb259689.aspx
static QString _tile2quadkey( int tileX, int tileY, int z )
{
QString quadKey;
for ( int i = z; i > 0; i-- )
{
char digit = '0';
int mask = 1 << ( i - 1 );
if ( tileX & mask )
digit++;
if ( tileY & mask )
digit += 2;
quadKey.append( QChar( digit ) );
}
return quadKey;
}


void QgsWmsProvider::createTileRequestsXYZ( const QgsWmtsTileMatrix* tm, const QgsWmsProvider::TilePositions& tiles, QgsWmsProvider::TileRequests& requests )
{
int z = tm->identifier.toInt();
Expand All @@ -1106,6 +1125,10 @@ void QgsWmsProvider::createTileRequestsXYZ( const QgsWmtsTileMatrix* tm, const Q
{
++i;
QString turl( url );

if ( turl.contains( "{q}" ) ) // used in Bing maps
turl.replace( "{q}", _tile2quadkey( tile.col, tile.row, z ) );

turl.replace( "{x}", QString::number( tile.col ), Qt::CaseInsensitive );
turl.replace( "{y}", QString::number( tile.row ), Qt::CaseInsensitive );
turl.replace( "{z}", QString::number( z ), Qt::CaseInsensitive );
Expand Down

1 comment on commit 2e1abda

@nirvn
Copy link
Contributor

@nirvn nirvn commented on 2e1abda Sep 16, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OpenStreetMap tracing unlocked! 👍

Please sign in to comment.