Skip to content

Commit 3ff1bff

Browse files
committed
wmts fixes:
- fix tile limits - fix support support for multiple formats
1 parent 7544239 commit 3ff1bff

File tree

2 files changed

+38
-31
lines changed

2 files changed

+38
-31
lines changed

src/providers/wms/qgswmsprovider.cpp

+35-28
Original file line numberDiff line numberDiff line change
@@ -696,10 +696,11 @@ QImage *QgsWmsProvider::draw( QgsRectangle const &viewExtent, int pixelWidth, i
696696
.arg( vres, 0, 'f' )
697697
);
698698

699-
QgsDebugMsg( QString( "tile matrix %1,%2 res:%3 tilesize:%4x%5 matrixsize:%6x%7" )
699+
QgsDebugMsg( QString( "tile matrix %1,%2 res:%3 tilesize:%4x%5 matrixsize:%6x%7 id:%8" )
700700
.arg( tm->topLeft.x() ).arg( tm->topLeft.y() ).arg( tres )
701701
.arg( tm->tileWidth ).arg( tm->tileHeight )
702702
.arg( tm->matrixWidth ).arg( tm->matrixHeight )
703+
.arg( tm->identifier )
703704
);
704705

705706
// calculate tile coordinates
@@ -712,23 +713,26 @@ QImage *QgsWmsProvider::draw( QgsRectangle const &viewExtent, int pixelWidth, i
712713
int minTileRow = 0;
713714
int maxTileRow = tm->matrixHeight - 1;
714715

715-
if ( mTileLayer->setLinks.contains( tm->identifier ) &&
716-
mTileLayer->setLinks[ tm->identifier ].limits.contains( mTileMatrixSet->identifier ) )
716+
if ( mTileLayer->setLinks.contains( mTileMatrixSet->identifier ) &&
717+
mTileLayer->setLinks[ mTileMatrixSet->identifier ].limits.contains( tm->identifier ) )
717718
{
718-
const QgsWmtsTileMatrixLimits &tml = mTileLayer->setLinks[ tm->identifier ].limits[ mTileMatrixSet->identifier ];
719+
const QgsWmtsTileMatrixLimits &tml = mTileLayer->setLinks[ mTileMatrixSet->identifier ].limits[ tm->identifier ];
719720
minTileCol = tml.minTileCol;
720721
maxTileCol = tml.maxTileCol;
721722
minTileRow = tml.minTileRow;
722723
maxTileRow = tml.maxTileRow;
724+
QgsDebugMsg( QString( "%1 %2: TileMatrixLimits col %3-%4 row %5-%6" )
725+
.arg( mTileMatrixSet->identifier )
726+
.arg( tm->identifier )
727+
.arg( minTileCol ).arg( maxTileCol )
728+
.arg( minTileRow ).arg( maxTileRow ) );
723729
}
724730

725731
int col0 = qBound( minTileCol, ( int ) floor(( viewExtent.xMinimum() - tm->topLeft.x() ) / twMap ), maxTileCol );
726732
int row0 = qBound( minTileRow, ( int ) floor(( tm->topLeft.y() - viewExtent.yMaximum() ) / thMap ), maxTileRow );
727733
int col1 = qBound( minTileCol, ( int ) ceil(( viewExtent.xMaximum() - tm->topLeft.x() ) / twMap ), maxTileCol );
728734
int row1 = qBound( minTileRow, ( int ) ceil(( tm->topLeft.y() - viewExtent.yMinimum() ) / thMap ), maxTileRow );
729735

730-
QgsDebugMsg( QString( "rows: %1-%2 cols: %3-%4" ).arg( row0 ).arg( row1 ).arg( col0 ).arg( col1 ) );
731-
732736
#if QGISDEBUG
733737
int n = ( col1 - col0 + 1 ) * ( row1 - row0 + 1 );
734738
QgsDebugMsg( QString( "tile number: %1x%2 = %3" ).arg( col1 - col0 + 1 ).arg( row1 - row0 + 1 ).arg( n ) );
@@ -2621,36 +2625,39 @@ void QgsWmsProvider::parseWMTSContents( QDomElement const &e )
26212625

26222626
for ( QDomElement e1 = e0.firstChildElement( "TileMatrixSetLink" ); !e1.isNull(); e1 = e1.nextSiblingElement( "TileMatrixSetLink" ) )
26232627
{
2624-
for ( QDomElement e2 = e1.firstChildElement( "TileMatrixSet" ); !e2.isNull(); e2 = e2.nextSiblingElement( "TileMatrixSet" ) )
2625-
{
2626-
QgsWmtsTileMatrixSetLink sl;
2628+
QgsWmtsTileMatrixSetLink sl;
26272629

2628-
sl.tileMatrixSet = e2.text();
2629-
if ( !mTileMatrixSets.contains( sl.tileMatrixSet ) )
2630-
{
2631-
QgsDebugMsg( QString( "tileMatrixSet %1 not found." ).arg( id ) );
2632-
continue;
2633-
}
2630+
sl.tileMatrixSet = e1.firstChildElement( "TileMatrixSet" ).text();
26342631

2635-
for ( QDomElement e3 = e2.firstChildElement( "TileMatrixSetLimits" ); !e3.isNull(); e3 = e3.nextSiblingElement( "TileMatrixSetLimits" ) )
2632+
if ( !mTileMatrixSets.contains( sl.tileMatrixSet ) )
2633+
{
2634+
QgsDebugMsg( QString( " TileMatrixSet %1 not found." ).arg( sl.tileMatrixSet ) );
2635+
continue;
2636+
}
2637+
2638+
for ( QDomElement e2 = e1.firstChildElement( "TileMatrixSetLimits" ); !e2.isNull(); e2 = e2.nextSiblingElement( "TileMatrixSetLimits" ) )
2639+
{
2640+
for ( QDomElement e3 = e2.firstChildElement( "TileMatrixLimits" ); !e3.isNull(); e3 = e3.nextSiblingElement( "TileMatrixLimits" ) )
26362641
{
2637-
for ( QDomElement e4 = e3.firstChildElement( "TileMatrixLimits" ); !e4.isNull(); e4 = e4.nextSiblingElement( "TileMatrixLimits" ) )
2638-
{
2639-
QgsWmtsTileMatrixLimits limit;
2642+
QgsWmtsTileMatrixLimits limit;
26402643

2641-
QString id = e4.firstChildElement( "TileMatrix" ).text();
2644+
QString id = e3.firstChildElement( "TileMatrix" ).text();
26422645

2643-
limit.minTileRow = e4.firstChildElement( "MinTileRow" ).text().toInt();
2644-
limit.maxTileRow = e4.firstChildElement( "MaxTileRow" ).text().toInt();
2645-
limit.minTileCol = e4.firstChildElement( "MinTileCol" ).text().toInt();
2646-
limit.maxTileCol = e4.firstChildElement( "MaxTileCol" ).text().toInt();
2646+
limit.minTileRow = e3.firstChildElement( "MinTileRow" ).text().toInt();
2647+
limit.maxTileRow = e3.firstChildElement( "MaxTileRow" ).text().toInt();
2648+
limit.minTileCol = e3.firstChildElement( "MinTileCol" ).text().toInt();
2649+
limit.maxTileCol = e3.firstChildElement( "MaxTileCol" ).text().toInt();
26472650

2648-
sl.limits.insert( id, limit );
2649-
}
2651+
QgsDebugMsg( QString( " TileMatrix id:%1 row:%2-%3 col:%4-%5" )
2652+
.arg( id )
2653+
.arg( limit.minTileRow ).arg( limit.maxTileRow )
2654+
.arg( limit.minTileCol ).arg( limit.maxTileCol )
2655+
);
2656+
sl.limits.insert( id, limit );
26502657
}
2651-
2652-
l.setLinks.insert( sl.tileMatrixSet, sl );
26532658
}
2659+
2660+
l.setLinks.insert( sl.tileMatrixSet, sl );
26542661
}
26552662

26562663
for ( QDomElement e1 = e0.firstChildElement( "ResourceURL" ); !e1.isNull(); e1 = e1.nextSiblingElement( "ResourceURL" ) )

src/providers/wms/qgswmssourceselect.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ bool QgsWMSSourceSelect::populateLayerList( QgsWmsProvider *wmsProvider )
348348
int rows = 0;
349349
foreach( const QgsWmtsTileLayer &l, mTileLayers )
350350
{
351-
rows += l.styles.size() * l.setLinks.size();
351+
rows += l.styles.size() * l.setLinks.size() * l.formats.size();
352352
}
353353

354354
lstTilesets->clearContents();
@@ -391,9 +391,9 @@ bool QgsWMSSourceSelect::populateLayerList( QgsWmsProvider *wmsProvider )
391391
item->setToolTip( tr( "encoding %1 not supported." ).arg( format ) );
392392
}
393393
}
394-
}
395394

396-
row++;
395+
row++;
396+
}
397397
}
398398
}
399399
}

0 commit comments

Comments
 (0)