aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--main/src/cgeo/geocaching/cgCache.java2
-rw-r--r--main/src/cgeo/geocaching/geopoint/Geopoint.java29
-rw-r--r--tests/src/cgeo/geocaching/cgBaseTest.java2
-rw-r--r--tests/src/cgeo/geocaching/cgeoApplicationTest.java4
-rw-r--r--tests/src/cgeo/geocaching/files/GPXParserTest.java4
-rw-r--r--tests/src/cgeo/geocaching/files/LocParserTest.java4
-rw-r--r--tests/src/cgeo/geocaching/geopoint/GeoPointParserTest.java4
-rw-r--r--tests/src/cgeo/geocaching/geopoint/GeopointTest.java8
-rw-r--r--tests/src/cgeo/geocaching/test/mock/GC2JVEH.java2
9 files changed, 32 insertions, 27 deletions
diff --git a/main/src/cgeo/geocaching/cgCache.java b/main/src/cgeo/geocaching/cgCache.java
index 5a14155..36fd064 100644
--- a/main/src/cgeo/geocaching/cgCache.java
+++ b/main/src/cgeo/geocaching/cgCache.java
@@ -308,7 +308,7 @@ public class cgCache implements ICache, IWaypoint {
premiumMembersOnly == other.premiumMembersOnly &&
difficulty == other.difficulty &&
terrain == other.terrain &&
- (coords != null ? coords.isEqualTo(other.coords) : null == other.coords) &&
+ (coords != null ? coords.equals(other.coords) : null == other.coords) &&
reliableLatLon == other.reliableLatLon &&
disabled == other.disabled &&
archived == other.archived &&
diff --git a/main/src/cgeo/geocaching/geopoint/Geopoint.java b/main/src/cgeo/geocaching/geopoint/Geopoint.java
index 31079bc..93d9c87 100644
--- a/main/src/cgeo/geocaching/geopoint/Geopoint.java
+++ b/main/src/cgeo/geocaching/geopoint/Geopoint.java
@@ -114,7 +114,7 @@ public final class Geopoint implements ICoordinates {
*/
public int getLatitudeE6()
{
- return (int) (latitude * 1E6);
+ return (int) Math.round(latitude * 1E6);
}
/**
@@ -134,7 +134,7 @@ public final class Geopoint implements ICoordinates {
*/
public int getLongitudeE6()
{
- return (int) (longitude * 1E6);
+ return (int) Math.round(longitude * 1E6);
}
/**
@@ -200,16 +200,21 @@ public final class Geopoint implements ICoordinates {
return new Geopoint(rlat * rad2deg, rlon * rad2deg);
}
- /**
- * Checks if given Geopoint is identical with this Geopoint.
- *
- * @param gp
- * Geopoint to check
- * @return true if identical, false otherwise
- */
- public boolean isEqualTo(Geopoint gp)
- {
- return null != gp && gp.latitude == latitude && gp.longitude == longitude;
+ @Override
+ public boolean equals(final Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null || !(obj instanceof Geopoint)) {
+ return false;
+ }
+ final Geopoint gp = (Geopoint) obj;
+ return getLatitudeE6() == gp.getLatitudeE6() && getLongitudeE6() == gp.getLongitudeE6();
+ }
+
+ @Override
+ public int hashCode() {
+ return getLatitudeE6() ^ getLongitudeE6();
}
/**
diff --git a/tests/src/cgeo/geocaching/cgBaseTest.java b/tests/src/cgeo/geocaching/cgBaseTest.java
index eedaa83..42765f0 100644
--- a/tests/src/cgeo/geocaching/cgBaseTest.java
+++ b/tests/src/cgeo/geocaching/cgBaseTest.java
@@ -150,7 +150,7 @@ public class cgBaseTest extends AbstractResourceInstrumentationTestCase {
cache.parseWaypointsFromNote();
assertEquals(expected.length, cache.getWaypoints().size());
for (int i = 0; i < expected.length; i++) {
- assertTrue(expected[i].isEqualTo(cache.getWaypoint(i).getCoords()));
+ assertTrue(expected[i].equals(cache.getWaypoint(i).getCoords()));
}
}
diff --git a/tests/src/cgeo/geocaching/cgeoApplicationTest.java b/tests/src/cgeo/geocaching/cgeoApplicationTest.java
index c4ab0e3..356eac9 100644
--- a/tests/src/cgeo/geocaching/cgeoApplicationTest.java
+++ b/tests/src/cgeo/geocaching/cgeoApplicationTest.java
@@ -242,7 +242,7 @@ public class cgeoApplicationTest extends ApplicationTestCase<cgeoapplication> {
cgCache parsedCache = cgeoapplication.getInstance().loadCache(mockedCache.getGeocode(), LoadFlags.LOAD_CACHE_OR_DB);
- assertEquals(Settings.isPremiumMember(), mockedCache.getCoords().isEqualTo(parsedCache.getCoords()));
+ assertEquals(Settings.isPremiumMember(), mockedCache.getCoords().equals(parsedCache.getCoords()));
assertEquals(Settings.isPremiumMember(), parsedCache.isReliableLatLon());
// check update after switch strategy to FAST
@@ -253,7 +253,7 @@ public class cgeoApplicationTest extends ApplicationTestCase<cgeoapplication> {
parsedCache = cgeoapplication.getInstance().loadCache(mockedCache.getGeocode(), LoadFlags.LOAD_CACHE_OR_DB);
- assertEquals(Settings.isPremiumMember(), mockedCache.getCoords().isEqualTo(parsedCache.getCoords()));
+ assertEquals(Settings.isPremiumMember(), mockedCache.getCoords().equals(parsedCache.getCoords()));
assertEquals(Settings.isPremiumMember(), parsedCache.isReliableLatLon());
} finally {
diff --git a/tests/src/cgeo/geocaching/files/GPXParserTest.java b/tests/src/cgeo/geocaching/files/GPXParserTest.java
index 3ca8460..0b7f396 100644
--- a/tests/src/cgeo/geocaching/files/GPXParserTest.java
+++ b/tests/src/cgeo/geocaching/files/GPXParserTest.java
@@ -42,7 +42,7 @@ public class GPXParserTest extends AbstractResourceInstrumentationTestCase {
assertEquals(5.0f, cache.getTerrain());
assertEquals("Baden-Württemberg, Germany", cache.getLocation());
assertEquals("Ein alter Kindheitstraum, ein Schatz auf einer unbewohnten Insel.\nA old dream of my childhood, a treasure on a lonely island.", cache.getShortdesc());
- assertTrue(new Geopoint(48.859683, 9.1874).isEqualTo(cache.getCoords()));
+ assertTrue(new Geopoint(48.859683, 9.1874).equals(cache.getCoords()));
return cache;
}
@@ -66,7 +66,7 @@ public class GPXParserTest extends AbstractResourceInstrumentationTestCase {
assertEquals(4.0f, cache.getTerrain());
assertEquals("Baden-Württemberg, Germany", cache.getLocation());
assertEquals("Ein alter Kindheitstraum, ein Schatz auf einer unbewohnten Insel. A old dream of my childhood, a treasure on a lonely is", cache.getShortdesc());
- assertTrue(new Geopoint(48.85968, 9.18740).isEqualTo(cache.getCoords()));
+ assertTrue(new Geopoint(48.85968, 9.18740).equals(cache.getCoords()));
assertTrue(cache.isReliableLatLon());
}
diff --git a/tests/src/cgeo/geocaching/files/LocParserTest.java b/tests/src/cgeo/geocaching/files/LocParserTest.java
index 64ac7ad..ede0e81 100644
--- a/tests/src/cgeo/geocaching/files/LocParserTest.java
+++ b/tests/src/cgeo/geocaching/files/LocParserTest.java
@@ -37,7 +37,7 @@ public class LocParserTest extends AbstractResourceInstrumentationTestCase {
assertNotNull(cache);
assertEquals("OC5952", cache.getGeocode());
assertEquals("Die Schatzinsel / treasure island", cache.getName());
- assertTrue(new Geopoint(48.85968, 9.18740).isEqualTo(cache.getCoords()));
+ assertTrue(new Geopoint(48.85968, 9.18740).equals(cache.getCoords()));
}
public void testGCLoc() throws IOException, ParserException {
@@ -47,7 +47,7 @@ public class LocParserTest extends AbstractResourceInstrumentationTestCase {
assertNotNull(cache);
assertEquals("GC1BKP3", cache.getGeocode());
assertEquals("Die Schatzinsel / treasure island", cache.getName());
- assertTrue(new Geopoint(48.859683, 9.1874).isEqualTo(cache.getCoords()));
+ assertTrue(new Geopoint(48.859683, 9.1874).equals(cache.getCoords()));
assertEquals(1.0f, cache.getDifficulty());
assertEquals(5.0f, cache.getTerrain());
assertEquals(CacheSize.MICRO, cache.getSize());
diff --git a/tests/src/cgeo/geocaching/geopoint/GeoPointParserTest.java b/tests/src/cgeo/geocaching/geopoint/GeoPointParserTest.java
index 661623e..4e24e5a 100644
--- a/tests/src/cgeo/geocaching/geopoint/GeoPointParserTest.java
+++ b/tests/src/cgeo/geocaching/geopoint/GeoPointParserTest.java
@@ -57,7 +57,7 @@ public class GeoPointParserTest extends AndroidTestCase {
final Geopoint p2 = GeopointParser.parse("N51 21.523", "E07 02.680");
assertNotNull(p1);
assertNotNull(p2);
- assertTrue(p1.isEqualTo(p2));
+ assertTrue(p1.equals(p2));
}
public static void testUnrelatedParts() {
@@ -77,6 +77,6 @@ public class GeoPointParserTest extends AndroidTestCase {
"E 15° 53' 41.68''");
assertNotNull(pointComma);
assertNotNull(pointDot);
- assertTrue(pointComma.isEqualTo(pointDot));
+ assertTrue(pointComma.equals(pointDot));
}
}
diff --git a/tests/src/cgeo/geocaching/geopoint/GeopointTest.java b/tests/src/cgeo/geocaching/geopoint/GeopointTest.java
index 894b046..ba88992 100644
--- a/tests/src/cgeo/geocaching/geopoint/GeopointTest.java
+++ b/tests/src/cgeo/geocaching/geopoint/GeopointTest.java
@@ -77,7 +77,7 @@ public class GeopointTest extends AndroidTestCase {
Geopoint gp1a = DDD.createGeopoint(String.valueOf(ddd1.latDir), String.valueOf(ddd1.latDeg), String.valueOf(ddd1.latDegFrac),
String.valueOf(ddd1.lonDir), String.valueOf(ddd1.lonDeg), String.valueOf(ddd1.lonDegFrac));
- Assert.assertTrue(gp1a.isEqualTo(gp1));
+ Assert.assertTrue(gp1a.equals(gp1));
// case 2
final Geopoint gp2 = new Geopoint(51.34567d, 13.87654d);
@@ -88,7 +88,7 @@ public class GeopointTest extends AndroidTestCase {
Geopoint gp2a = DDD.createGeopoint(String.valueOf(ddd2.latDir), String.valueOf(ddd2.latDeg), String.valueOf(ddd2.latDegFrac),
String.valueOf(ddd2.lonDir), String.valueOf(ddd2.lonDeg), String.valueOf(ddd2.lonDegFrac));
- Assert.assertTrue(gp2a.isEqualTo(gp2));
+ Assert.assertTrue(gp2a.equals(gp2));
// case 3
final Geopoint gp3 = new Geopoint(51.29999833333333d, 13.8d);
@@ -137,7 +137,7 @@ public class GeopointTest extends AndroidTestCase {
Geopoint gp1a = DMM.createGeopoint(String.valueOf(dmm1.latDir), String.valueOf(dmm1.latDeg), String.valueOf(dmm1.latMin), String.valueOf(dmm1.latMinFrac),
String.valueOf(dmm1.lonDir), String.valueOf(dmm1.lonDeg), String.valueOf(dmm1.lonMin), String.valueOf(dmm1.lonMinFrac));
- Assert.assertTrue(gp1a.isEqualTo(gp1));
+ Assert.assertTrue(gp1a.equals(gp1));
// case 2
final Geopoint gp2 = new Geopoint(51.34567d, 13.87654d);
@@ -194,7 +194,7 @@ public class GeopointTest extends AndroidTestCase {
Geopoint gp1a = DMS.createGeopoint(String.valueOf(dms1.latDir), String.valueOf(dms1.latDeg), String.valueOf(dms1.latMin), String.valueOf(dms1.latSec), String.valueOf(dms1.latSecFrac),
String.valueOf(dms1.lonDir), String.valueOf(dms1.lonDeg), String.valueOf(dms1.lonMin), String.valueOf(dms1.lonSec), String.valueOf(dms1.lonSecFrac));
- Assert.assertTrue(gp1a.isEqualTo(gp1));
+ Assert.assertTrue(gp1a.equals(gp1));
// case 2
final Geopoint gp2 = new Geopoint(51.34567d, 13.87654d);
diff --git a/tests/src/cgeo/geocaching/test/mock/GC2JVEH.java b/tests/src/cgeo/geocaching/test/mock/GC2JVEH.java
index 6fdd753..34f5bcc 100644
--- a/tests/src/cgeo/geocaching/test/mock/GC2JVEH.java
+++ b/tests/src/cgeo/geocaching/test/mock/GC2JVEH.java
@@ -24,7 +24,7 @@ public class GC2JVEH extends MockedCache {
}
public GC2JVEH() {
- super(new Geopoint(52.37225, 9.73537));
+ super(new Geopoint(52.37225, 9.735367));
}
@Override