aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBananeweizen <bananeweizen@gmx.de>2013-10-12 09:42:03 +0200
committerBananeweizen <bananeweizen@gmx.de>2013-10-12 09:42:03 +0200
commit51aae851f35e4bbd04cbfc898b906a27ff54c83f (patch)
tree4833ef27288214bbc20937276d98b22c045377f3
parent986fce52206eebf856f0fe9911b15aaec5c769ac (diff)
downloadcgeo-51aae851f35e4bbd04cbfc898b906a27ff54c83f.zip
cgeo-51aae851f35e4bbd04cbfc898b906a27ff54c83f.tar.gz
cgeo-51aae851f35e4bbd04cbfc898b906a27ff54c83f.tar.bz2
fix #3321: No distance calculation and coords if cache is at equator
-rw-r--r--main/src/cgeo/geocaching/geopoint/GeopointParser.java6
-rw-r--r--tests/src/cgeo/geocaching/geopoint/GeoPointParserTest.java15
2 files changed, 18 insertions, 3 deletions
diff --git a/main/src/cgeo/geocaching/geopoint/GeopointParser.java b/main/src/cgeo/geocaching/geopoint/GeopointParser.java
index ba86e70..136664c 100644
--- a/main/src/cgeo/geocaching/geopoint/GeopointParser.java
+++ b/main/src/cgeo/geocaching/geopoint/GeopointParser.java
@@ -25,8 +25,8 @@ class GeopointParser {
}
// ( 1 ) ( 2 ) ( 3 ) ( 4 ) ( 5 )
- private static final Pattern PATTERN_LAT = Pattern.compile("\\b([NS])\\s*(\\d+)°?(?:\\s*(\\d+)(?:[.,](\\d+)|'?\\s*(\\d+(?:[.,]\\d+)?)(?:''|\")?)?)?", Pattern.CASE_INSENSITIVE);
- private static final Pattern PATTERN_LON = Pattern.compile("\\b([WE])\\s*(\\d+)°?(?:\\s*(\\d+)(?:[.,](\\d+)|'?\\s*(\\d+(?:[.,]\\d+)?)(?:''|\")?)?)?", Pattern.CASE_INSENSITIVE);
+ private static final Pattern PATTERN_LAT = Pattern.compile("\\b([NS]|)\\s*(\\d+)°?(?:\\s*(\\d+)(?:[.,](\\d+)|'?\\s*(\\d+(?:[.,]\\d+)?)(?:''|\")?)?)?", Pattern.CASE_INSENSITIVE);
+ private static final Pattern PATTERN_LON = Pattern.compile("\\b([WE]|)\\s*(\\d+)°?(?:\\s*(\\d+)(?:[.,](\\d+)|'?\\s*(\\d+(?:[.,]\\d+)?)(?:''|\")?)?)?", Pattern.CASE_INSENSITIVE);
private static final Pattern PATTERN_BAD_BLANK = Pattern.compile("(\\d)[,.] (\\d{2,})");
@@ -131,7 +131,7 @@ class GeopointParser {
}
- // Nothing found with "N 52...", try to match string as decimaldegree
+ // Nothing found with "N 52...", try to match string as decimal degree
try {
final String[] items = StringUtils.split(text.trim());
if (items.length > 0) {
diff --git a/tests/src/cgeo/geocaching/geopoint/GeoPointParserTest.java b/tests/src/cgeo/geocaching/geopoint/GeoPointParserTest.java
index 076f2c9..1de2e26 100644
--- a/tests/src/cgeo/geocaching/geopoint/GeoPointParserTest.java
+++ b/tests/src/cgeo/geocaching/geopoint/GeoPointParserTest.java
@@ -93,4 +93,19 @@ public class GeoPointParserTest extends AndroidTestCase {
assertEquals(refLatitude, GeopointParser.parseLatitude("N 49° 56, 031"), 1e-8);
}
+ public static void testNonTrimmed() {
+ assertEquals(refLatitude, GeopointParser.parseLatitude(" N 49° 56, 031 "), 1e-8);
+ }
+
+ public static void testEquatorGC53() {
+ assertEquals(new Geopoint(0, 36), GeopointParser.parse("00° 00.000 E 036° 00.000"));
+ }
+
+ public static void testMeridian() {
+ assertEquals(new Geopoint(123, 0), GeopointParser.parse("N 123° 00.000 00° 00.000"));
+ }
+
+ public static void testEquatorMeridian() {
+ assertEquals(new Geopoint(0, 0), GeopointParser.parse("00° 00.000 00° 00.000"));
+ }
}