Skip to content

Instantly share code, notes, and snippets.

@jef-n
Created April 4, 2012 20:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jef-n/2305551 to your computer and use it in GitHub Desktop.
Save jef-n/2305551 to your computer and use it in GitHub Desktop.
diff --git a/src/core/qgsdistancearea.cpp b/src/core/qgsdistancearea.cpp
index 269e0ae..bbcb5d5 100644
@@ -808,14 +808,22 @@ QString QgsDistanceArea::textUnit( double value, int decimals, QGis::UnitType u,
case QGis::Feet:
if ( isArea )
{
- if ( keepBaseUnit || qAbs( value ) <= ( 528.0*528.0 ) )
+ if ( keepBaseUnit || qAbs( value ) <= 0.5*43560.0 )
{
+ // < 0.5 acre show sq ft
unitLabel = QObject::tr( " sq ft" );
}
+ else if ( qAbs( value ) <= 0.5*5280.0*5280.0 )
+ {
+ // < 0.5 sq mile show acre
+ unitLabel = QObject::tr( " acre" );
+ value /= 43560.0;
+ }
else
{
+ // above 0.5 acre show sq mi
unitLabel = QObject::tr( " sq mile" );
- value = value / ( 5280.0 * 5280.0 );
+ value /= 5280.0 * 5280.0;
}
}
else
@wildintellect
Copy link

  • so you're removing if area is <= .01 sq miles and swapping for if area if <= .5 acres do sq ft
  • else if area <= 1/2 a sq mile do acres
  • else do square miles

Calculation wise it looks fine. I'm not really sure what most ends users expect other than to be able to toggle between acres/miles easily.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment