aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--main/src/cgeo/geocaching/Geocache.java16
1 files changed, 14 insertions, 2 deletions
diff --git a/main/src/cgeo/geocaching/Geocache.java b/main/src/cgeo/geocaching/Geocache.java
index 9a8325d..2706c5b 100644
--- a/main/src/cgeo/geocaching/Geocache.java
+++ b/main/src/cgeo/geocaching/Geocache.java
@@ -1372,8 +1372,11 @@ public class Geocache implements ICache, IWaypoint {
while (matcher.find()) {
try {
final Geopoint point = new Geopoint(note.substring(matcher.start()));
- // coords must have non zero latitude and longitude and at least one part shall have fractional degrees
- if (point.getLatitudeE6() != 0 && point.getLongitudeE6() != 0 && ((point.getLatitudeE6() % 1000) != 0 || (point.getLongitudeE6() % 1000) != 0)) {
+ // Coords must have non zero latitude and longitude, at least one part shall have fractional degrees,
+ // and there must exist no waypoint with the same coordinates already.
+ if (point.getLatitudeE6() != 0 && point.getLongitudeE6() != 0 &&
+ ((point.getLatitudeE6() % 1000) != 0 || (point.getLongitudeE6() % 1000) != 0) &&
+ !hasIdenticalWaypoint(point)) {
final String name = cgeoapplication.getInstance().getString(R.string.cache_personal_note) + " " + count;
final Waypoint waypoint = new Waypoint(name, WaypointType.WAYPOINT, false);
waypoint.setCoords(point);
@@ -1392,6 +1395,15 @@ public class Geocache implements ICache, IWaypoint {
}
}
+ private boolean hasIdenticalWaypoint(final Geopoint point) {
+ for (final Waypoint waypoint: waypoints) {
+ if (waypoint.getCoords() == point) {
+ return true;
+ }
+ }
+ return false;
+ }
+
/*
* For working in the debugger
* (non-Javadoc)