aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/geopoint/GeopointFormatter.java
diff options
context:
space:
mode:
Diffstat (limited to 'main/src/cgeo/geocaching/geopoint/GeopointFormatter.java')
-rw-r--r--main/src/cgeo/geocaching/geopoint/GeopointFormatter.java27
1 files changed, 12 insertions, 15 deletions
diff --git a/main/src/cgeo/geocaching/geopoint/GeopointFormatter.java b/main/src/cgeo/geocaching/geopoint/GeopointFormatter.java
index c706e77..ba0a4d5 100644
--- a/main/src/cgeo/geocaching/geopoint/GeopointFormatter.java
+++ b/main/src/cgeo/geocaching/geopoint/GeopointFormatter.java
@@ -5,12 +5,11 @@ import java.util.Locale;
/**
* Formatting of Geopoint.
*/
-public class GeopointFormatter
-{
+public class GeopointFormatter {
/**
* Predefined formats.
*/
- public static enum Format {
+ public enum Format {
/** Example: "10,123456 -0,123456" */
LAT_LON_DECDEGREE,
@@ -54,20 +53,19 @@ public class GeopointFormatter
* one of the predefined formats
* @return the formatted coordinates
*/
- public static String format(final Format format, final Geopoint gp)
- {
+ public static String format(final Format format, final Geopoint gp) {
final double latSigned = gp.getLatitude();
final double lonSigned = gp.getLongitude();
switch (format) {
case LAT_LON_DECDEGREE:
- return String.format("%.6f %.6f", latSigned, lonSigned);
+ return String.format(Locale.getDefault(), "%.6f %.6f", latSigned, lonSigned);
case LAT_LON_DECDEGREE_COMMA:
return String.format((Locale) null, "%.6f,%.6f", latSigned, lonSigned);
case LAT_LON_DECMINUTE:
- return String.format("%c %02d° %06.3f · %c %03d° %06.3f",
+ return String.format(Locale.getDefault(), "%c %02d° %06.3f · %c %03d° %06.3f",
gp.getLatDir(), gp.getLatDeg(), gp.getLatMinRaw(), gp.getLonDir(), gp.getLonDeg(), gp.getLonMinRaw());
case LAT_LON_DECMINUTE_RAW:
@@ -75,7 +73,7 @@ public class GeopointFormatter
gp.getLatDir(), gp.getLatDeg(), gp.getLatMinRaw(), gp.getLonDir(), gp.getLonDeg(), gp.getLonMinRaw());
case LAT_LON_DECSECOND:
- return String.format("%c %02d° %02d' %06.3f\" · %c %03d° %02d' %06.3f\"",
+ return String.format(Locale.getDefault(), "%c %02d° %02d' %06.3f\" · %c %03d° %02d' %06.3f\"",
gp.getLatDir(), gp.getLatDeg(), gp.getLatMin(), gp.getLatSecRaw(),
gp.getLonDir(), gp.getLonDeg(), gp.getLonMin(), gp.getLonSecRaw());
@@ -83,23 +81,22 @@ public class GeopointFormatter
return String.format((Locale) null, "%.6f", latSigned);
case LAT_DECMINUTE:
- return String.format("%c %02d° %06.3f", gp.getLatDir(), gp.getLatDeg(), gp.getLatMinRaw());
+ return String.format(Locale.getDefault(), "%c %02d° %06.3f", gp.getLatDir(), gp.getLatDeg(), gp.getLatMinRaw());
case LAT_DECMINUTE_RAW:
- return String.format("%c %02d %06.3f", gp.getLatDir(), gp.getLatDeg(), gp.getLatMinRaw());
+ return String.format(Locale.getDefault(), "%c %02d %06.3f", gp.getLatDir(), gp.getLatDeg(), gp.getLatMinRaw());
case LON_DECDEGREE_RAW:
return String.format((Locale) null, "%.6f", lonSigned);
case LON_DECMINUTE:
- return String.format("%c %03d° %06.3f", gp.getLonDir(), gp.getLonDeg(), gp.getLonMinRaw());
+ return String.format(Locale.getDefault(), "%c %03d° %06.3f", gp.getLonDir(), gp.getLonDeg(), gp.getLonMinRaw());
case LON_DECMINUTE_RAW:
- return String.format("%c %03d %06.3f", gp.getLonDir(), gp.getLonDeg(), gp.getLonMinRaw());
+ return String.format(Locale.getDefault(), "%c %03d %06.3f", gp.getLonDir(), gp.getLonDeg(), gp.getLonMinRaw());
+ default:
+ throw new IllegalArgumentException();
}
-
- // Keep the compiler happy even though it cannot happen
- return null;
}
}