NearestPlace { @NonNull public String getString(@NonNull MLocation loc) { final Place place = cached(loc); if (place != null) { final double distance = Geo.distance(loc.latitude, loc.longitude, place.lat, place.lng); return String.format("%s (%s)", place, Convert.distance3(distance)); } else { return ""; } } NearestPlace(@NonNull Places places); @Nullable Place cached(@NonNull MLocation current); @NonNull String getString(@NonNull MLocation loc);  }
@Test public void getString() { NearestPlace nearestPlace = new NearestPlace(makePlaces()); Convert.metric = false; assertEquals("Kpow (2 mi)", nearestPlace.getString(shelton)); }