Skip to content

Commit 25988d6

Browse files
committed
show acres after sq ft and before sq mile
1 parent 4a9e8cc commit 25988d6

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

src/core/qgsdistancearea.cpp

+14-6
Original file line numberDiff line numberDiff line change
@@ -761,11 +761,11 @@ QString QgsDistanceArea::textUnit( double value, int decimals, QGis::UnitType u,
761761
{
762762
if ( keepBaseUnit )
763763
{
764-
unitLabel = QObject::tr( " m2" );
764+
unitLabel = QObject::trUtf8( " " );
765765
}
766766
else if ( qAbs( value ) > 1000000.0 )
767767
{
768-
unitLabel = QObject::tr( " km2" );
768+
unitLabel = QObject::trUtf8( " km²" );
769769
value = value / 1000000.0;
770770
}
771771
else if ( qAbs( value ) > 10000.0 )
@@ -775,7 +775,7 @@ QString QgsDistanceArea::textUnit( double value, int decimals, QGis::UnitType u,
775775
}
776776
else
777777
{
778-
unitLabel = QObject::tr( " m2" );
778+
unitLabel = QObject::trUtf8( " " );
779779
}
780780
}
781781
else
@@ -808,14 +808,22 @@ QString QgsDistanceArea::textUnit( double value, int decimals, QGis::UnitType u,
808808
case QGis::Feet:
809809
if ( isArea )
810810
{
811-
if ( keepBaseUnit || qAbs( value ) <= ( 528.0*528.0 ) )
811+
if ( keepBaseUnit || qAbs( value ) <= 0.5*43560.0 )
812812
{
813+
// < 0.5 acre show sq ft
813814
unitLabel = QObject::tr( " sq ft" );
814815
}
816+
else if ( qAbs( value ) <= 0.5*5280.0*5280.0 )
817+
{
818+
// < 0.5 sq mile show acre
819+
unitLabel = QObject::tr( " acres" );
820+
value /= 43560.0;
821+
}
815822
else
816823
{
824+
// above 0.5 acre show sq mi
817825
unitLabel = QObject::tr( " sq mile" );
818-
value = value / ( 5280.0 * 5280.0 );
826+
value /= 5280.0 * 5280.0;
819827
}
820828
}
821829
else
@@ -834,7 +842,7 @@ QString QgsDistanceArea::textUnit( double value, int decimals, QGis::UnitType u,
834842
else
835843
{
836844
unitLabel = QObject::tr( " mile" );
837-
value = value / 5280.0;
845+
value /= 5280.0;
838846
}
839847
}
840848
break;

0 commit comments

Comments
 (0)