diff options
3 files changed, 22 insertions, 2 deletions
diff --git a/main/src/cgeo/geocaching/geopoint/Geopoint.java b/main/src/cgeo/geocaching/geopoint/Geopoint.java index 612b6ad..7d585ac 100644 --- a/main/src/cgeo/geocaching/geopoint/Geopoint.java +++ b/main/src/cgeo/geocaching/geopoint/Geopoint.java @@ -583,7 +583,7 @@ public final class Geopoint implements ICoordinates, Parcelable { } private static double getSecRaw(final double deg) { - return (Math.abs(deg) * 3600) % 3600; + return (Math.abs(deg) * 3600) % 60; } private static String addZeros(final int value, final int len) { diff --git a/main/src/cgeo/geocaching/geopoint/GeopointFormatter.java b/main/src/cgeo/geocaching/geopoint/GeopointFormatter.java index 0b3df05..c706e77 100644 --- a/main/src/cgeo/geocaching/geopoint/GeopointFormatter.java +++ b/main/src/cgeo/geocaching/geopoint/GeopointFormatter.java @@ -23,7 +23,7 @@ public class GeopointFormatter /** Example: "N 10° 12.345 W 5° 12.345" */ LAT_LON_DECMINUTE_RAW, - /** Example: "N 10° 12' 34" W 5° 12' 34"" */ + /** Example: "N 10° 12' 34" W 5° 12' 34" */ LAT_LON_DECSECOND, /** Example: "-0.123456" (unlocalized latitude) */ diff --git a/tests/src/cgeo/geocaching/geopoint/GeoPointFormatterTest.java b/tests/src/cgeo/geocaching/geopoint/GeoPointFormatterTest.java new file mode 100644 index 0000000..76c0f09 --- /dev/null +++ b/tests/src/cgeo/geocaching/geopoint/GeoPointFormatterTest.java @@ -0,0 +1,20 @@ +package cgeo.geocaching.geopoint; + +import cgeo.geocaching.ui.Formatter; + +import android.test.AndroidTestCase; + +public class GeoPointFormatterTest extends AndroidTestCase { + + public static void testFormat() { + // taken from GC30R6G + Geopoint point = new Geopoint("N 51° 21.104 E 010° 15.369"); + final String format = GeopointFormatter.format(GeopointFormatter.Format.LAT_LON_DECDEGREE_COMMA, point); + assertEquals(format, "51.351733,10.256150", format); + final String formatMinute = GeopointFormatter.format(GeopointFormatter.Format.LAT_LON_DECMINUTE_RAW, point); + assertEquals(formatMinute, "N 51° 21.104 E 010° 15.369", formatMinute); + final String formatSecond = GeopointFormatter.format(GeopointFormatter.Format.LAT_LON_DECSECOND, point).replaceAll(",", "."); + assertEquals(formatSecond, "N 51° 21' 06.240\"" + Formatter.SEPARATOR + "E 010° 15' 22.140\"", formatSecond); + } + +} |
