Skip to content
Permalink
Browse files

Calculate point cloud attributes to fetch based on renderer's needs

  • Loading branch information
nyalldawson committed Nov 12, 2020
1 parent 1feccd1 commit 4e38237e4b8cfa03d3242c2125af507b0cf334cc
Showing with 21 additions and 9 deletions.
  1. +21 −9 src/core/pointcloud/qgspointcloudlayerrenderer.cpp
@@ -126,15 +126,6 @@ QgsPointCloudLayerRenderer::QgsPointCloudLayerRenderer( QgsPointCloudLayer *laye

mRenderer.reset( mLayer->renderer()->clone() );

mAttributes.push_back( QgsPointCloudAttribute( QStringLiteral( "X" ), QgsPointCloudAttribute::Int32 ) );
mAttributes.push_back( QgsPointCloudAttribute( QStringLiteral( "Y" ), QgsPointCloudAttribute::Int32 ) );

int offset;
const QgsPointCloudAttribute *renderAttribute = mLayer->attributes().find( mConfig.attribute(), offset );
if ( !renderAttribute )
return;

mAttributes.push_back( *renderAttribute );
mScale = mLayer->dataProvider()->index()->scale();
mOffset = mLayer->dataProvider()->index()->offset();
}
@@ -149,6 +140,27 @@ bool QgsPointCloudLayerRenderer::render()
QgsPointCloudRenderContext context( *renderContext(), mScale, mOffset );


mAttributes.push_back( QgsPointCloudAttribute( QStringLiteral( "X" ), QgsPointCloudAttribute::Int32 ) );
mAttributes.push_back( QgsPointCloudAttribute( QStringLiteral( "Y" ), QgsPointCloudAttribute::Int32 ) );

// collect attributes required by renderer
const QSet< QString > rendererAttributes = mRenderer->usedAttributes( context );
for ( const QString &attribute : rendererAttributes )
{
if ( mAttributes.indexOf( attribute ) >= 0 )
continue; // don't re-add attributes we are already going to fetch

const int layerIndex = mLayer->attributes().indexOf( attribute );
if ( layerIndex < 0 )
{
QgsMessageLog::logMessage( QObject::tr( "Required attribute %1 not found in layer" ).arg( attribute ), QObject::tr( "Point Cloud" ) );
continue;
}

mAttributes.push_back( mLayer->attributes().at( layerIndex ) );
}


// Set up the render configuration options
QPainter *painter = context.renderContext().painter();

0 comments on commit 4e38237

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