Convert { @NonNull public static String altitude(double m) { if (Double.isNaN(m)) { return ""; } else if (Double.isInfinite(m)) { return Double.toString(m); } else { final String localUnits = metric ? "m" : "ft"; final double localValue = metric ? m : m * 3.2808399; if (localValue < 999.5) { return Math.round(localValue) + " " + localUnits; } else { return String.format(Locale.getDefault(), "%.1f k%s", localValue * 0.001, localUnits); } } }  static double kts2mps(double knots); @NonNull static String altitude(double m); @NonNull static String distance(double m); @NonNull static String distance(double m, int precision, boolean units); @NonNull static String distance2(double m, int precision); @NonNull static String distance3(double m); @NonNull static String speed(double mps); @NonNull static String speed(double mps, int precision, boolean units); @NonNull static String glide(double glideRatio, int precision, boolean units); @NonNull static String glide(double groundSpeed, double climb, int precision, boolean units); @NonNull static String glide2(double groundSpeed, double climb, int precision, boolean units); @NonNull static String pressure(double hPa); @NonNull static String angle(double degrees); @NonNull static String angle2(double degrees); @NonNull static String bearing2(double degrees); static boolean metric; static final double FT; static final double MPH; static final double KPH; static final float MPHf; static final float KPHf; static final String GLIDE_STATIONARY; static final String GLIDE_LEVEL; static final String GLIDE_VERTICAL; }
@Test public void convertAltitude() { Convert.metric = false; assertEquals("0 ft", Convert.altitude(0.0)); assertEquals("3.3 kft", Convert.altitude(1000.0)); assertEquals("", Convert.altitude(Double.NaN)); assertEquals("Infinity", Convert.altitude(Double.POSITIVE_INFINITY)); }