Navigation Menu

Skip to content

Commit

Permalink
Add number of vertices to derived fields in identify tool
Browse files Browse the repository at this point in the history
  • Loading branch information
Sandro Santilli committed Sep 16, 2015
1 parent f0f53b1 commit 2d9424a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/gui/qgsmaptoolidentify.cpp
Expand Up @@ -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 );
Expand Down

0 comments on commit 2d9424a

Please sign in to comment.