Skip to content

Commit 2d9424a

Browse files
author
Sandro Santilli
committedSep 16, 2015
Add number of vertices to derived fields in identify tool
1 parent f0f53b1 commit 2d9424a

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed
 

‎src/gui/qgsmaptoolidentify.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,20 +307,23 @@ QMap< QString, QString > QgsMapToolIdentify::featureDerivedAttributes( QgsFeatur
307307

308308
if ( geometryType == QGis::Line )
309309
{
310+
const QgsPolyline &pline = feature->constGeometry()->asPolyline();
310311
double dist = calc.measure( feature->constGeometry() );
311312
QGis::UnitType myDisplayUnits;
312313
convertMeasurement( calc, dist, myDisplayUnits, false );
313314
QString str = calc.textUnit( dist, 3, myDisplayUnits, false ); // dist and myDisplayUnits are out params
314315
derivedAttributes.insert( tr( "Length" ), str );
316+
str = QLocale::system().toString( pline.size() );
317+
derivedAttributes.insert( tr( "Vertices" ), str );
315318
if ( wkbType == QGis::WKBLineString || wkbType == QGis::WKBLineString25D )
316319
{
317320
// Add the start and end points in as derived attributes
318-
QgsPoint pnt = mCanvas->mapSettings().layerToMapCoordinates( layer, feature->constGeometry()->asPolyline().first() );
321+
QgsPoint pnt = mCanvas->mapSettings().layerToMapCoordinates( layer, pline.first() );
319322
str = QLocale::system().toString( pnt.x(), 'g', 10 );
320323
derivedAttributes.insert( tr( "firstX", "attributes get sorted; translation for lastX should be lexically larger than this one" ), str );
321324
str = QLocale::system().toString( pnt.y(), 'g', 10 );
322325
derivedAttributes.insert( tr( "firstY" ), str );
323-
pnt = mCanvas->mapSettings().layerToMapCoordinates( layer, feature->constGeometry()->asPolyline().last() );
326+
pnt = mCanvas->mapSettings().layerToMapCoordinates( layer, pline.last() );
324327
str = QLocale::system().toString( pnt.x(), 'g', 10 );
325328
derivedAttributes.insert( tr( "lastX", "attributes get sorted; translation for firstX should be lexically smaller than this one" ), str );
326329
str = QLocale::system().toString( pnt.y(), 'g', 10 );

0 commit comments

Comments
 (0)
Please sign in to comment.