Skip to content
Permalink
Browse files

Added {q} for XYZ tile layers to support Bing maps

  • Loading branch information
wonder-sk committed Sep 16, 2016
1 parent 75269d6 commit 2e1abdab64efb24f0525f69d21f716753805504a
Showing with 23 additions and 0 deletions.
  1. +23 −0 src/providers/wms/qgswmsprovider.cpp
@@ -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();
@@ -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 );

1 comment on commit 2e1abda

@nirvn

This comment has been minimized.

Copy link
Contributor

@nirvn nirvn commented on 2e1abda Sep 16, 2016

OpenStreetMap tracing unlocked! 👍

Please sign in to comment.
You can’t perform that action at this time.