aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--main/src/cgeo/geocaching/IBasicCache.java2
-rw-r--r--main/src/cgeo/geocaching/ICache.java10
-rw-r--r--main/src/cgeo/geocaching/ICoordinates.java9
-rw-r--r--main/src/cgeo/geocaching/IWaypoint.java5
-rw-r--r--main/src/cgeo/geocaching/cgCache.java11
-rw-r--r--main/src/cgeo/geocaching/geopoint/Geopoint.java11
-rw-r--r--tests/src/cgeo/geocaching/cgBaseTest.java3
-rw-r--r--tests/src/cgeo/geocaching/files/GPXParserTest.java4
-rw-r--r--tests/src/cgeo/geocaching/test/mock/MockedCache.java11
9 files changed, 21 insertions, 45 deletions
diff --git a/main/src/cgeo/geocaching/IBasicCache.java b/main/src/cgeo/geocaching/IBasicCache.java
index 5e67b2d..195572b 100644
--- a/main/src/cgeo/geocaching/IBasicCache.java
+++ b/main/src/cgeo/geocaching/IBasicCache.java
@@ -11,7 +11,7 @@ import cgeo.geocaching.enumerations.CacheType;
* @author blafoo
*
*/
-public interface IBasicCache extends ILogable {
+public interface IBasicCache extends ILogable, ICoordinates {
public abstract String getGuid();
diff --git a/main/src/cgeo/geocaching/ICache.java b/main/src/cgeo/geocaching/ICache.java
index b6a809f..dccdb85 100644
--- a/main/src/cgeo/geocaching/ICache.java
+++ b/main/src/cgeo/geocaching/ICache.java
@@ -28,16 +28,6 @@ public interface ICache extends IBasicCache {
public String getOwnerReal();
/**
- * @return Latitude, e.g. N 52° 12.345
- */
- public String getLatitude();
-
- /**
- * @return Longitude, e.g. E 9° 34.567
- */
- public String getLongitude();
-
- /**
* @return true if the user is the owner of the cache, false else
*/
public boolean isOwn();
diff --git a/main/src/cgeo/geocaching/ICoordinates.java b/main/src/cgeo/geocaching/ICoordinates.java
new file mode 100644
index 0000000..b70e4ac
--- /dev/null
+++ b/main/src/cgeo/geocaching/ICoordinates.java
@@ -0,0 +1,9 @@
+package cgeo.geocaching;
+
+import cgeo.geocaching.geopoint.Geopoint;
+
+public interface ICoordinates {
+
+ public abstract Geopoint getCoords();
+
+}
diff --git a/main/src/cgeo/geocaching/IWaypoint.java b/main/src/cgeo/geocaching/IWaypoint.java
index 3e26052..ad12d48 100644
--- a/main/src/cgeo/geocaching/IWaypoint.java
+++ b/main/src/cgeo/geocaching/IWaypoint.java
@@ -4,18 +4,15 @@
package cgeo.geocaching;
import cgeo.geocaching.enumerations.WaypointType;
-import cgeo.geocaching.geopoint.Geopoint;
/**
* @author blafoo
*
*/
-public interface IWaypoint extends ILogable {
+public interface IWaypoint extends ILogable, ICoordinates {
public abstract int getId();
- public abstract Geopoint getCoords();
-
public abstract WaypointType getWaypointType();
public abstract String getCoordType();
diff --git a/main/src/cgeo/geocaching/cgCache.java b/main/src/cgeo/geocaching/cgCache.java
index 15f430c..5a14155 100644
--- a/main/src/cgeo/geocaching/cgCache.java
+++ b/main/src/cgeo/geocaching/cgCache.java
@@ -13,7 +13,6 @@ import cgeo.geocaching.enumerations.LoadFlags.RemoveFlag;
import cgeo.geocaching.enumerations.LogType;
import cgeo.geocaching.enumerations.WaypointType;
import cgeo.geocaching.geopoint.Geopoint;
-import cgeo.geocaching.geopoint.GeopointFormatter;
import cgeo.geocaching.geopoint.GeopointParser;
import cgeo.geocaching.utils.CancellableHandler;
import cgeo.geocaching.utils.Log;
@@ -523,16 +522,6 @@ public class cgCache implements ICache, IWaypoint {
}
@Override
- public String getLatitude() {
- return coords != null ? coords.format(GeopointFormatter.Format.LAT_DECMINUTE) : null;
- }
-
- @Override
- public String getLongitude() {
- return coords != null ? coords.format(GeopointFormatter.Format.LON_DECMINUTE) : null;
- }
-
- @Override
public String getOwner() {
return owner;
}
diff --git a/main/src/cgeo/geocaching/geopoint/Geopoint.java b/main/src/cgeo/geocaching/geopoint/Geopoint.java
index ef08401..31079bc 100644
--- a/main/src/cgeo/geocaching/geopoint/Geopoint.java
+++ b/main/src/cgeo/geocaching/geopoint/Geopoint.java
@@ -1,5 +1,6 @@
package cgeo.geocaching.geopoint;
+import cgeo.geocaching.ICoordinates;
import cgeo.geocaching.Settings;
import cgeo.geocaching.geopoint.GeopointFormatter.Format;
import cgeo.geocaching.network.Network;
@@ -18,8 +19,7 @@ import java.math.RoundingMode;
/**
* Abstraction of geographic point.
*/
-public final class Geopoint
-{
+public final class Geopoint implements ICoordinates {
public static final double deg2rad = Math.PI / 180;
public static final double rad2deg = 180 / Math.PI;
public static final float erad = 6371.0f;
@@ -242,7 +242,7 @@ public final class Geopoint
/**
* Returns formatted coordinates with default format.
* Default format is decimalminutes, e.g. N 52° 36.123 E 010° 03.456
- *
+ *
* @return formatted coordinates
*/
@Override
@@ -512,4 +512,9 @@ public final class Geopoint
return null;
}
+ @Override
+ public Geopoint getCoords() {
+ return this;
+ }
+
}
diff --git a/tests/src/cgeo/geocaching/cgBaseTest.java b/tests/src/cgeo/geocaching/cgBaseTest.java
index d0a7b98..eedaa83 100644
--- a/tests/src/cgeo/geocaching/cgBaseTest.java
+++ b/tests/src/cgeo/geocaching/cgBaseTest.java
@@ -57,8 +57,7 @@ public class cgBaseTest extends AbstractResourceInstrumentationTestCase {
assertEquals(expected.isPremiumMembersOnly(), actual.isPremiumMembersOnly());
if (all) {
- assertEquals(expected.getLatitude(), actual.getLatitude());
- assertEquals(expected.getLongitude(), actual.getLongitude());
+ assertEquals(expected.getCoords(), actual.getCoords());
assertTrue(actual.isReliableLatLon());
assertEquals(expected.isOwn(), actual.isOwn());
assertEquals(expected.getOwnerReal(), actual.getOwnerReal());
diff --git a/tests/src/cgeo/geocaching/files/GPXParserTest.java b/tests/src/cgeo/geocaching/files/GPXParserTest.java
index 3754af1..3ca8460 100644
--- a/tests/src/cgeo/geocaching/files/GPXParserTest.java
+++ b/tests/src/cgeo/geocaching/files/GPXParserTest.java
@@ -7,7 +7,6 @@ import cgeo.geocaching.enumerations.CacheSize;
import cgeo.geocaching.enumerations.CacheType;
import cgeo.geocaching.enumerations.WaypointType;
import cgeo.geocaching.geopoint.Geopoint;
-import cgeo.geocaching.geopoint.GeopointFormatter;
import cgeo.geocaching.test.AbstractResourceInstrumentationTestCase;
import cgeo.geocaching.test.R;
@@ -117,8 +116,7 @@ public class GPXParserTest extends AbstractResourceInstrumentationTestCase {
assertEquals(2.0f, cache.getDifficulty(), 0.01f);
assertEquals(1.0f, cache.getTerrain(), 0.01f);
final Geopoint refCoordinates = new Geopoint("N 49° 19.122", "E 008° 32.739");
- assertEquals(refCoordinates.format(GeopointFormatter.Format.LAT_DECMINUTE), cache.getLatitude());
- assertEquals(refCoordinates.format(GeopointFormatter.Format.LON_DECMINUTE), cache.getLongitude());
+ assertEquals(refCoordinates, cache.getCoords());
assertEquals("vptsz", cache.getOwner());
assertEquals(CacheSize.SMALL, cache.getSize());
assertEquals(CacheType.MULTI, cache.getType());
diff --git a/tests/src/cgeo/geocaching/test/mock/MockedCache.java b/tests/src/cgeo/geocaching/test/mock/MockedCache.java
index 61369ee..2c717a4 100644
--- a/tests/src/cgeo/geocaching/test/mock/MockedCache.java
+++ b/tests/src/cgeo/geocaching/test/mock/MockedCache.java
@@ -5,7 +5,6 @@ import cgeo.geocaching.cgImage;
import cgeo.geocaching.cgTrackable;
import cgeo.geocaching.connector.gc.GCConstants;
import cgeo.geocaching.geopoint.Geopoint;
-import cgeo.geocaching.geopoint.GeopointFormatter;
import cgeo.geocaching.utils.BaseUtils;
import org.apache.commons.lang3.StringUtils;
@@ -75,16 +74,6 @@ public abstract class MockedCache implements ICache {
}
@Override
- public String getLatitude() {
- return coords.format(GeopointFormatter.Format.LAT_DECMINUTE);
- }
-
- @Override
- public String getLongitude() {
- return coords.format(GeopointFormatter.Format.LON_DECMINUTE);
- }
-
- @Override
public boolean isArchived() {
return false;
}