Skip to content
Permalink
Browse files

Correct vertex count when using identify tool on curved lines

  • Loading branch information
nyalldawson committed Dec 22, 2015
1 parent 06553db commit 2963408e8e9c8235fd66c2bf0b69131a794e0106
Showing with 11 additions and 9 deletions.
  1. +11 −9 src/gui/qgsmaptoolidentify.cpp
@@ -37,6 +37,7 @@
#include "qgsrendererv2.h"
#include "qgsgeometryutils.h"
#include "qgsgeometrycollectionv2.h"
#include "qgscurvev2.h"

#include <QSettings>
#include <QMouseEvent>
@@ -346,27 +347,28 @@ QMap< QString, QString > QgsMapToolIdentify::featureDerivedAttributes( QgsFeatur

if ( geometryType == QGis::Line )
{
const QgsPolyline &pline = feature->constGeometry()->asPolyline();
double dist = calc.measureLength( 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 );

//add details of closest vertex to identify point
closestVertexAttributes( *feature->constGeometry()->geometry(), vId, layer, derivedAttributes );

if ( QgsWKBTypes::flatType( wkbType ) == QgsWKBTypes::LineString )
const QgsCurveV2* curve = dynamic_cast< const QgsCurveV2* >( feature->constGeometry()->geometry() );
if ( curve )
{
str = QLocale::system().toString( curve->nCoordinates() );
derivedAttributes.insert( tr( "Vertices" ), str );

//add details of closest vertex to identify point
closestVertexAttributes( *curve, vId, layer, derivedAttributes );

// Add the start and end points in as derived attributes
QgsPoint pnt = mCanvas->mapSettings().layerToMapCoordinates( layer, pline.first() );
QgsPoint pnt = mCanvas->mapSettings().layerToMapCoordinates( layer, QgsPoint( curve->startPoint().x(), curve->startPoint().y() ) );
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, pline.last() );
pnt = mCanvas->mapSettings().layerToMapCoordinates( layer, QgsPoint( curve->endPoint().x(), curve->endPoint().y() ) );
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 2963408

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