Skip to content

Commit 9378f39

Browse files
committed
Show closest vertex attributes in identify tool for multipoint layers
1 parent 1625d1f commit 9378f39

File tree

1 file changed

+27
-15
lines changed

1 file changed

+27
-15
lines changed

src/gui/qgsmaptoolidentify.cpp

+27-15
Original file line numberDiff line numberDiff line change
@@ -423,25 +423,37 @@ QMap< QString, QString > QgsMapToolIdentify::featureDerivedAttributes( QgsFeatur
423423
//add details of closest vertex to identify point
424424
closestVertexAttributes( *feature->geometry().constGet(), vId, layer, derivedAttributes );
425425
}
426-
else if ( geometryType == QgsWkbTypes::PointGeometry &&
427-
QgsWkbTypes::flatType( wkbType ) == QgsWkbTypes::Point )
426+
else if ( geometryType == QgsWkbTypes::PointGeometry )
428427
{
429-
// Include the x and y coordinates of the point as a derived attribute
430-
QgsPointXY pnt = mCanvas->mapSettings().layerToMapCoordinates( layer, feature->geometry().asPoint() );
431-
QString str = formatXCoordinate( pnt );
432-
derivedAttributes.insert( QStringLiteral( "X" ), str );
433-
str = formatYCoordinate( pnt );
434-
derivedAttributes.insert( QStringLiteral( "Y" ), str );
435-
436-
if ( QgsWkbTypes::hasZ( wkbType ) )
428+
if ( QgsWkbTypes::flatType( wkbType ) == QgsWkbTypes::Point )
437429
{
438-
str = QLocale::system().toString( static_cast<const QgsPoint *>( feature->geometry().constGet() )->z(), 'g', 10 );
439-
derivedAttributes.insert( QStringLiteral( "Z" ), str );
430+
// Include the x and y coordinates of the point as a derived attribute
431+
QgsPointXY pnt = mCanvas->mapSettings().layerToMapCoordinates( layer, feature->geometry().asPoint() );
432+
QString str = formatXCoordinate( pnt );
433+
derivedAttributes.insert( QStringLiteral( "X" ), str );
434+
str = formatYCoordinate( pnt );
435+
derivedAttributes.insert( QStringLiteral( "Y" ), str );
436+
437+
if ( QgsWkbTypes::hasZ( wkbType ) )
438+
{
439+
str = QLocale::system().toString( static_cast<const QgsPoint *>( feature->geometry().constGet() )->z(), 'g', 10 );
440+
derivedAttributes.insert( QStringLiteral( "Z" ), str );
441+
}
442+
if ( QgsWkbTypes::hasM( wkbType ) )
443+
{
444+
str = QLocale::system().toString( static_cast<const QgsPoint *>( feature->geometry().constGet() )->m(), 'g', 10 );
445+
derivedAttributes.insert( QStringLiteral( "M" ), str );
446+
}
440447
}
441-
if ( QgsWkbTypes::hasM( wkbType ) )
448+
else
442449
{
443-
str = QLocale::system().toString( static_cast<const QgsPoint *>( feature->geometry().constGet() )->m(), 'g', 10 );
444-
derivedAttributes.insert( QStringLiteral( "M" ), str );
450+
//multipart
451+
452+
//add details of closest vertex to identify point
453+
const QgsAbstractGeometry *geom = feature->geometry().constGet();
454+
{
455+
closestVertexAttributes( *geom, vId, layer, derivedAttributes );
456+
}
445457
}
446458
}
447459

0 commit comments

Comments
 (0)