Skip to content

Commit

Permalink
put back to derived attrs clicked coordinates
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbruy committed Nov 27, 2012
1 parent 8a339a7 commit 4cfdba4
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions src/app/qgsmaptoolidentify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ bool QgsMapToolIdentify::identifyVectorLayer( QgsVectorLayer *layer, int x, int
return false;
}

QMap< QString, QString > attributes, derivedAttributes;
QMap< QString, QString > derivedAttributes;

QgsPoint point = mCanvas->getCoordinateTransform()->toMapCoordinates( x, y );

Expand Down Expand Up @@ -259,6 +259,7 @@ bool QgsMapToolIdentify::identifyVectorLayer( QgsVectorLayer *layer, int x, int
calc.setEllipsoid( ellipsoid );
calc.setSourceCrs( layer->crs().srsid() );
}

QgsFeatureList::iterator f_it = featureList.begin();

bool filter = false;
Expand All @@ -280,8 +281,6 @@ bool QgsMapToolIdentify::identifyVectorLayer( QgsVectorLayer *layer, int x, int

featureCount++;

QMap<QString, QString> derivedAttributes;

// Calculate derived attributes and insert:
// measure distance or area depending on geometry type
if ( layer->geometryType() == QGis::Line )
Expand All @@ -295,13 +294,15 @@ bool QgsMapToolIdentify::identifyVectorLayer( QgsVectorLayer *layer, int x, int
f_it->geometry()->wkbType() == QGis::WKBLineString25D )
{
// Add the start and end points in as derived attributes
str = QLocale::system().toString( f_it->geometry()->asPolyline().first().x(), 'g', 10 );
QgsPoint pnt = mCanvas->mapRenderer()->layerToMapCoordinates( layer, f_it->geometry()->asPolyline().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( f_it->geometry()->asPolyline().first().y(), 'g', 10 );
str = QLocale::system().toString( pnt.y(), 'g', 10 );
derivedAttributes.insert( tr( "firstY" ), str );
str = QLocale::system().toString( f_it->geometry()->asPolyline().last().x(), 'g', 10 );
pnt = mCanvas->mapRenderer()->layerToMapCoordinates( layer, f_it->geometry()->asPolyline().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( f_it->geometry()->asPolyline().last().y(), 'g', 10 );
str = QLocale::system().toString( pnt.y(), 'g', 10 );
derivedAttributes.insert( tr( "lastY" ), str );
}
}
Expand All @@ -322,10 +323,10 @@ bool QgsMapToolIdentify::identifyVectorLayer( QgsVectorLayer *layer, int x, int
f_it->geometry()->wkbType() == QGis::WKBPoint25D ) )
{
// Include the x and y coordinates of the point as a derived attribute
QString str;
str = QLocale::system().toString( f_it->geometry()->asPoint().x(), 'g', 10 );
QgsPoint pnt = mCanvas->mapRenderer()->layerToMapCoordinates( layer, f_it->geometry()->asPoint() );
QString str = QLocale::system().toString( pnt.x(), 'g', 10 );
derivedAttributes.insert( "X", str );
str = QLocale::system().toString( f_it->geometry()->asPoint().y(), 'g', 10 );
str = QLocale::system().toString( pnt.y(), 'g', 10 );
derivedAttributes.insert( "Y", str );
}

Expand Down

0 comments on commit 4cfdba4

Please sign in to comment.