"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/core/vectortile/qgsvectortilelayerrenderer.cpp" between
QGIS-final-3_14_15.tar.gz and QGIS-final-3_14_16.tar.gz

About: QGIS (Quantum GIS) is a Geographic Information System that supports vector, raster, and database formats. Latest release (3.14.x series).

qgsvectortilelayerrenderer.cpp  (QGIS-final-3_14_15):qgsvectortilelayerrenderer.cpp  (QGIS-final-3_14_16)
skipping to change at line 64 skipping to change at line 64
} }
bool QgsVectorTileLayerRenderer::render() bool QgsVectorTileLayerRenderer::render()
{ {
QgsRenderContext &ctx = *renderContext(); QgsRenderContext &ctx = *renderContext();
if ( ctx.renderingStopped() ) if ( ctx.renderingStopped() )
return false; return false;
ctx.painter()->save();
QElapsedTimer tTotal; QElapsedTimer tTotal;
tTotal.start(); tTotal.start();
QgsDebugMsgLevel( QStringLiteral( "Vector tiles rendering extent: " ) + ctx.ex tent().toString( -1 ), 2 ); QgsDebugMsgLevel( QStringLiteral( "Vector tiles rendering extent: " ) + ctx.ex tent().toString( -1 ), 2 );
QgsDebugMsgLevel( QStringLiteral( "Vector tiles map scale 1 : %1" ).arg( ctx.r endererScale() ), 2 ); QgsDebugMsgLevel( QStringLiteral( "Vector tiles map scale 1 : %1" ).arg( ctx.r endererScale() ), 2 );
mTileZoom = QgsVectorTileUtils::scaleToZoomLevel( ctx.rendererScale(), mSource MinZoom, mSourceMaxZoom ); mTileZoom = QgsVectorTileUtils::scaleToZoomLevel( ctx.rendererScale(), mSource MinZoom, mSourceMaxZoom );
QgsDebugMsgLevel( QStringLiteral( "Vector tiles zoom level: %1" ).arg( mTileZo om ), 2 ); QgsDebugMsgLevel( QStringLiteral( "Vector tiles zoom level: %1" ).arg( mTileZo om ), 2 );
mTileMatrix = QgsTileMatrix::fromWebMercator( mTileZoom ); mTileMatrix = QgsTileMatrix::fromWebMercator( mTileZoom );
skipping to change at line 86 skipping to change at line 88
QgsDebugMsgLevel( QStringLiteral( "Vector tiles range X: %1 - %2 Y: %3 - %4" ) QgsDebugMsgLevel( QStringLiteral( "Vector tiles range X: %1 - %2 Y: %3 - %4" )
.arg( mTileRange.startColumn() ).arg( mTileRange.endColumn() ) .arg( mTileRange.startColumn() ).arg( mTileRange.endColumn() )
.arg( mTileRange.startRow() ).arg( mTileRange.endRow() ), 2 ); .arg( mTileRange.startRow() ).arg( mTileRange.endRow() ), 2 );
// view center is used to sort the order of tiles for fetching and rendering // view center is used to sort the order of tiles for fetching and rendering
QPointF viewCenter = mTileMatrix.mapToTileCoordinates( ctx.extent().center() ) ; QPointF viewCenter = mTileMatrix.mapToTileCoordinates( ctx.extent().center() ) ;
if ( !mTileRange.isValid() ) if ( !mTileRange.isValid() )
{ {
QgsDebugMsgLevel( QStringLiteral( "Vector tiles - outside of range" ), 2 ); QgsDebugMsgLevel( QStringLiteral( "Vector tiles - outside of range" ), 2 );
ctx.painter()->restore();
return true; // nothing to do return true; // nothing to do
} }
bool isAsync = ( mSourceType == QStringLiteral( "xyz" ) ); bool isAsync = ( mSourceType == QStringLiteral( "xyz" ) );
std::unique_ptr<QgsVectorTileLoader> asyncLoader; std::unique_ptr<QgsVectorTileLoader> asyncLoader;
QList<QgsVectorTileRawData> rawTiles; QList<QgsVectorTileRawData> rawTiles;
if ( !isAsync ) if ( !isAsync )
{ {
QElapsedTimer tFetch; QElapsedTimer tFetch;
skipping to change at line 113 skipping to change at line 116
asyncLoader.reset( new QgsVectorTileLoader( mSourcePath, mTileMatrix, mTileR ange, viewCenter, mFeedback.get() ) ); asyncLoader.reset( new QgsVectorTileLoader( mSourcePath, mTileMatrix, mTileR ange, viewCenter, mFeedback.get() ) );
QObject::connect( asyncLoader.get(), &QgsVectorTileLoader::tileRequestFinish ed, [this]( const QgsVectorTileRawData & rawTile ) QObject::connect( asyncLoader.get(), &QgsVectorTileLoader::tileRequestFinish ed, [this]( const QgsVectorTileRawData & rawTile )
{ {
QgsDebugMsgLevel( QStringLiteral( "Got tile asynchronously: " ) + rawTile. id.toString(), 2 ); QgsDebugMsgLevel( QStringLiteral( "Got tile asynchronously: " ) + rawTile. id.toString(), 2 );
if ( !rawTile.data.isEmpty() ) if ( !rawTile.data.isEmpty() )
decodeAndDrawTile( rawTile ); decodeAndDrawTile( rawTile );
} ); } );
} }
if ( ctx.renderingStopped() ) if ( ctx.renderingStopped() )
{
ctx.painter()->restore();
return false; return false;
}
// add @zoom_level variable which can be used in styling // add @zoom_level variable which can be used in styling
QgsExpressionContextScope *scope = new QgsExpressionContextScope( QObject::tr( "Tiles" ) ); // will be deleted by popper QgsExpressionContextScope *scope = new QgsExpressionContextScope( QObject::tr( "Tiles" ) ); // will be deleted by popper
scope->setVariable( "zoom_level", mTileZoom, true ); scope->setVariable( "zoom_level", mTileZoom, true );
QgsExpressionContextScopePopper popper( ctx.expressionContext(), scope ); QgsExpressionContextScopePopper popper( ctx.expressionContext(), scope );
mRenderer->startRender( *renderContext(), mTileZoom, mTileRange ); mRenderer->startRender( *renderContext(), mTileZoom, mTileRange );
QMap<QString, QSet<QString> > requiredFields = mRenderer->usedAttributes( ctx ); QMap<QString, QSet<QString> > requiredFields = mRenderer->usedAttributes( ctx );
skipping to change at line 167 skipping to change at line 173
} }
else else
{ {
// Block until tiles are fetched and rendered. If the rendering gets cancele d at some point, // Block until tiles are fetched and rendered. If the rendering gets cancele d at some point,
// the async loader will catch the signal, abort requests and return from do wnloadBlocking() // the async loader will catch the signal, abort requests and return from do wnloadBlocking()
asyncLoader->downloadBlocking(); asyncLoader->downloadBlocking();
} }
mRenderer->stopRender( ctx ); mRenderer->stopRender( ctx );
ctx.painter()->setClipping( false );
QgsDebugMsgLevel( QStringLiteral( "Total time for decoding: %1" ).arg( mTotalD ecodeTime / 1000. ), 2 ); QgsDebugMsgLevel( QStringLiteral( "Total time for decoding: %1" ).arg( mTotalD ecodeTime / 1000. ), 2 );
QgsDebugMsgLevel( QStringLiteral( "Drawing time: %1" ).arg( mTotalDrawTime / 1 000. ), 2 ); QgsDebugMsgLevel( QStringLiteral( "Drawing time: %1" ).arg( mTotalDrawTime / 1 000. ), 2 );
QgsDebugMsgLevel( QStringLiteral( "Total time: %1" ).arg( tTotal.elapsed() / 1 000. ), 2 ); QgsDebugMsgLevel( QStringLiteral( "Total time: %1" ).arg( tTotal.elapsed() / 1 000. ), 2 );
ctx.painter()->restore();
return !ctx.renderingStopped(); return !ctx.renderingStopped();
} }
void QgsVectorTileLayerRenderer::decodeAndDrawTile( const QgsVectorTileRawData & rawTile ) void QgsVectorTileLayerRenderer::decodeAndDrawTile( const QgsVectorTileRawData & rawTile )
{ {
QgsRenderContext &ctx = *renderContext(); QgsRenderContext &ctx = *renderContext();
QgsDebugMsgLevel( QStringLiteral( "Drawing tile " ) + rawTile.id.toString(), 2 ); QgsDebugMsgLevel( QStringLiteral( "Drawing tile " ) + rawTile.id.toString(), 2 );
QElapsedTimer tLoad; QElapsedTimer tLoad;
skipping to change at line 211 skipping to change at line 216
tile.setTilePolygon( QgsVectorTileUtils::tilePolygon( rawTile.id, ct, mTileMat rix, ctx.mapToPixel() ) ); tile.setTilePolygon( QgsVectorTileUtils::tilePolygon( rawTile.id, ct, mTileMat rix, ctx.mapToPixel() ) );
mTotalDecodeTime += tLoad.elapsed(); mTotalDecodeTime += tLoad.elapsed();
// calculate tile polygon in screen coordinates // calculate tile polygon in screen coordinates
if ( ctx.renderingStopped() ) if ( ctx.renderingStopped() )
return; return;
// set up clipping so that rendering does not go behind tile's extent // set up clipping so that rendering does not go behind tile's extent
ctx.painter()->save();
ctx.painter()->setClipRegion( QRegion( tile.tilePolygon() ) ); // we have to intersect with any existing painter clip regions, or we risk ove
rwriting valid clip
// regions setup outside of the vector tile renderer (e.g. layout map clip reg
ion)
ctx.painter()->setClipRegion( QRegion( tile.tilePolygon() ), Qt::IntersectClip
);
QElapsedTimer tDraw; QElapsedTimer tDraw;
tDraw.start(); tDraw.start();
mRenderer->renderTile( tile, ctx ); mRenderer->renderTile( tile, ctx );
mTotalDrawTime += tDraw.elapsed(); mTotalDrawTime += tDraw.elapsed();
if ( mLabelProvider ) if ( mLabelProvider )
mLabelProvider->registerTileFeatures( tile, ctx ); mLabelProvider->registerTileFeatures( tile, ctx );
if ( mDrawTileBoundaries ) if ( mDrawTileBoundaries )
{ {
ctx.painter()->save();
ctx.painter()->setClipping( false ); ctx.painter()->setClipping( false );
QPen pen( Qt::red ); QPen pen( Qt::red );
pen.setWidth( 3 ); pen.setWidth( 3 );
ctx.painter()->setPen( pen ); ctx.painter()->setPen( pen );
ctx.painter()->drawPolygon( tile.tilePolygon() ); ctx.painter()->drawPolygon( tile.tilePolygon() );
ctx.painter()->restore();
} }
ctx.painter()->restore();
} }
 End of changes. 10 change blocks. 
4 lines changed or deleted 17 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)