Skip to content

Commit

Permalink
Show closest vertex attributes in identify tool for multipoint layers
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Dec 2, 2017
1 parent 1625d1f commit 9378f39
Showing 1 changed file with 27 additions and 15 deletions.
42 changes: 27 additions & 15 deletions src/gui/qgsmaptoolidentify.cpp
Expand Up @@ -423,25 +423,37 @@ QMap< QString, QString > QgsMapToolIdentify::featureDerivedAttributes( QgsFeatur
//add details of closest vertex to identify point //add details of closest vertex to identify point
closestVertexAttributes( *feature->geometry().constGet(), vId, layer, derivedAttributes ); closestVertexAttributes( *feature->geometry().constGet(), vId, layer, derivedAttributes );
} }
else if ( geometryType == QgsWkbTypes::PointGeometry && else if ( geometryType == QgsWkbTypes::PointGeometry )
QgsWkbTypes::flatType( wkbType ) == QgsWkbTypes::Point )
{ {
// Include the x and y coordinates of the point as a derived attribute if ( QgsWkbTypes::flatType( wkbType ) == QgsWkbTypes::Point )
QgsPointXY pnt = mCanvas->mapSettings().layerToMapCoordinates( layer, feature->geometry().asPoint() );
QString str = formatXCoordinate( pnt );
derivedAttributes.insert( QStringLiteral( "X" ), str );
str = formatYCoordinate( pnt );
derivedAttributes.insert( QStringLiteral( "Y" ), str );

if ( QgsWkbTypes::hasZ( wkbType ) )
{ {
str = QLocale::system().toString( static_cast<const QgsPoint *>( feature->geometry().constGet() )->z(), 'g', 10 ); // Include the x and y coordinates of the point as a derived attribute
derivedAttributes.insert( QStringLiteral( "Z" ), str ); QgsPointXY pnt = mCanvas->mapSettings().layerToMapCoordinates( layer, feature->geometry().asPoint() );
QString str = formatXCoordinate( pnt );
derivedAttributes.insert( QStringLiteral( "X" ), str );
str = formatYCoordinate( pnt );
derivedAttributes.insert( QStringLiteral( "Y" ), str );

if ( QgsWkbTypes::hasZ( wkbType ) )
{
str = QLocale::system().toString( static_cast<const QgsPoint *>( feature->geometry().constGet() )->z(), 'g', 10 );
derivedAttributes.insert( QStringLiteral( "Z" ), str );
}
if ( QgsWkbTypes::hasM( wkbType ) )
{
str = QLocale::system().toString( static_cast<const QgsPoint *>( feature->geometry().constGet() )->m(), 'g', 10 );
derivedAttributes.insert( QStringLiteral( "M" ), str );
}
} }
if ( QgsWkbTypes::hasM( wkbType ) ) else
{ {
str = QLocale::system().toString( static_cast<const QgsPoint *>( feature->geometry().constGet() )->m(), 'g', 10 ); //multipart
derivedAttributes.insert( QStringLiteral( "M" ), str );
//add details of closest vertex to identify point
const QgsAbstractGeometry *geom = feature->geometry().constGet();
{
closestVertexAttributes( *geom, vId, layer, derivedAttributes );
}
} }
} }


Expand Down

0 comments on commit 9378f39

Please sign in to comment.