public SpannableString formatDistance ( double distance ) { double distanceSmallUnit = TurfConversion . convertLength ( distance , TurfConstants . UNIT_METERS , smallUnit ) ; double distanceLargeUnit = TurfConversion . convertLength ( distance , TurfConstants . UNIT_METERS , largeUnit ) ; // If the distance is greater than 10 miles/kilometers, then round to nearest mile/kilometer if ( distanceLargeUnit > LARGE_UNIT_THRESHOLD ) { return getDistanceString ( roundToDecimalPlace ( distanceLargeUnit , 0 ) , largeUnit ) ; // If the distance is less than 401 feet/meters, round by fifty feet/meters } else if ( distanceSmallUnit < SMALL_UNIT_THRESHOLD ) { return getDistanceString ( roundToClosestIncrement ( distanceSmallUnit ) , smallUnit ) ; // If the distance is between 401 feet/meters and 10 miles/kilometers, then round to one decimal place } else { return getDistanceString ( roundToDecimalPlace ( distanceLargeUnit , 1 ) , largeUnit ) ; } }
Returns a formatted SpannableString with bold and size formatting . I . e . 10 mi 350 m