diff options
Diffstat (limited to 'main')
| -rw-r--r-- | main/src/cgeo/geocaching/Go4Cache.java | 6 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/StaticMapsProvider.java | 9 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/Twitter.java | 5 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/apps/cache/navi/RMapsApp.java | 14 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/cgBase.java | 4 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/cgeodetail.java | 4 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/cgeonavigate.java | 5 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/geopoint/GeopointFormatter.java | 10 |
8 files changed, 28 insertions, 29 deletions
diff --git a/main/src/cgeo/geocaching/Go4Cache.java b/main/src/cgeo/geocaching/Go4Cache.java index 639ea5c..d916e32 100644 --- a/main/src/cgeo/geocaching/Go4Cache.java +++ b/main/src/cgeo/geocaching/Go4Cache.java @@ -1,13 +1,13 @@ package cgeo.geocaching; import cgeo.geocaching.geopoint.Geopoint; +import cgeo.geocaching.geopoint.GeopointFormatter.Format; import cgeo.geocaching.utils.CryptUtils; import org.apache.commons.lang3.StringUtils; import android.util.Log; -import java.util.Locale; import java.util.concurrent.ArrayBlockingQueue; /** @@ -78,8 +78,8 @@ public class Go4Cache extends Thread { continue; } - final String latStr = String.format((Locale) null, "%.6f", currentCoords.getLatitude()); - final String lonStr = String.format((Locale) null, "%.6f", currentCoords.getLongitude()); + final String latStr = currentCoords.format(Format.LAT_DECDEGREE_RAW); + final String lonStr = currentCoords.format(Format.LON_DECDEGREE_RAW); final Parameters params = new Parameters( "u", username, "lt", latStr, diff --git a/main/src/cgeo/geocaching/StaticMapsProvider.java b/main/src/cgeo/geocaching/StaticMapsProvider.java index 2a5725e..34ebd3d 100644 --- a/main/src/cgeo/geocaching/StaticMapsProvider.java +++ b/main/src/cgeo/geocaching/StaticMapsProvider.java @@ -1,6 +1,7 @@ package cgeo.geocaching; import cgeo.geocaching.files.LocalStorage; +import cgeo.geocaching.geopoint.GeopointFormatter.Format; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; @@ -12,7 +13,6 @@ import android.view.Display; import android.view.WindowManager; import java.io.File; -import java.util.Locale; public class StaticMapsProvider { private static final String MARKERS_URL = "http://cgeo.carnero.cc/_markers/"; @@ -58,8 +58,7 @@ public class StaticMapsProvider { return; } - final String latlonMap = String.format((Locale) null, "%.6f", cache.getCoords().getLatitude()) + "," + - String.format((Locale) null, "%.6f", cache.getCoords().getLongitude()); + final String latlonMap = cache.getCoords().format(Format.LAT_LON_DECDEGREE_COMMA); final Display display = ((WindowManager) activity.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); final int maxWidth = display.getWidth() - 25; final int maxHeight = display.getHeight() - 25; @@ -82,9 +81,7 @@ public class StaticMapsProvider { waypoints.append("marker_waypoint_"); waypoints.append(waypoint.getWaypointType() != null ? waypoint.getWaypointType().id : null); waypoints.append(".png%7C"); - waypoints.append(String.format((Locale) null, "%.6f", waypoint.getCoords().getLatitude())); - waypoints.append(','); - waypoints.append(String.format((Locale) null, "%.6f", waypoint.getCoords().getLongitude())); + waypoints.append(waypoint.getCoords().format(Format.LAT_LON_DECDEGREE_COMMA)); } } diff --git a/main/src/cgeo/geocaching/Twitter.java b/main/src/cgeo/geocaching/Twitter.java index 28da23e..6d5ec29 100644 --- a/main/src/cgeo/geocaching/Twitter.java +++ b/main/src/cgeo/geocaching/Twitter.java @@ -1,6 +1,7 @@ package cgeo.geocaching; import cgeo.geocaching.geopoint.Geopoint; +import cgeo.geocaching.geopoint.GeopointFormatter.Format; import cgeo.geocaching.network.OAuth; import org.apache.http.HttpResponse; @@ -22,8 +23,8 @@ public final class Twitter { Parameters parameters = new Parameters("status", status); if (coords != null) { parameters.put( - "lat", String.format("%.6f", coords.getLatitude()), - "long", String.format("%.6f", coords.getLongitude()), + "lat", coords.format(Format.LAT_DECDEGREE_RAW), + "long", coords.format(Format.LON_DECDEGREE_RAW), "display_coordinates", "true"); } diff --git a/main/src/cgeo/geocaching/apps/cache/navi/RMapsApp.java b/main/src/cgeo/geocaching/apps/cache/navi/RMapsApp.java index cb0b520..bc88853 100644 --- a/main/src/cgeo/geocaching/apps/cache/navi/RMapsApp.java +++ b/main/src/cgeo/geocaching/apps/cache/navi/RMapsApp.java @@ -6,13 +6,13 @@ import cgeo.geocaching.cgGeo; import cgeo.geocaching.cgSearch; import cgeo.geocaching.cgWaypoint; import cgeo.geocaching.geopoint.Geopoint; +import cgeo.geocaching.geopoint.GeopointFormatter.Format; import android.app.Activity; import android.content.Intent; import android.content.res.Resources; import java.util.ArrayList; -import java.util.Locale; class RMapsApp extends AbstractNavigationApp { @@ -34,20 +34,12 @@ class RMapsApp extends AbstractNavigationApp { if (isInstalled(activity)) { final ArrayList<String> locations = new ArrayList<String>(); if (cache != null && cache.getCoords() != null) { - locations.add(String.format((Locale) null, "%.6f", - cache.getCoords().getLatitude()) - + "," - + String.format((Locale) null, "%.6f", - cache.getCoords().getLongitude()) + locations.add(cache.getCoords().format(Format.LAT_LON_DECDEGREE_COMMA) + ";" + cache.getGeocode() + ";" + cache.getName()); } else if (waypoint != null && waypoint.getCoords() != null) { - locations.add(String.format((Locale) null, "%.6f", - waypoint.getCoords().getLatitude()) - + "," - + String.format((Locale) null, "%.6f", - waypoint.getCoords().getLongitude()) + locations.add(waypoint.getCoords().format(Format.LAT_LON_DECDEGREE_COMMA) + ";" + waypoint.getLookup() + ";" + waypoint.getName()); diff --git a/main/src/cgeo/geocaching/cgBase.java b/main/src/cgeo/geocaching/cgBase.java index e40493b..4bd76ac 100644 --- a/main/src/cgeo/geocaching/cgBase.java +++ b/main/src/cgeo/geocaching/cgBase.java @@ -11,6 +11,7 @@ import cgeo.geocaching.enumerations.WaypointType; import cgeo.geocaching.files.LocParser; import cgeo.geocaching.geopoint.DistanceParser; import cgeo.geocaching.geopoint.Geopoint; +import cgeo.geocaching.geopoint.GeopointFormatter.Format; import cgeo.geocaching.network.HtmlImage; import cgeo.geocaching.utils.BaseUtils; import cgeo.geocaching.utils.CancellableHandler; @@ -3385,8 +3386,7 @@ public class cgBase { final String uri = "http://maps.googleapis.com/maps/api/elevation/json"; final Parameters params = new Parameters( "sensor", "false", - "locations", String.format((Locale) null, "%.6f", coords.getLatitude()) + "," + - String.format((Locale) null, "%.6f", coords.getLongitude())); + "locations", coords.format(Format.LAT_LON_DECDEGREE_COMMA)); final JSONObject response = requestJSON(uri, params); if (response == null) { diff --git a/main/src/cgeo/geocaching/cgeodetail.java b/main/src/cgeo/geocaching/cgeodetail.java index de7c735..40b1528 100644 --- a/main/src/cgeo/geocaching/cgeodetail.java +++ b/main/src/cgeo/geocaching/cgeodetail.java @@ -9,6 +9,7 @@ import cgeo.geocaching.connector.ConnectorFactory; import cgeo.geocaching.connector.IConnector; import cgeo.geocaching.enumerations.CacheType; import cgeo.geocaching.geopoint.GeopointFormatter; +import cgeo.geocaching.geopoint.GeopointFormatter.Format; import cgeo.geocaching.network.HtmlImage; import cgeo.geocaching.utils.CancellableHandler; import cgeo.geocaching.utils.CryptUtils; @@ -1415,8 +1416,7 @@ public class cgeodetail extends AbstractActivity { BitmapDrawable image = null; try { - final String latlonMap = String.format((Locale) null, "%.6f", cache.getCoords().getLatitude()) + "," + - String.format((Locale) null, "%.6f", cache.getCoords().getLongitude()); + final String latlonMap = cache.getCoords().format(Format.LAT_LON_DECDEGREE_COMMA); final Display display = ((WindowManager) getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); int width = display.getWidth(); diff --git a/main/src/cgeo/geocaching/cgeonavigate.java b/main/src/cgeo/geocaching/cgeonavigate.java index bc66961..2314136 100644 --- a/main/src/cgeo/geocaching/cgeonavigate.java +++ b/main/src/cgeo/geocaching/cgeonavigate.java @@ -3,6 +3,7 @@ package cgeo.geocaching; import cgeo.geocaching.activity.AbstractActivity; import cgeo.geocaching.geopoint.Geopoint; import cgeo.geocaching.geopoint.GeopointFormatter; +import cgeo.geocaching.geopoint.GeopointFormatter.Format; import cgeo.geocaching.maps.CGeoMap; import org.apache.commons.lang3.StringUtils; @@ -277,9 +278,7 @@ public class cgeonavigate extends AbstractActivity { setDestCoords(); updateDistanceInfo(); - Log.d(Settings.tag, "destination set: " + title + " (" + - String.format(Locale.getDefault(), "%.8f", dstCoords.getLatitude()) + " | " + - String.format(Locale.getDefault(), "%.8f", dstCoords.getLongitude()) + ")"); + Log.d(Settings.tag, "destination set: " + title + " (" + dstCoords.format(Format.LAT_LON_DECMINUTE_PIPE) + ")"); return true; } diff --git a/main/src/cgeo/geocaching/geopoint/GeopointFormatter.java b/main/src/cgeo/geocaching/geopoint/GeopointFormatter.java index 2c0dd3b..052dfb2 100644 --- a/main/src/cgeo/geocaching/geopoint/GeopointFormatter.java +++ b/main/src/cgeo/geocaching/geopoint/GeopointFormatter.java @@ -19,10 +19,14 @@ public class GeopointFormatter LAT_LON_DECMINUTE, /** Example: "W 5° 12,345 | N 10° 12,345" */ LAT_LON_DECMINUTE_PIPE, + /** Example: "-0.123456" (unlocalized latitude) */ + LAT_DECDEGREE_RAW, /** Example: "W 5° 12,345" */ LAT_DECMINUTE, /** Example: "W 5 12,345" */ LAT_DECMINUTE_RAW, + /** Example: "-0.123456" (unlocalized longitude) */ + LON_DECDEGREE_RAW, /** Example: "N 10° 12,345" */ LON_DECMINUTE, /** Example: "N 10 12,345" */ @@ -66,12 +70,18 @@ public class GeopointFormatter return String.format("%c %02.0f° %.3f | %c %03.0f° %.3f", latDir, latFloor, latMin, lonDir, lonFloor, lonMin); + case LAT_DECDEGREE_RAW: + return String.format((Locale) null, "%.6f", latSigned); + case LAT_DECMINUTE: return String.format("%c %02.0f° %.3f", latDir, latFloor, latMin); case LAT_DECMINUTE_RAW: return String.format("%c %02.0f %.3f", latDir, latFloor, latMin); + case LON_DECDEGREE_RAW: + return String.format((Locale) null, "%.6f", lonSigned); + case LON_DECMINUTE: return String.format("%c %03.0f° %.3f", lonDir, lonFloor, lonMin); |
