diff --git a/LocationLib/bin/locationlib.jar b/LocationLib/bin/locationlib.jar index c556d82..411510a 100644 Binary files a/LocationLib/bin/locationlib.jar and b/LocationLib/bin/locationlib.jar differ diff --git a/LocationLib/src/com/TwentyCodes/android/location/GeoUtils.java b/LocationLib/src/com/TwentyCodes/android/location/GeoUtils.java index 380fe7b..3388d74 100644 --- a/LocationLib/src/com/TwentyCodes/android/location/GeoUtils.java +++ b/LocationLib/src/com/TwentyCodes/android/location/GeoUtils.java @@ -20,6 +20,7 @@ */ package com.TwentyCodes.android.location; +import java.text.DecimalFormat; import java.util.ArrayList; import java.util.List; @@ -151,6 +152,32 @@ public class GeoUtils { return Math.acos(Math.sin(lat1Rad) * Math.sin(lat2Rad) + Math.cos(lat1Rad) * Math.cos(lat2Rad) * Math.cos(deltaLonRad)) * EARTH_RADIUS_KM; } + /** + * Converts distance into a human readbale string + * @param distance in kilometers + * @param returnMetric true if metric, false for US + * @return string distance + * @author ricky barrette + */ + public static String distanceToString(double distance, boolean returnMetric) { + DecimalFormat threeDForm = new DecimalFormat("#.###"); + DecimalFormat twoDForm = new DecimalFormat("#.##"); + + if (returnMetric) { + if (distance < 1) { + distance = distance * 1000; + return twoDForm.format(distance) + " m"; + } + return threeDForm.format(distance) + " Km"; + } + distance = distance / 1.609344; + if (distance < 1) { + distance = distance * 5280; + return twoDForm.format(distance) + " ft"; + } + return twoDForm.format(distance) + " mi"; + } + /** * a convince method for testing if 2 circles on the the surface of the earth intersect. * we will use this method to test if the users accuracy circle intersects a marked locaton's radius