com.here.msdkui.common

## Class DistanceFormatterUtil

- java.lang.Object
- - com.here.msdkui.common.DistanceFormatterUtil

-     public final class DistanceFormatterUtil
      extends java.lang.Object

  A convenience class to convert distance in meters to a string representation.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `THOUSAND`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static java.lang.String` | `format(android.content.Context context, long distance, UnitSystem system)` Converts a given distance in meters to a string representation.
    `static java.lang.String` | `formatDistance(android.content.Context context, long distance, UnitSystem system)` Converts given distance in meters to a string representation rounded to specified unit system.
    `static java.lang.String` | `formatDistanceInImperialUkSystem(android.content.Context context, long distance)` Converts a given distance in meters to a string representation rounded to feet or miles.
    `static java.lang.String` | `formatDistanceInImperialUsSystem(android.content.Context context, long distance)` Converts a given distance in meters to a string representation rounded to yards or miles.
    `static java.lang.String` | `formatDistanceInMetricSystem(android.content.Context context, long distance)` Converts a given distance in meters to a string representation rounded to meters or kilometers.
    `static java.lang.String` | `formatInImperialUkSystem(android.content.Context context, long distance)` Converts given distance in meters to a string representation rounded to feet or miles.
    `static java.lang.String` | `formatInImperialUsSystem(android.content.Context context, long distance)` Converts given distance in meters to a string representation rounded to yards or miles.
    `static java.lang.String` | `formatInMetricSystem(android.content.Context context, long distance)` Converts given distance in meters to a string representation rounded to meters or kilometers.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### THOUSAND

          public static final int THOUSAND

      See Also:
        Constant Field Values

  - ### Method Detail

    - #### format

          public static java.lang.String format(android.content.Context context,
                                                long distance,
                                                UnitSystem system)

      Converts a given distance in meters to a string representation. The distance will be rounded based on the provided unit system. See: `formatInMetricSystem(Context, long)`, `formatInImperialUsSystem(Context, long)`, `formatInImperialUkSystem(Context, long)`.
      Parameters:
        `context` - the required context.
        `distance` - the distance in meters.
        `system` - the unit system `UnitSystem`.
      Returns:
        a string representation including unit.

    - #### formatInMetricSystem

          public static java.lang.String formatInMetricSystem(android.content.Context context,
                                                              long distance)

      Converts given distance in meters to a string representation rounded to meters or kilometers.
      Parameters:
        `context` - the required context.
        `distance` - the distance in meters.
      Returns:
        a string representation including unit.

    - #### formatInImperialUsSystem

          public static java.lang.String formatInImperialUsSystem(android.content.Context context,
                                                                  long distance)

      Converts given distance in meters to a string representation rounded to yards or miles.
      Parameters:
        `context` - the required context.
        `distance` - the distance in meters.
      Returns:
        a string representation including unit.

    - #### formatInImperialUkSystem

          public static java.lang.String formatInImperialUkSystem(android.content.Context context,
                                                                  long distance)

      Converts given distance in meters to a string representation rounded to feet or miles.
      Parameters:
        `context` - the required context.
        `distance` - the distance in meters.
      Returns:
        a string representation including unit.

    - #### formatDistance

          public static java.lang.String formatDistance(android.content.Context context,
                                                        long distance,
                                                        UnitSystem system)

      Converts given distance in meters to a string representation rounded to specified unit system. For details of unit system specific see: `formatDistanceInMetricSystem(Context, long)`, `formatDistanceInImperialUkSystem(Context, long)`, `formatDistanceInImperialUsSystem(Context, long)`.
      Parameters:
        `context` - the required context.
        `distance` - the distance in meters.
        `system` - the unit system `UnitSystem`.
      Returns:
        a string representation including unit.

    - #### formatDistanceInMetricSystem

          public static java.lang.String formatDistanceInMetricSystem(android.content.Context context,
                                                                      long distance)

      Converts a given distance in meters to a string representation rounded to meters or kilometers. Some examples:
      - If the given distance is greater than 10 km, then the returned value will be rounded to its nearest division of 1 km. For example, 10.37 km will be rounded to 10 km.
      - If the given distance is between 1 km and 10 km, then the returned value will be rounded to its nearest division of 100 m. For example, 9.37 km will be rounded to 9.30 km.
      - If the given distance is between 200 m and 1 km, then the returned value will be rounded to its nearest division of 50 m. For example, 340 m will be rounded to 300 m.
      - If the given distance is between 10 m and 200 m, then the returned value will be rounded to its nearest division of 10 m. For example, 165 m will be rounded to 170 m.
      - If the given distance is less than 10 m, then the returned value will be rounded to its nearest division of 1 m. For example, 1.3 m will be rounded to 1 m.
      Parameters:
        `context` - the required context.
        `distance` - the distance in meters.
      Returns:
        a string representation including unit.

    - #### formatDistanceInImperialUsSystem

          public static java.lang.String formatDistanceInImperialUsSystem(android.content.Context context,
                                                                          long distance)

      Converts a given distance in meters to a string representation rounded to yards or miles. Some examples:
      - If the given distance is greater than 10 miles, then the returned value will be rounded to its nearest division of 1 mile. For example, 10.37 miles will be rounded to 10 miles.
      - If the given distance is between 1 mile and 10 miles, then the returned value will be rounded to its nearest division of 0.1 mile. For example, 9.37 miles will be rounded to 9.30 miles.
      - If the given distance is between 350 yd and 1 mile, then the returned value will be rounded to its nearest division of 50 yd. For example, 540 yd will be rounded to 500 yd.
      - If the given distance is between 10 yd and 350 yd, then the returned value will be rounded to its nearest division of 10 yd. For example, 132 yd will be rounded to 130 yd.
      - If the given distance is less than 10 yd, then the returned value will be rounded to its nearest division of 1 yd. For example, 1.3 yd will be rounded to 1 yd.
      Parameters:
        `context` - the required context.
        `distance` - the distance in meters.
      Returns:
        a string representation including unit.

    - #### formatDistanceInImperialUkSystem

          public static java.lang.String formatDistanceInImperialUkSystem(android.content.Context context,
                                                                          long distance)

      Converts a given distance in meters to a string representation rounded to feet or miles. Some examples:
      - If the given distance is greater than 10 miles, then the returned value will be rounded to its nearest division of 1 mile. For example, 10.37 miles will be rounded to 10 miles.
      - If the given distance is between 1 mile and 10 miles, then the returned value will be rounded to its nearest division of 0.1 mile. For example, 9.37 miles will be rounded to 9.30 miles.
      - If the given distance is between 1050 ft and 1 mile, then the returned value will be rounded to its nearest division of 50 ft. For example, 1240 ft will be rounded to 1200 ft.
      - If the given distance is between 10 ft and 1050 ft, then the returned value will be rounded to its nearest division of 10 ft. For example, 132 ft will be rounded to 130 ft.
      - If the given distance is less than 10 ft, then the returned value will be rounded to its nearest division of 1 ft. For example, 1.3 ft will be rounded to 1 ft.
      Parameters:
        `context` - the required context.
        `distance` - the distance in meters.
      Returns:
        a string representation including unit.