Skip to content
Permalink
Browse files

Add number of vertices to derived fields in identify tool

  • Loading branch information
Sandro Santilli
Sandro Santilli committed Sep 16, 2015
1 parent f0f53b1 commit 2d9424afdd715c00c09eec2ec54251f18cd8c9a6
Showing with 5 additions and 2 deletions.
  1. +5 −2 src/gui/qgsmaptoolidentify.cpp
@@ -307,20 +307,23 @@ QMap< QString, QString > QgsMapToolIdentify::featureDerivedAttributes( QgsFeatur

if ( geometryType == QGis::Line )
{
const QgsPolyline &pline = feature->constGeometry()->asPolyline();
double dist = calc.measure( feature->constGeometry() );
QGis::UnitType myDisplayUnits;
convertMeasurement( calc, dist, myDisplayUnits, false );
QString str = calc.textUnit( dist, 3, myDisplayUnits, false ); // dist and myDisplayUnits are out params
derivedAttributes.insert( tr( "Length" ), str );
str = QLocale::system().toString( pline.size() );
derivedAttributes.insert( tr( "Vertices" ), str );
if ( wkbType == QGis::WKBLineString || wkbType == QGis::WKBLineString25D )
{
// Add the start and end points in as derived attributes
QgsPoint pnt = mCanvas->mapSettings().layerToMapCoordinates( layer, feature->constGeometry()->asPolyline().first() );
QgsPoint pnt = mCanvas->mapSettings().layerToMapCoordinates( layer, pline.first() );
str = QLocale::system().toString( pnt.x(), 'g', 10 );
derivedAttributes.insert( tr( "firstX", "attributes get sorted; translation for lastX should be lexically larger than this one" ), str );
str = QLocale::system().toString( pnt.y(), 'g', 10 );
derivedAttributes.insert( tr( "firstY" ), str );
pnt = mCanvas->mapSettings().layerToMapCoordinates( layer, feature->constGeometry()->asPolyline().last() );
pnt = mCanvas->mapSettings().layerToMapCoordinates( layer, pline.last() );
str = QLocale::system().toString( pnt.x(), 'g', 10 );
derivedAttributes.insert( tr( "lastX", "attributes get sorted; translation for firstX should be lexically smaller than this one" ), str );
str = QLocale::system().toString( pnt.y(), 'g', 10 );

0 comments on commit 2d9424a

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