Skip to content
Permalink
Browse files

Make sure point cloud results in identify dock follow same behavior a…

…s vector
  • Loading branch information
nyalldawson authored and wonder-sk committed Jan 5, 2021
1 parent 1808a44 commit 736dff5b27b0a32654fc6770667f0801adf5176c
Showing with 12 additions and 6 deletions.
  1. +7 −3 src/app/qgsidentifyresultsdialog.cpp
  2. +5 −3 src/gui/qgsmaptoolidentify.cpp
@@ -1276,7 +1276,7 @@ void QgsIdentifyResultsDialog::addFeature( QgsPointCloudLayer *layer,

if ( !layItem )
{
layItem = new QTreeWidgetItem( QStringList() << layer->name() << QString::number( lstResults->topLevelItemCount() ) );
layItem = new QTreeWidgetItem( QStringList() << layer->name() );
layItem->setData( 0, Qt::UserRole, QVariant::fromValue( qobject_cast<QObject *>( layer ) ) );
lstResults->addTopLevelItem( layItem );
QFont boldFont;
@@ -1291,9 +1291,13 @@ void QgsIdentifyResultsDialog::addFeature( QgsPointCloudLayer *layer,
QgsFeature(),
layer->crs(),
QStringList() << label << QString() );

layItem->addChild( featItem );
featItem->setExpanded( true );

layItem->setFirstColumnSpanned( true );
QString countSuffix = layItem->childCount() > 1
? QStringLiteral( " [%1]" ).arg( layItem->childCount() )
: QString();
layItem->setText( 0, QStringLiteral( "%1 %2" ).arg( layer->name(), countSuffix ) );

// attributes
for ( QMap<QString, QString>::const_iterator it = attributes.begin(); it != attributes.end(); ++it )
@@ -516,11 +516,12 @@ bool QgsMapToolIdentify::identifyPointCloudLayer( QList<QgsMapToolIdentify::Iden
const double searchRadiusMapUnits = mOverrideCanvasSearchRadius < 0 ? searchRadiusMU( mCanvas ) : mOverrideCanvasSearchRadius;

const QVector<QVariantMap> points = renderer->identify( layer, context, geometry, searchRadiusMapUnits );
int id = 0;
int id = 1;
const QgsPointCloudLayerElevationProperties *elevationProps = qobject_cast< const QgsPointCloudLayerElevationProperties *>( layer->elevationProperties() );
for ( const QVariantMap &pt : points )
{
QMap<QString, QString> ptStr;
QString classification;
for ( auto attrIt = pt.constBegin(); attrIt != pt.constEnd(); ++attrIt )
{
if ( attrIt.key().compare( QLatin1String( "Z" ), Qt::CaseInsensitive ) == 0
@@ -532,14 +533,15 @@ bool QgsMapToolIdentify::identifyPointCloudLayer( QList<QgsMapToolIdentify::Iden
}
else if ( attrIt.key().compare( QLatin1String( "Classification" ), Qt::CaseInsensitive ) == 0 )
{
ptStr[ attrIt.key() ] = QStringLiteral( "%1 (%2)" ).arg( attrIt.value().toString(), QgsPointCloudDataProvider::translatedLasClassificationCodes().value( attrIt.value().toInt() ) );
classification = QgsPointCloudDataProvider::translatedLasClassificationCodes().value( attrIt.value().toInt() );
ptStr[ attrIt.key() ] = QStringLiteral( "%1 (%2)" ).arg( attrIt.value().toString(), classification );
}
else
{
ptStr[attrIt.key()] = attrIt.value().toString();
}
}
QgsMapToolIdentify::IdentifyResult res( layer, QString::number( id ), ptStr, ptStr );
QgsMapToolIdentify::IdentifyResult res( layer, classification.isEmpty() ? QString::number( id ) : QStringLiteral( "%1 (%2)" ).arg( id ).arg( classification ), ptStr, QMap<QString, QString>() );
results->append( res );
++id;
}

0 comments on commit 736dff5

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