@@ -326,18 +326,6 @@ void QgsMapToolIdentify::closestVertexAttributes( const QgsAbstractGeometry &geo
326
326
}
327
327
}
328
328
329
- void QgsMapToolIdentify::closestPointAttributes ( const QgsAbstractGeometry &geometry, QgsMapLayer *layer, const QgsPointXY &layerPoint, QMap< QString, QString > &derivedAttributes )
330
- {
331
- Q_UNUSED ( layer );
332
- // measure
333
- if ( QgsWkbTypes::hasM ( geometry.wkbType () ) )
334
- {
335
- QgsPoint closestPoint = QgsGeometryUtils::closestPoint ( geometry, QgsPoint ( layerPoint.x (), layerPoint.y () ) );
336
- QString str = QLocale::system ().toString ( closestPoint.m (), ' g' , 10 );
337
- derivedAttributes.insert ( QStringLiteral ( " Closest point M" ), str );
338
- }
339
- }
340
-
341
329
QString QgsMapToolIdentify::formatCoordinate ( const QgsPointXY &canvasPoint ) const
342
330
{
343
331
return QgsCoordinateUtils::formatCoordinateForProject ( canvasPoint, mCanvas ->mapSettings ().destinationCrs (),
@@ -396,27 +384,28 @@ QMap< QString, QString > QgsMapToolIdentify::featureDerivedAttributes( QgsFeatur
396
384
QString str = formatDistance ( dist );
397
385
derivedAttributes.insert ( tr ( " Length" ), str );
398
386
399
- const QgsCurve *curve = qgsgeometry_cast< const QgsCurve * >( feature->geometry ().constGet () );
400
- if ( curve )
387
+ const QgsAbstractGeometry *geom = feature->geometry ().constGet ();
388
+ if ( geom )
401
389
{
402
- str = QLocale::system ().toString ( curve ->nCoordinates () );
390
+ str = QLocale::system ().toString ( geom ->nCoordinates () );
403
391
derivedAttributes.insert ( tr ( " Vertices" ), str );
404
-
405
392
// add details of closest vertex to identify point
406
- closestVertexAttributes ( *curve, vId, layer, derivedAttributes );
407
- closestPointAttributes ( *curve, layer, layerPoint, derivedAttributes );
408
-
409
- // Add the start and end points in as derived attributes
410
- QgsPointXY pnt = mCanvas ->mapSettings ().layerToMapCoordinates ( layer, QgsPointXY ( curve->startPoint ().x (), curve->startPoint ().y () ) );
411
- str = formatXCoordinate ( pnt );
412
- derivedAttributes.insert ( tr ( " firstX" , " attributes get sorted; translation for lastX should be lexically larger than this one" ), str );
413
- str = formatYCoordinate ( pnt );
414
- derivedAttributes.insert ( tr ( " firstY" ), str );
415
- pnt = mCanvas ->mapSettings ().layerToMapCoordinates ( layer, QgsPointXY ( curve->endPoint ().x (), curve->endPoint ().y () ) );
416
- str = formatXCoordinate ( pnt );
417
- derivedAttributes.insert ( tr ( " lastX" , " attributes get sorted; translation for firstX should be lexically smaller than this one" ), str );
418
- str = formatYCoordinate ( pnt );
419
- derivedAttributes.insert ( tr ( " lastY" ), str );
393
+ closestVertexAttributes ( *geom, vId, layer, derivedAttributes );
394
+
395
+ if ( const QgsCurve *curve = qgsgeometry_cast< const QgsCurve * >( geom ) )
396
+ {
397
+ // Add the start and end points in as derived attributes
398
+ QgsPointXY pnt = mCanvas ->mapSettings ().layerToMapCoordinates ( layer, QgsPointXY ( curve->startPoint ().x (), curve->startPoint ().y () ) );
399
+ str = formatXCoordinate ( pnt );
400
+ derivedAttributes.insert ( tr ( " firstX" , " attributes get sorted; translation for lastX should be lexically larger than this one" ), str );
401
+ str = formatYCoordinate ( pnt );
402
+ derivedAttributes.insert ( tr ( " firstY" ), str );
403
+ pnt = mCanvas ->mapSettings ().layerToMapCoordinates ( layer, QgsPointXY ( curve->endPoint ().x (), curve->endPoint ().y () ) );
404
+ str = formatXCoordinate ( pnt );
405
+ derivedAttributes.insert ( tr ( " lastX" , " attributes get sorted; translation for firstX should be lexically smaller than this one" ), str );
406
+ str = formatYCoordinate ( pnt );
407
+ derivedAttributes.insert ( tr ( " lastY" ), str );
408
+ }
420
409
}
421
410
}
422
411
else if ( geometryType == QgsWkbTypes::PolygonGeometry )
0 commit comments