@@ -205,7 +205,7 @@ bool QgsMapToolIdentify::identifyVectorLayer( QgsVectorLayer *layer, int x, int
205
205
return false ;
206
206
}
207
207
208
- QMap< QString, QString > attributes, derivedAttributes;
208
+ QMap< QString, QString > derivedAttributes;
209
209
210
210
QgsPoint point = mCanvas ->getCoordinateTransform ()->toMapCoordinates ( x, y );
211
211
@@ -259,6 +259,7 @@ bool QgsMapToolIdentify::identifyVectorLayer( QgsVectorLayer *layer, int x, int
259
259
calc.setEllipsoid ( ellipsoid );
260
260
calc.setSourceCrs ( layer->crs ().srsid () );
261
261
}
262
+
262
263
QgsFeatureList::iterator f_it = featureList.begin ();
263
264
264
265
bool filter = false ;
@@ -280,8 +281,6 @@ bool QgsMapToolIdentify::identifyVectorLayer( QgsVectorLayer *layer, int x, int
280
281
281
282
featureCount++;
282
283
283
- QMap<QString, QString> derivedAttributes;
284
-
285
284
// Calculate derived attributes and insert:
286
285
// measure distance or area depending on geometry type
287
286
if ( layer->geometryType () == QGis::Line )
@@ -295,13 +294,15 @@ bool QgsMapToolIdentify::identifyVectorLayer( QgsVectorLayer *layer, int x, int
295
294
f_it->geometry ()->wkbType () == QGis::WKBLineString25D )
296
295
{
297
296
// Add the start and end points in as derived attributes
298
- str = QLocale::system ().toString ( f_it->geometry ()->asPolyline ().first ().x (), ' g' , 10 );
297
+ QgsPoint pnt = mCanvas ->mapRenderer ()->layerToMapCoordinates ( layer, f_it->geometry ()->asPolyline ().first () );
298
+ str = QLocale::system ().toString ( pnt.x (), ' g' , 10 );
299
299
derivedAttributes.insert ( tr ( " firstX" , " attributes get sorted; translation for lastX should be lexically larger than this one" ), str );
300
- str = QLocale::system ().toString ( f_it-> geometry ()-> asPolyline (). first () .y (), ' g' , 10 );
300
+ str = QLocale::system ().toString ( pnt .y (), ' g' , 10 );
301
301
derivedAttributes.insert ( tr ( " firstY" ), str );
302
- str = QLocale::system ().toString ( f_it->geometry ()->asPolyline ().last ().x (), ' g' , 10 );
302
+ pnt = mCanvas ->mapRenderer ()->layerToMapCoordinates ( layer, f_it->geometry ()->asPolyline ().last () );
303
+ str = QLocale::system ().toString ( pnt.x (), ' g' , 10 );
303
304
derivedAttributes.insert ( tr ( " lastX" , " attributes get sorted; translation for firstX should be lexically smaller than this one" ), str );
304
- str = QLocale::system ().toString ( f_it-> geometry ()-> asPolyline (). last () .y (), ' g' , 10 );
305
+ str = QLocale::system ().toString ( pnt .y (), ' g' , 10 );
305
306
derivedAttributes.insert ( tr ( " lastY" ), str );
306
307
}
307
308
}
@@ -322,10 +323,10 @@ bool QgsMapToolIdentify::identifyVectorLayer( QgsVectorLayer *layer, int x, int
322
323
f_it->geometry ()->wkbType () == QGis::WKBPoint25D ) )
323
324
{
324
325
// Include the x and y coordinates of the point as a derived attribute
325
- QString str ;
326
- str = QLocale::system ().toString ( f_it-> geometry ()-> asPoint () .x (), ' g' , 10 );
326
+ QgsPoint pnt = mCanvas -> mapRenderer ()-> layerToMapCoordinates ( layer, f_it-> geometry ()-> asPoint () ) ;
327
+ QString str = QLocale::system ().toString ( pnt .x (), ' g' , 10 );
327
328
derivedAttributes.insert ( " X" , str );
328
- str = QLocale::system ().toString ( f_it-> geometry ()-> asPoint () .y (), ' g' , 10 );
329
+ str = QLocale::system ().toString ( pnt .y (), ' g' , 10 );
329
330
derivedAttributes.insert ( " Y" , str );
330
331
}
331
332
0 commit comments