diff options
Diffstat (limited to 'src/net/cbaines/suma/Util.java')
-rw-r--r-- | src/net/cbaines/suma/Util.java | 108 |
1 files changed, 54 insertions, 54 deletions
diff --git a/src/net/cbaines/suma/Util.java b/src/net/cbaines/suma/Util.java index 420d848..89a9e07 100644 --- a/src/net/cbaines/suma/Util.java +++ b/src/net/cbaines/suma/Util.java @@ -21,7 +21,6 @@ package net.cbaines.suma; import java.util.ArrayList; - import org.osmdroid.util.GeoPoint; import android.location.Location; @@ -29,68 +28,69 @@ import android.util.Log; public class Util { - private static final String TAG = "Util"; - - public static GeoPoint csLatLongToGeoPoint(String lat, String lng) { - try { - double dLat = Double.valueOf(lat).doubleValue(); - double dLng = Double.valueOf(lng).doubleValue(); - int iLat = (int) (dLat * 1e6); - int iLng = (int) (dLng * 1e6); - return new GeoPoint(iLat, iLng); - } catch (NumberFormatException e) { - Log.e(TAG, "Error formating " + lat + " " + lng, e); - throw e; + private static final String TAG = "Util"; + + public static GeoPoint csLatLongToGeoPoint(String lat, String lng) { + try { + double dLat = Double.valueOf(lat).doubleValue(); + double dLng = Double.valueOf(lng).doubleValue(); + int iLat = (int) (dLat * 1e6); + int iLng = (int) (dLng * 1e6); + return new GeoPoint(iLat, iLng); + } catch (NumberFormatException e) { + Log.e(TAG, "Error formating " + lat + " " + lng, e); + throw e; + } } - } - - public static GeoPoint ssLatLongToGeoPoint(String lat, String lng) { - try { - - double dLat = Double.valueOf(lat).doubleValue(); - double dLng = Double.valueOf(lng).doubleValue(); - int iLat = (int) (dLat * 1e6); - int iLng = (int) (dLng * 1e6); - return new GeoPoint(iLat, iLng); - } catch (NumberFormatException e) { - Log.e(TAG, "Error formating " + lat + " " + lng, e); - throw e; + + public static GeoPoint ssLatLongToGeoPoint(String lat, String lng) { + try { + + double dLat = Double.valueOf(lat).doubleValue(); + double dLng = Double.valueOf(lng).doubleValue(); + int iLat = (int) (dLat * 1e6); + int iLng = (int) (dLng * 1e6); + return new GeoPoint(iLat, iLng); + } catch (NumberFormatException e) { + Log.e(TAG, "Error formating " + lat + " " + lng, e); + throw e; + } } - } - public static Polygon csPolygonToPolygon(String str) { - // Log.i(TAG, "Getting poly from " + str); - ArrayList<GeoPoint> geoPoints = new ArrayList<GeoPoint>(); + public static Polygon csPolygonToPolygon(String str) { + // Log.i(TAG, "Getting poly from " + str); + ArrayList<GeoPoint> geoPoints = new ArrayList<GeoPoint>(); - String[] latLongPoints = str.split(","); - for (int point = 0; point < latLongPoints.length; point++) { - // Log.i(TAG, "LatLong point " + point + " " + latLongPoints[point]); + String[] latLongPoints = str.split(","); + for (int point = 0; point < latLongPoints.length; point++) { + // Log.i(TAG, "LatLong point " + point + " " + + // latLongPoints[point]); - String[] latLongs = latLongPoints[point].split(" "); - GeoPoint geoPoint = ssLatLongToGeoPoint(latLongs[1], latLongs[0]); - geoPoints.add(geoPoint); - } + String[] latLongs = latLongPoints[point].split(" "); + GeoPoint geoPoint = ssLatLongToGeoPoint(latLongs[1], latLongs[0]); + geoPoints.add(geoPoint); + } - return new Polygon(geoPoints.toArray(new GeoPoint[0])); - } + return new Polygon(geoPoints.toArray(new GeoPoint[0])); + } - public static int doubleToIntE6(double dub) { - return (int) (dub * 1e6); - } + public static int doubleToIntE6(double dub) { + return (int) (dub * 1e6); + } - public static double E6IntToDouble(int integer) { - return (double) (integer / 1e6); - } + public static double E6IntToDouble(int integer) { + return (double) (integer / 1e6); + } - public static GeoPoint locationToGeoPoint(Location loc) { - return new GeoPoint(doubleToIntE6(loc.getLatitude()), doubleToIntE6(loc.getLongitude())); - } + public static GeoPoint locationToGeoPoint(Location loc) { + return new GeoPoint(doubleToIntE6(loc.getLatitude()), doubleToIntE6(loc.getLongitude())); + } - public static Location geoPointToLocation(GeoPoint point) { - Location loc = new Location(""); - loc.setLatitude(E6IntToDouble(point.getLatitudeE6())); - loc.setLongitude(E6IntToDouble(point.getLongitudeE6())); - return loc; - } + public static Location geoPointToLocation(GeoPoint point) { + Location loc = new Location(""); + loc.setLatitude(E6IntToDouble(point.getLatitudeE6())); + loc.setLongitude(E6IntToDouble(point.getLongitudeE6())); + return loc; + } } |