Skip to content
Permalink
Browse files

Show closest vertex attributes in identify tool for multipoint layers

  • Loading branch information
nyalldawson committed Dec 2, 2017
1 parent 1625d1f commit 9378f392c8542550e904774c0c6365e35b0db70c
Showing with 27 additions and 15 deletions.
  1. +27 −15 src/gui/qgsmaptoolidentify.cpp
@@ -423,25 +423,37 @@ QMap< QString, QString > QgsMapToolIdentify::featureDerivedAttributes( QgsFeatur
//add details of closest vertex to identify point
closestVertexAttributes( *feature->geometry().constGet(), vId, layer, derivedAttributes );
}
else if ( geometryType == QgsWkbTypes::PointGeometry &&
QgsWkbTypes::flatType( wkbType ) == QgsWkbTypes::Point )
else if ( geometryType == QgsWkbTypes::PointGeometry )
{
// Include the x and y coordinates of the point as a derived attribute
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 ) )
if ( QgsWkbTypes::flatType( wkbType ) == QgsWkbTypes::Point )
{
str = QLocale::system().toString( static_cast<const QgsPoint *>( feature->geometry().constGet() )->z(), 'g', 10 );
derivedAttributes.insert( QStringLiteral( "Z" ), str );
// Include the x and y coordinates of the point as a derived attribute
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 );
derivedAttributes.insert( QStringLiteral( "M" ), str );
//multipart

//add details of closest vertex to identify point
const QgsAbstractGeometry *geom = feature->geometry().constGet();
{
closestVertexAttributes( *geom, vId, layer, derivedAttributes );
}
}
}

0 comments on commit 9378f39

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