Skip to content
Permalink
Browse files

Show both original z value and adjusted z value in identify results w…

…hen layer has z adjustment present
  • Loading branch information
nyalldawson authored and wonder-sk committed Jan 4, 2021
1 parent 5fea462 commit 12a40f100ec4039807b2c592aee1a77d7fd7978c
Showing with 17 additions and 7 deletions.
  1. +17 −7 src/gui/qgsmaptoolidentify.cpp
@@ -527,17 +527,27 @@ bool QgsMapToolIdentify::identifyPointCloudLayer( QList<QgsMapToolIdentify::Iden
}

QgsRenderContext context = QgsRenderContext::fromMapSettings( mCanvas->mapSettings() );
QVector<QMap<QString, QVariant>> points = renderer->identify( layer, context, transformedGeometry );
const QVector<QVariantMap> points = renderer->identify( layer, context, transformedGeometry );
int id = 0;
QgsPointCloudLayerElevationProperties *elevationProps = dynamic_cast<QgsPointCloudLayerElevationProperties *>( layer->elevationProperties() );
for ( QMap<QString, QVariant> pt : points )
const QgsPointCloudLayerElevationProperties *elevationProps = qobject_cast< const QgsPointCloudLayerElevationProperties *>( layer->elevationProperties() );
for ( const QVariantMap &pt : points )
{
// Apply elevation properties
pt["Z"] = pt["Z"].toReal() * elevationProps->zScale() + elevationProps->zOffset();
// TODO: replace this conversion with something better
QMap<QString, QString> ptStr;
for ( QString key : pt.keys() )
ptStr[key] = pt[key].toString();
for ( auto attrIt = pt.constBegin(); attrIt != pt.constEnd(); ++attrIt )
{
if ( attrIt.key().compare( QLatin1String( "Z" ), Qt::CaseInsensitive ) == 0
&& ( !qgsDoubleNear( elevationProps->zScale(), 1 ) || !qgsDoubleNear( elevationProps->zOffset(), 0 ) ) )
{
// Apply elevation properties
ptStr[ tr( "Z (original)" ) ] = attrIt.value().toString();
ptStr[ tr( "Z (adjusted)" ) ] = QString::number( attrIt.value().toDouble() * elevationProps->zScale() + elevationProps->zOffset() );
}
else
{
ptStr[attrIt.key()] = attrIt.value().toString();
}
}
QgsMapToolIdentify::IdentifyResult res( layer, QString::number( id ), ptStr, ptStr );
results->append( res );
++id;

0 comments on commit 12a40f1

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