aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBananeweizen <bananeweizen@gmx.de>2012-07-01 11:29:44 +0200
committerBananeweizen <bananeweizen@gmx.de>2012-07-01 11:29:44 +0200
commit13033f965e55d7abb6c0807c1853652fa51627ff (patch)
tree59fc08aa2bfa31c20ab89fa9cc21af101c5835ea
parent2b744ff80e20203f8d4e3e4a6891f799a500e8ac (diff)
downloadcgeo-13033f965e55d7abb6c0807c1853652fa51627ff.zip
cgeo-13033f965e55d7abb6c0807c1853652fa51627ff.tar.gz
cgeo-13033f965e55d7abb6c0807c1853652fa51627ff.tar.bz2
fix #1828: Coords conversion to DMS not working correct
-rw-r--r--main/src/cgeo/geocaching/geopoint/Geopoint.java2
-rw-r--r--main/src/cgeo/geocaching/geopoint/GeopointFormatter.java2
-rw-r--r--tests/src/cgeo/geocaching/geopoint/GeoPointFormatterTest.java20
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);
+ }
+
+}