Skip to content

Commit 4cfdba4

Browse files
committed
put back to derived attrs clicked coordinates
1 parent 8a339a7 commit 4cfdba4

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

src/app/qgsmaptoolidentify.cpp

+11-10
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ bool QgsMapToolIdentify::identifyVectorLayer( QgsVectorLayer *layer, int x, int
205205
return false;
206206
}
207207

208-
QMap< QString, QString > attributes, derivedAttributes;
208+
QMap< QString, QString > derivedAttributes;
209209

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

@@ -259,6 +259,7 @@ bool QgsMapToolIdentify::identifyVectorLayer( QgsVectorLayer *layer, int x, int
259259
calc.setEllipsoid( ellipsoid );
260260
calc.setSourceCrs( layer->crs().srsid() );
261261
}
262+
262263
QgsFeatureList::iterator f_it = featureList.begin();
263264

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

281282
featureCount++;
282283

283-
QMap<QString, QString> derivedAttributes;
284-
285284
// Calculate derived attributes and insert:
286285
// measure distance or area depending on geometry type
287286
if ( layer->geometryType() == QGis::Line )
@@ -295,13 +294,15 @@ bool QgsMapToolIdentify::identifyVectorLayer( QgsVectorLayer *layer, int x, int
295294
f_it->geometry()->wkbType() == QGis::WKBLineString25D )
296295
{
297296
// 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 );
299299
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 );
301301
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 );
303304
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 );
305306
derivedAttributes.insert( tr( "lastY" ), str );
306307
}
307308
}
@@ -322,10 +323,10 @@ bool QgsMapToolIdentify::identifyVectorLayer( QgsVectorLayer *layer, int x, int
322323
f_it->geometry()->wkbType() == QGis::WKBPoint25D ) )
323324
{
324325
// 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 );
327328
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 );
329330
derivedAttributes.insert( "Y", str );
330331
}
331332

0 commit comments

Comments
 (0)