formatDistance

fun formatDistance(distance: <Error class: unknown class>): FormattedDistance

Formats a given Distance into a FormattedDistance according to following rules:

  • When format is DistanceFormat.KILOMETERS_AND_METERS, the Distance will be formatted in kilometers and meters. For example: with a 949 meters distance, the formatted distance string is 900 m, with a 950 meters distance - 1.0 km.

  • When format is DistanceFormat.MILES_AND_FEET, the Distance will be formatted in miles and feet. For example: with a 948.1 feet distance, the formatted distance string is 900 ft, with a 951.4 feet distance - 0.2 mi.

  • When format is DistanceFormat.MILES_AND_YARDS, the Distance will be formatted in miles and yards. For example: with a 844.2 yard distance, the formatted distance string is 800 yards, with a 845.3 yard distance - 0.5 mi. Returns a FormattedDistance object.