aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/cgData.java
diff options
context:
space:
mode:
authorrsudev <rasch@munin-soft.de>2013-07-06 15:08:08 +0200
committerrsudev <rasch@munin-soft.de>2013-07-06 15:08:08 +0200
commit7595b69b01a2e43befb2565a23a9b3f6c8736160 (patch)
treed26e3fcdb1c218eaf232dfdc215f227680c38ae6 /main/src/cgeo/geocaching/cgData.java
parent06e089bd300a3967f1c50d6509bdc8a0b792bdad (diff)
downloadcgeo-7595b69b01a2e43befb2565a23a9b3f6c8736160.zip
cgeo-7595b69b01a2e43befb2565a23a9b3f6c8736160.tar.gz
cgeo-7595b69b01a2e43befb2565a23a9b3f6c8736160.tar.bz2
Fixes #2826, Found caches shown on live map
Implemented detection and filtering for vanishing caches Added testcases for new functionality
Diffstat (limited to 'main/src/cgeo/geocaching/cgData.java')
-rw-r--r--main/src/cgeo/geocaching/cgData.java33
1 files changed, 33 insertions, 0 deletions
diff --git a/main/src/cgeo/geocaching/cgData.java b/main/src/cgeo/geocaching/cgData.java
index 6f535dc..adb3612 100644
--- a/main/src/cgeo/geocaching/cgData.java
+++ b/main/src/cgeo/geocaching/cgData.java
@@ -1,5 +1,7 @@
package cgeo.geocaching;
+import cgeo.geocaching.connector.IConnector;
+import cgeo.geocaching.connector.gc.Tile;
import cgeo.geocaching.enumerations.CacheSize;
import cgeo.geocaching.enumerations.CacheType;
import cgeo.geocaching.enumerations.LoadFlags;
@@ -2975,4 +2977,35 @@ public class cgData {
return false;
}
+ public static Set<String> getCachedMissingFromSearch(SearchResult searchResult, Set<Tile> tiles, IConnector connector) {
+
+ // get cached cgeocaches
+ final Set<String> cachedGeocodes = new HashSet<String>();
+ for (Tile tile : tiles) {
+ cachedGeocodes.addAll(cacheCache.getInViewport(tile.getViewport(), CacheType.ALL));
+ }
+ // remove found in search result
+ cachedGeocodes.removeAll(searchResult.getGeocodes());
+
+ // check remaining against viewports
+ Set<String> missingFromSearch = new HashSet<String>();
+ for (String geocode : cachedGeocodes) {
+ if (connector.canHandle(geocode)) {
+ Geocache geocache = cacheCache.getCacheFromCache(geocode);
+ boolean bFound = false;
+ for (Tile tile : tiles) {
+ if (tile.containsPoint(geocache)) {
+ bFound = true;
+ break;
+ }
+ }
+ if (bFound) {
+ missingFromSearch.add(geocode);
+ }
+ }
+ }
+
+ return missingFromSearch;
+ }
+
}