@@ -781,10 +781,58 @@ QString QgsVectorLayerProperties::metadata()
781
781
myMetadata += " </td></tr>" ;
782
782
// extents in layer cs TODO...maybe make a little nested table to improve layout...
783
783
myMetadata += " <tr><td>" ;
784
+
785
+ // Try to be a bit clever over what number format we use for the
786
+ // extents. Some people don't like it using scientific notation when the
787
+ // numbers get large, but for small numbers this is the more practical
788
+ // option (so we can't force the format to 'f' for all values).
789
+ // The scheme:
790
+ // - for all numbers with more than 5 digits, force non-scientific notation
791
+ // and 2 digits after the decimal point.
792
+ // - for all smaller numbers let the OS decide which format to use (it will
793
+ // generally use non-scientific unless the number gets much less than 1).
794
+
795
+ QString xMin, yMin, xMax, yMax;
796
+ double changeoverValue = 99999 ; // The 'largest' 5 digit number
797
+ if (fabs (myExtent.xMinimum ()) > changeoverValue)
798
+ {
799
+ xMin = QString (" %1" ).arg (myExtent.xMinimum (), 0 , ' f' , 2 );
800
+ }
801
+ else
802
+ {
803
+ xMin = QString (" %1" ).arg (myExtent.xMinimum ());
804
+ }
805
+
806
+ if (fabs (myExtent.yMinimum ()) > changeoverValue)
807
+ {
808
+ yMin = QString (" %1" ).arg (myExtent.yMinimum (), 0 , ' f' , 2 );
809
+ }
810
+ else
811
+ {
812
+ yMin = QString (" %1" ).arg (myExtent.yMinimum ());
813
+ }
814
+
815
+ if (fabs (myExtent.xMaximum ()) > changeoverValue)
816
+ {
817
+ xMax = QString (" %1" ).arg (myExtent.xMaximum (), 0 , ' f' , 2 );
818
+ }
819
+ else
820
+ {
821
+ xMax = QString (" %1" ).arg (myExtent.xMaximum ());
822
+ }
823
+
824
+ if (fabs (myExtent.yMaximum ()) > changeoverValue)
825
+ {
826
+ yMax = QString (" %1" ).arg (myExtent.yMaximum (), 0 , ' f' , 2 );
827
+ }
828
+ else
829
+ {
830
+ yMax = QString (" %1" ).arg (myExtent.yMaximum ());
831
+ }
832
+
784
833
myMetadata += tr ( " In layer spatial reference system units : " )
785
834
+ tr ( " xMin,yMin %1,%2 : xMax,yMax %3,%4" )
786
- .arg ( myExtent.xMinimum () ).arg ( myExtent.yMinimum () )
787
- .arg ( myExtent.xMaximum () ).arg ( myExtent.yMaximum () );
835
+ .arg ( xMin ).arg ( yMin ).arg ( xMax ).arg ( yMax );
788
836
myMetadata += " </td></tr>" ;
789
837
790
838
// extents in project cs
0 commit comments