@@ -1390,24 +1390,36 @@ QgsRectangle QgsVectorLayer::boundingBoxOfSelected()
13901390 }
13911391
13921392 QgsRectangle r, retval;
1393-
1394-
1395- select ( QgsAttributeList (), QgsRectangle (), true );
1396-
13971393 retval.setMinimal ();
13981394
13991395 QgsFeature fet;
1400- while ( nextFeature ( fet ) )
1396+ if ( mDataProvider -> capabilities () & QgsVectorDataProvider::SelectAtId )
14011397 {
1402- if ( mSelectedFeatureIds . contains ( fet. id () ) )
1398+ foreach ( QgsFeatureId fid, mSelectedFeatureIds )
14031399 {
1404- if ( fet.geometry () )
1400+ if ( featureAtId ( fid, fet, true , false ) && fet.geometry () )
14051401 {
14061402 r = fet.geometry ()->boundingBox ();
14071403 retval.combineExtentWith ( &r );
14081404 }
14091405 }
14101406 }
1407+ else
1408+ {
1409+ select ( QgsAttributeList (), QgsRectangle (), true );
1410+
1411+ while ( nextFeature ( fet ) )
1412+ {
1413+ if ( mSelectedFeatureIds .contains ( fet.id () ) )
1414+ {
1415+ if ( fet.geometry () )
1416+ {
1417+ r = fet.geometry ()->boundingBox ();
1418+ retval.combineExtentWith ( &r );
1419+ }
1420+ }
1421+ }
1422+ }
14111423
14121424 if ( retval.width () == 0.0 || retval.height () == 0.0 )
14131425 {
@@ -5428,7 +5440,7 @@ QString QgsVectorLayer::metadata()
54285440 myMetadata += tr ( " Extents:" );
54295441 myMetadata += " </td></tr>" ;
54305442 // extents in layer cs TODO...maybe make a little nested table to improve layout...
5431- myMetadata += " <tr><td>" ;
5443+ myMetadata += " <tr><td>" + tr ( " In layer spatial reference system units : " ) ;
54325444
54335445 // Try to be a bit clever over what number format we use for the
54345446 // extents. Some people don't like it using scientific notation when the
@@ -5440,44 +5452,51 @@ QString QgsVectorLayer::metadata()
54405452 // - for all smaller numbers let the OS decide which format to use (it will
54415453 // generally use non-scientific unless the number gets much less than 1).
54425454
5443- QString xMin, yMin, xMax, yMax;
5444- double changeoverValue = 99999 ; // The 'largest' 5 digit number
5445- if ( qAbs ( myExtent.xMinimum () ) > changeoverValue )
5446- {
5447- xMin = QString ( " %1" ).arg ( myExtent.xMinimum (), 0 , ' f' , 2 );
5448- }
5449- else
5450- {
5451- xMin = QString ( " %1" ).arg ( myExtent.xMinimum () );
5452- }
5453- if ( qAbs ( myExtent.yMinimum () ) > changeoverValue )
5455+ if ( !myExtent.isEmpty () )
54545456 {
5455- yMin = QString ( " %1" ).arg ( myExtent.yMinimum (), 0 , ' f' , 2 );
5456- }
5457- else
5458- {
5459- yMin = QString ( " %1" ).arg ( myExtent.yMinimum () );
5460- }
5461- if ( qAbs ( myExtent.xMaximum () ) > changeoverValue )
5462- {
5463- xMax = QString ( " %1" ).arg ( myExtent.xMaximum (), 0 , ' f' , 2 );
5464- }
5465- else
5466- {
5467- xMax = QString ( " %1" ).arg ( myExtent.xMaximum () );
5468- }
5469- if ( qAbs ( myExtent.yMaximum () ) > changeoverValue )
5470- {
5471- yMax = QString ( " %1" ).arg ( myExtent.yMaximum (), 0 , ' f' , 2 );
5457+ QString xMin, yMin, xMax, yMax;
5458+ double changeoverValue = 99999 ; // The 'largest' 5 digit number
5459+ if ( qAbs ( myExtent.xMinimum () ) > changeoverValue )
5460+ {
5461+ xMin = QString ( " %1" ).arg ( myExtent.xMinimum (), 0 , ' f' , 2 );
5462+ }
5463+ else
5464+ {
5465+ xMin = QString ( " %1" ).arg ( myExtent.xMinimum () );
5466+ }
5467+ if ( qAbs ( myExtent.yMinimum () ) > changeoverValue )
5468+ {
5469+ yMin = QString ( " %1" ).arg ( myExtent.yMinimum (), 0 , ' f' , 2 );
5470+ }
5471+ else
5472+ {
5473+ yMin = QString ( " %1" ).arg ( myExtent.yMinimum () );
5474+ }
5475+ if ( qAbs ( myExtent.xMaximum () ) > changeoverValue )
5476+ {
5477+ xMax = QString ( " %1" ).arg ( myExtent.xMaximum (), 0 , ' f' , 2 );
5478+ }
5479+ else
5480+ {
5481+ xMax = QString ( " %1" ).arg ( myExtent.xMaximum () );
5482+ }
5483+ if ( qAbs ( myExtent.yMaximum () ) > changeoverValue )
5484+ {
5485+ yMax = QString ( " %1" ).arg ( myExtent.yMaximum (), 0 , ' f' , 2 );
5486+ }
5487+ else
5488+ {
5489+ yMax = QString ( " %1" ).arg ( myExtent.yMaximum () );
5490+ }
5491+
5492+ myMetadata += tr ( " xMin,yMin %1,%2 : xMax,yMax %3,%4" )
5493+ .arg ( xMin ).arg ( yMin ).arg ( xMax ).arg ( yMax );
54725494 }
54735495 else
54745496 {
5475- yMax = QString ( " %1 " ). arg ( myExtent. yMaximum () );
5497+ myMetadata += tr ( " unknown extent " );
54765498 }
54775499
5478- myMetadata += tr ( " In layer spatial reference system units : " )
5479- + tr ( " xMin,yMin %1,%2 : xMax,yMax %3,%4" )
5480- .arg ( xMin ).arg ( yMin ).arg ( xMax ).arg ( yMax );
54815500 myMetadata += " </td></tr>" ;
54825501
54835502 // extents in project cs
0 commit comments