aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--main/src/cgeo/geocaching/cgData.java10
-rw-r--r--main/src/cgeo/geocaching/cgeocoords.java15
-rw-r--r--main/src/cgeo/geocaching/geopoint/Geopoint.java32
-rw-r--r--tests/src/cgeo/geocaching/geopoint/GeopointTest.java25
4 files changed, 5 insertions, 77 deletions
diff --git a/main/src/cgeo/geocaching/cgData.java b/main/src/cgeo/geocaching/cgData.java
index ba95ad4..37b20ad 100644
--- a/main/src/cgeo/geocaching/cgData.java
+++ b/main/src/cgeo/geocaching/cgData.java
@@ -5,7 +5,6 @@ import cgeo.geocaching.enumerations.CacheType;
import cgeo.geocaching.enumerations.WaypointType;
import cgeo.geocaching.files.LocalStorage;
import cgeo.geocaching.geopoint.Geopoint;
-import cgeo.geocaching.geopoint.Geopoint.MalformedCoordinateException;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
@@ -1465,14 +1464,7 @@ public class cgData {
return null;
}
- try {
- return new Geopoint(cursor.getDouble(indexLat), cursor.getDouble(indexLon));
- } catch (MalformedCoordinateException e) {
- // TODO: check whether the exception should be returned to the caller instead,
- // as it might want to remove an invalid geopoint from the database.
- Log.e(Settings.tag, "cannot parse geopoint from database: " + e.getMessage());
- return null;
- }
+ return new Geopoint(cursor.getDouble(indexLat), cursor.getDouble(indexLon));
}
/**
diff --git a/main/src/cgeo/geocaching/cgeocoords.java b/main/src/cgeo/geocaching/cgeocoords.java
index aafe9ec..533dc23 100644
--- a/main/src/cgeo/geocaching/cgeocoords.java
+++ b/main/src/cgeo/geocaching/cgeocoords.java
@@ -3,7 +3,6 @@ package cgeo.geocaching;
import cgeo.geocaching.Settings.coordInputFormatEnum;
import cgeo.geocaching.activity.AbstractActivity;
import cgeo.geocaching.geopoint.Geopoint;
-import cgeo.geocaching.geopoint.Geopoint.MalformedCoordinateException;
import cgeo.geocaching.geopoint.GeopointFormatter;
import cgeo.geocaching.geopoint.GeopointParser.ParseException;
@@ -358,11 +357,6 @@ public class cgeocoords extends Dialog {
context.showToast(context.getResources().getString(R.string.err_parse_lat_lon));
}
return false;
- } catch (MalformedCoordinateException e) {
- if (signalError) {
- context.showToast(context.getResources().getString(R.string.err_invalid_lat_lon));
- }
- return false;
}
return true;
}
@@ -411,14 +405,7 @@ public class cgeocoords extends Dialog {
latitude *= (bLat.getText().toString().equalsIgnoreCase("S") ? -1 : 1);
longitude *= (bLon.getText().toString().equalsIgnoreCase("W") ? -1 : 1);
- try {
- gp = new Geopoint(latitude, longitude);
- } catch (MalformedCoordinateException e) {
- if (signalError) {
- context.showToast(context.getResources().getString(R.string.err_invalid_lat_lon));
- }
- return false;
- }
+ gp = new Geopoint(latitude, longitude);
return true;
}
diff --git a/main/src/cgeo/geocaching/geopoint/Geopoint.java b/main/src/cgeo/geocaching/geopoint/Geopoint.java
index 6b00331..fc85f88 100644
--- a/main/src/cgeo/geocaching/geopoint/Geopoint.java
+++ b/main/src/cgeo/geocaching/geopoint/Geopoint.java
@@ -21,22 +21,11 @@ public final class Geopoint
* latitude
* @param lon
* longitude
- * @throws MalformedCoordinateException
- * if any coordinate is incorrect
*/
public Geopoint(final double lat, final double lon)
{
- if (lat <= 90 && lat >= -90) {
- latitude = lat;
- } else {
- throw new MalformedCoordinateException("malformed latitude: " + lat);
- }
- if (lon <= 180 && lon >= -180) {
- // Prefer 180 degrees rather than the equivalent -180.
- longitude = lon == -180 ? 180 : lon;
- } else {
- throw new MalformedCoordinateException("malformed longitude: " + lon);
- }
+ latitude = lat;
+ longitude = lon;
}
/**
@@ -46,8 +35,6 @@ public final class Geopoint
* latitude
* @param lon
* longitude
- * @throws MalformedCoordinateException
- * if any coordinate is incorrect
*/
public Geopoint(final int lat, final int lon)
{
@@ -61,8 +48,6 @@ public final class Geopoint
* string to parse
* @throws GeopointParser.ParseException
* if the string cannot be parsed
- * @throws MalformedCoordinateException
- * if any coordinate is incorrect
* @see GeopointParser.parse()
*/
public Geopoint(final String text) {
@@ -78,8 +63,6 @@ public final class Geopoint
* longitude string to parse
* @throws GeopointParser.ParseException
* if any argument string cannot be parsed
- * @throws MalformedCoordinateException
- * if any coordinate is incorrect
* @see GeopointParser.parse()
*/
public Geopoint(final String latText, final String lonText) {
@@ -259,15 +242,4 @@ public final class Geopoint
super(msg);
}
}
-
- public static class MalformedCoordinateException
- extends GeopointException
- {
- private static final long serialVersionUID = 1L;
-
- public MalformedCoordinateException(String msg)
- {
- super(msg);
- }
- }
}
diff --git a/tests/src/cgeo/geocaching/geopoint/GeopointTest.java b/tests/src/cgeo/geocaching/geopoint/GeopointTest.java
index 068b8cc..e67bc99 100644
--- a/tests/src/cgeo/geocaching/geopoint/GeopointTest.java
+++ b/tests/src/cgeo/geocaching/geopoint/GeopointTest.java
@@ -1,8 +1,5 @@
package cgeo.geocaching.geopoint;
-import cgeo.geocaching.geopoint.Geopoint;
-import cgeo.geocaching.geopoint.Geopoint.GeopointException;
-
import android.test.AndroidTestCase;
import junit.framework.Assert;
@@ -16,7 +13,7 @@ public class GeopointTest extends AndroidTestCase {
}
public static void testCreationAtLimit() {
- // No exception should be raised at limits.
+ // No exception should be raised.
final Geopoint gp1 = new Geopoint(90.0, 10.0);
Assert.assertEquals(90, gp1.getLatitude(), 1e-8);
@@ -25,26 +22,6 @@ public class GeopointTest extends AndroidTestCase {
final Geopoint gp3 = new Geopoint(10.0, 180.0);
Assert.assertEquals(180, gp3.getLongitude(), 1e-8);
-
- // 180 should be preferred to -180
- final Geopoint gp4 = new Geopoint(10.0, -180.0);
- Assert.assertEquals(180, gp4.getLongitude(), 1e-8);
- }
-
- private static void createShouldFail(final double lat, final double lon) {
- try {
- final Geopoint gp = new Geopoint(lat, lon);
- Assert.fail("creation should fail: " + gp);
- } catch (GeopointException e) {
- // Success
- }
- }
-
- public static void testCreationFails() {
- createShouldFail(90.1, 0.0);
- createShouldFail(-90.1, 0.0);
- createShouldFail(0.0, 180.1);
- createShouldFail(0.0, -180.1);
}
public static void testEqual() {