aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--main/src/cgeo/geocaching/connector/gc/GCMap.java21
-rw-r--r--main/src/cgeo/geocaching/connector/gc/IconDecoder.java610
-rw-r--r--tests/src/cgeo/geocaching/connector/gc/IconDecoderTest.java313
3 files changed, 842 insertions, 102 deletions
diff --git a/main/src/cgeo/geocaching/connector/gc/GCMap.java b/main/src/cgeo/geocaching/connector/gc/GCMap.java
index 049748c..be4c17b 100644
--- a/main/src/cgeo/geocaching/connector/gc/GCMap.java
+++ b/main/src/cgeo/geocaching/connector/gc/GCMap.java
@@ -167,6 +167,8 @@ public class GCMap {
// iterate over the data and construct all caches in this tile
Map<String, List<UTFGridPosition>> positions = new HashMap<String, List<UTFGridPosition>>(); // JSON id as key
+ Map<String, List<UTFGridPosition>> singlePositions = new HashMap<String, List<UTFGridPosition>>(); // JSON id as key
+
for (int i = 1; i < keys.length(); i++) { // index 0 is empty
String key = keys.getString(i);
if (StringUtils.isNotBlank(key)) {
@@ -178,12 +180,20 @@ public class GCMap {
nameCache.put(id, cacheInfo.getString("n"));
List<UTFGridPosition> listOfPositions = positions.get(id);
+ List<UTFGridPosition> singleListOfPositions = singlePositions.get(id);
+
if (listOfPositions == null) {
listOfPositions = new ArrayList<UTFGridPosition>();
positions.put(id, listOfPositions);
+ singleListOfPositions = new ArrayList<UTFGridPosition>();
+ singlePositions.put(id, singleListOfPositions);
}
listOfPositions.add(pos);
+ if (dataForKey.length() == 1) {
+ singleListOfPositions.add(pos);
+ }
+
}
}
}
@@ -199,12 +209,17 @@ public class GCMap {
cache.setName(nameCache.get(id));
cache.setZoomlevel(tile.getZoomlevel());
cache.setCoords(tile.getCoord(xy));
- if (strategy.flags.contains(StrategyFlag.PARSE_TILES) && positions.size() < 64 && bitmap != null) {
- // don't parse if there are too many caches. The decoding would return too much wrong results
- IconDecoder.parseMapPNG(cache, bitmap, xy, tile.getZoomlevel());
+ if (strategy.flags.contains(StrategyFlag.PARSE_TILES) && bitmap != null) {
+ for (UTFGridPosition singlePos : singlePositions.get(id)) {
+ if (IconDecoder.parseMapPNG(cache, bitmap, singlePos, tile.getZoomlevel()))
+ {
+ break; // cache parsed
+ }
+ }
} else {
cache.setType(CacheType.UNKNOWN);
}
+
boolean exclude = false;
if (Settings.isExcludeMyCaches() && (cache.isFound() || cache.isOwn())) { // workaround for BM
exclude = true;
diff --git a/main/src/cgeo/geocaching/connector/gc/IconDecoder.java b/main/src/cgeo/geocaching/connector/gc/IconDecoder.java
index 74e78cc..554760c 100644
--- a/main/src/cgeo/geocaching/connector/gc/IconDecoder.java
+++ b/main/src/cgeo/geocaching/connector/gc/IconDecoder.java
@@ -11,106 +11,193 @@ import android.graphics.Bitmap;
*/
public abstract class IconDecoder {
- public static void parseMapPNG(final cgCache cache, Bitmap bitmap, UTFGridPosition xy, int zoomlevel) {
+ public static boolean parseMapPNG(final cgCache cache, Bitmap bitmap, UTFGridPosition xy, int zoomlevel) {
if (zoomlevel >= 14) {
- parseMapPNG14(cache, bitmap, xy);
- } else {
- parseMapPNG13(cache, bitmap, xy);
+ return parseMapPNG14(cache, bitmap, xy);
}
+ if (zoomlevel <= 11) {
+ return parseMapPNG11(cache, bitmap, xy);
+ }
+ return parseMapPNG13(cache, bitmap, xy);
}
- private static final int[] OFFSET_X = new int[] { 0, -1, -1, 0, 1, 1, 1, 0, -1, -2, -2, -2, -2, -1, 0, 1, 2, 2, 2, 2, 2, 1, 0, -1, -2 };
- private static final int[] OFFSET_Y = new int[] { 0, 0, 1, 1, 1, 0, -1, -1, -1, -1, 0, 1, 2, 2, 2, 2, 2, 1, 0, -1, -2, -2, -2, -2, -2 };
+ public static int CT_TRADITIONAL = 0;
+ public static int CT_MULTI = 1;
+ public static int CT_MYSTERY = 2;
+ public static int CT_EVENT = 3;
+ public static int CT_VIRTUAL = 4;
+ public static int CT_FOUND = 5;
+ public static int CT_OWN = 6;
+ public static int CT_MEGAEVENT = 7;
+ public static int CT_CITO = 8;
+ public static int CT_WEBCAM = 9;
+ public static int CT_WHEREIGO = 10;
+ public static int CT_EARTH = 11;
+ public static int CT_LETTERBOX = 12;
/**
- * The icon decoder walks a spiral around the center pixel position of the cache
- * and searches for characteristic colors.
+ * The icon decoder over all 16 pixels of image . It should not be invoked on any part of image that might overlay
+ * with other caches.
+ * Is uses decision tree to determine right type.
*
* @param cache
* @param bitmap
* @param xy
+ * @return true if parsing was successful
*/
- private static void parseMapPNG13(final cgCache cache, Bitmap bitmap, UTFGridPosition xy) {
- final int xCenter = xy.getX() * 4 + 2;
- final int yCenter = xy.getY() * 4 + 2;
+ private static boolean parseMapPNG13(final cgCache cache, Bitmap bitmap, UTFGridPosition xy) {
+ final int topX = xy.getX() * 4;
+ final int topY = xy.getY() * 4;
final int bitmapWidth = bitmap.getWidth();
final int bitmapHeight = bitmap.getHeight();
- int countMulti = 0;
- int countFound = 0;
+ int[] pngType = new int[7];
- for (int i = 0; i < OFFSET_X.length; i++) {
+ if ((topX < 0) || (topY < 0) || (topX + 4 > bitmapWidth) || (topY + 4 > bitmapHeight)) {
+ return false; //out of image position
+ }
- // assert that we are still in the tile
- final int x = xCenter + OFFSET_X[i];
- if (x < 0 || x >= bitmapWidth) {
- continue;
- }
+ for (int x = topX; x < topX + 4; x++) {
+ for (int y = topY; y < topY + 4; y++) {
+ int color = bitmap.getPixel(x, y);
- final int y = yCenter + OFFSET_Y[i];
- if (y < 0 || y >= bitmapHeight) {
- continue;
- }
+ if ((color & 0xFFFFFF) == 0x5f5f5f) {
+ continue; //Border in every icon is the same and therefore no use to us
+ }
+ if ((color >>> 24) != 255) {
+ continue; //transparent pixels (or semi_transparent) are only shadows of border
+ }
- int color = bitmap.getPixel(x, y) & 0x00FFFFFF;
+ int red = (color & 0xFF0000) >> 16;
+ int green = (color & 0xFF00) >> 8;
+ int blue = color & 0xFF;
- // transparent pixels are not interesting
- if (color == 0) {
- continue;
+ int type = getCacheTypeFromPixel13(red, green, blue);
+ pngType[type]++;
}
+ }
- int red = (color & 0xFF0000) >> 16;
- int green = (color & 0xFF00) >> 8;
- int blue = color & 0xFF;
+ int type = -1;
+ int count = 0;
- // these are quite sure, so one pixel is enough for matching
- if (green > 0x80 && green > red && green > blue) {
- cache.setType(CacheType.TRADITIONAL);
- return;
- }
- if (blue > 0x80 && blue > red && blue > green) {
- cache.setType(CacheType.MYSTERY);
- return;
- }
- if (red > 0x90 && blue < 0x10 && green < 0x10) {
- cache.setType(CacheType.EVENT);
- return;
+ for (int x = 0; x < 7; x++)
+ {
+ if (pngType[x] > count) {
+ count = pngType[x];
+ type = x;
}
+ }
- // next two are hard to distinguish, therefore we sample all pixels of the spiral
- if (red > 0xFA && green > 0xD0) {
- countMulti++;
+ if (count > 1) { // 2 pixels need to detect same type and we say good to go
+ switch (type) {
+ case 0:
+ cache.setType(CacheType.TRADITIONAL);
+ return true;
+ case 1:
+ cache.setType(CacheType.MULTI);
+ return true;
+ case 2:
+ cache.setType(CacheType.MYSTERY); //mystery, whereigo, groundspeak HQ and mystery is most common
+ return true;
+ case 3:
+ cache.setType(CacheType.EVENT); //event, cito, mega-event and event is most common
+ return true;
+ case 4:
+ cache.setType(CacheType.EARTH); //It's an image of ghost (webcam, earth, virtual) and earth in most common
+ return true;
+ case 5:
+ cache.setFound(true);
+ return true;
+ case 6:
+ cache.setOwn(true);
+ return true;
}
- if (red < 0xF3 && red > 0xa0 && green > 0x20 && blue < 0x80) {
- countFound++;
+ }
+ return false;
+ }
+
+ /**
+ * The icon decoder over all 16 pixels of image . It should not be invoked on any part of image that might overlay
+ * with other caches.
+ * Is uses decision tree to determine right type.
+ *
+ * @param cache
+ * @param bitmap
+ * @param xy
+ * @return true if parsing was successful
+ */
+ private static boolean parseMapPNG11(final cgCache cache, Bitmap bitmap, UTFGridPosition xy) {
+ final int topX = xy.getX() * 4;
+ final int topY = xy.getY() * 4;
+ final int bitmapWidth = bitmap.getWidth();
+ final int bitmapHeight = bitmap.getHeight();
+
+ int[] pngType = new int[5];
+
+ if ((topX < 0) || (topY < 0) || (topX + 4 > bitmapWidth) || (topY + 4 > bitmapHeight)) {
+ return false; //out of image position
+ }
+
+ for (int x = topX; x < topX + 4; x++) {
+ for (int y = topY; y < topY + 4; y++) {
+ int color = bitmap.getPixel(x, y);
+
+
+ if ((color >>> 24) != 255) {
+ continue; //transparent pixels (or semi_transparent) are only shadows of border
+ }
+
+ int r = (color & 0xFF0000) >> 16;
+ int g = (color & 0xFF00) >> 8;
+ int b = color & 0xFF;
+
+ //Duplicate colors does not add any value
+ if (((r == 52) && (g == 52) && (b == 52)) ||
+ ((r == 69) && (g == 69) && (b == 69)) ||
+ ((r == 90) && (g == 90) && (b == 90)) ||
+ ((r == 233) && (g == 233) && (b == 234)) ||
+ ((r == 255) && (g == 255) && (b == 255))) {
+ continue;
+ }
+
+ int type = getCacheTypeFromPixel11(r, g, b);
+ pngType[type]++;
}
}
- // now check whether we are sure about found/multi
- if (countFound > countMulti && countFound >= 2) {
- cache.setFound(true);
+ int type = -1;
+ int count = 0;
+
+ for (int x = 0; x < 5; x++)
+ {
+ if (pngType[x] > count) {
+ count = pngType[x];
+ type = x;
+ }
}
- if (countMulti > countFound && countMulti >= 5) {
- cache.setType(CacheType.MULTI);
+
+ if (count > 1) { // 2 pixels need to detect same type and we say good to go
+ switch (type) {
+ case 0:
+ cache.setType(CacheType.TRADITIONAL);
+ return true;
+ case 1:
+ cache.setType(CacheType.MULTI);
+ return true;
+ case 2:
+ cache.setType(CacheType.MYSTERY); //mystery, whereigo, groundspeak HQ and mystery is most common
+ return true;
+ case 3:
+ cache.setType(CacheType.EVENT); //event, cito, mega-event and event is most common
+ return true;
+ case 4:
+ cache.setType(CacheType.EARTH); //webcam, earth, virtual and earth in most common
+ return true;
+ }
}
+ return false;
}
- // Pixel colors in tile
- private final static int COLOR_BORDER_GRAY = 0x5F5F5F;
- private final static int COLOR_TRADITIONAL = 0x316013;
- private final static int COLOR_MYSTERY = 0x243C97;
- private final static int COLOR_MULTI = 0xFFDE19;
- private final static int COLOR_FOUND = 0xFBEA5D;
-
- // Offset inside cache icon
- private final static int POSX_TRADI = 7;
- private final static int POSY_TRADI = -12;
- private final static int POSX_MULTI = 5; // for orange 8
- private final static int POSY_MULTI = -9; // for orange 10
- private final static int POSX_MYSTERY = 5;
- private final static int POSY_MYSTERY = -13;
- private final static int POSX_FOUND = 10;
- private final static int POSY_FOUND = -8;
/**
* For level 14 find the borders of the icons and then use a single pixel and color to match.
@@ -119,44 +206,377 @@ public abstract class IconDecoder {
* @param bitmap
* @param xy
*/
- private static void parseMapPNG14(cgCache cache, Bitmap bitmap, UTFGridPosition xy) {
- int x = xy.getX() * 4 + 2;
- int y = xy.getY() * 4 + 2;
+ private static boolean parseMapPNG14(cgCache cache, Bitmap bitmap, UTFGridPosition xy) {
+ final int topX = xy.getX() * 4;
+ final int topY = xy.getY() * 4;
+ final int bitmapWidth = bitmap.getWidth();
+ final int bitmapHeight = bitmap.getHeight();
+
+ int[] pngType = new int[13];
+
+ if ((topX < 0) || (topY < 0) || (topX + 4 > bitmapWidth) || (topY + 4 > bitmapHeight)) {
+ return false; //out of image position
+ }
+
+ for (int x = topX; x < topX + 4; x++) {
+ for (int y = topY; y < topY + 4; y++) {
+ int color = bitmap.getPixel(x, y);
+
+ if ((color & 0xFFFFFF) == 0x5f5f5f) {
+ continue; //Border in every icon is the same and therefore no use to us
+ }
+ if ((color >>> 24) != 255) {
+ continue; //transparent pixels (or semi_transparent) are only shadows of border
+ }
+
+ int r = (color & 0xFF0000) >> 16;
+ int g = (color & 0xFF00) >> 8;
+ int b = color & 0xFF;
+
+ //Duplicate colors does not add any value
+ if (((r == 216) && (g == 216) && (b == 216)) ||
+ ((r == 23) && (g == 23) && (b == 23)) ||
+ ((r == 240) && (g == 240) && (b == 240)) ||
+ ((r == 44) && (g == 44) && (b == 44)) ||
+ ((r == 228) && (g == 228) && (b == 228)) ||
+ ((r == 225) && (g == 225) && (b == 225)) ||
+ ((r == 199) && (g == 199) && (b == 199)) ||
+ ((r == 161) && (g == 161) && (b == 161)) ||
+ ((r == 8) && (g == 8) && (b == 8)) ||
+ ((r == 200) && (g == 200) && (b == 200)) ||
+ ((r == 255) && (g == 255) && (b == 255)) ||
+ ((r == 250) && (g == 250) && (b == 250)) ||
+ ((r == 95) && (g == 95) && (b == 95)) ||
+ ((r == 236) && (g == 236) && (b == 236)) ||
+ ((r == 215) && (g == 215) && (b == 215)) ||
+ ((r == 232) && (g == 232) && (b == 232)) ||
+ ((r == 217) && (g == 217) && (b == 217)) ||
+ ((r == 0) && (g == 0) && (b == 0)) ||
+ ((r == 167) && (g == 167) && (b == 167)) ||
+ ((r == 247) && (g == 247) && (b == 247)) ||
+ ((r == 144) && (g == 144) && (b == 144)) ||
+ ((r == 231) && (g == 231) && (b == 231)) ||
+ ((r == 248) && (g == 248) && (b == 248))) {
+ continue;
+ }
- // search for left border
- int countX = 0;
- while ((bitmap.getPixel(x, y) & 0x00FFFFFF) != COLOR_BORDER_GRAY) {
- if (--x < 0 || ++countX > 20) {
- return;
+ int type = getCacheTypeFromPixel14(r, g, b);
+ pngType[type]++;
}
}
- // search for bottom border
- int countY = 0;
- while ((bitmap.getPixel(x, y) & 0x00FFFFFF) != 0x000000) {
- if (++y >= Tile.TILE_SIZE || ++countY > 20) {
- return;
+
+ int type = -1;
+ int count = 0;
+
+ for (int x = 0; x < 7; x++)
+ {
+ if (pngType[x] > count) {
+ count = pngType[x];
+ type = x;
+ }
+ }
+ /*
+ * public static int CT_MEGAEVENT = 7;
+ * public static int CT_CITO = 8;
+ * public static int CT_WEBCAM = 9;
+ * public static int CT_WHEREIGO = 10;
+ * public static int CT_EARTH = 11;
+ * public static int CT_LETTERBOX = 12;
+ */
+ if (count > 1) { // 2 pixels need to detect same type and we say good to go
+ switch (type) {
+ case 0:
+ cache.setType(CacheType.TRADITIONAL);
+ return true;
+ case 1:
+ cache.setType(CacheType.MULTI);
+ return true;
+ case 2:
+ cache.setType(CacheType.MYSTERY);
+ return true;
+ case 3:
+ cache.setType(CacheType.EVENT);
+ return true;
+ case 4:
+ cache.setType(CacheType.VIRTUAL);
+ return true;
+ case 5:
+ cache.setFound(true);
+ return true;
+ case 6:
+ cache.setOwn(true);
+ return true;
+ case 7:
+ cache.setType(CacheType.MEGA_EVENT);
+ return true;
+ case 8:
+ cache.setType(CacheType.CITO);
+ return true;
+ case 9:
+ cache.setType(CacheType.WEBCAM);
+ return true;
+ case 10:
+ cache.setType(CacheType.WHERIGO);
+ return true;
+ case 11:
+ cache.setType(CacheType.EARTH);
+ return true;
+ case 12:
+ cache.setType(CacheType.LETTERBOX);
+ return true;
+ }
+ }
+ return false;
+
+ }
+
+ /**
+ * This method returns detected type from specific pixel from geocaching.com live map.
+ * It was constructed based on classification tree made by Orange (http://orange.biolab.si/)
+ * Input file was made from every non-transparent pixel of every possible "middle" cache icon from GC map
+ *
+ * @param r
+ * Red component of pixel (from 0 - 255)
+ * @param g
+ * Green component of pixel (from 0 - 255)
+ * @param b
+ * Blue component of pixel (from 0 - 255)
+ * @return Value from 0 to 6 representing detected type or state of the cache.
+ */
+ private static int getCacheTypeFromPixel13(int r, int g, int b) {
+ if (g < 110) {
+ if (r > 87) {
+ return ((g > 73) && (b < 63)) ? CT_FOUND : CT_EVENT;
+ }
+ return CT_MYSTERY;
+ }
+ if (b > 137) {
+ if ((r < 184) && (g > 190)) {
+ return CT_TRADITIONAL;
+ }
+ if ((r < 184) && (g < 191) && (r < 136)) {
+ return CT_MYSTERY;
}
+ return CT_VIRTUAL;
}
+ if (r < 158) {
+ return ((r > 129) && (r < 153)) ? CT_FOUND : CT_TRADITIONAL;
+ }
+ if (b > 33) {
+ if (b > 57) {
+ if (b > 100) {
+ return (r > 229) ? CT_MULTI : CT_EVENT;
+ }
+ return ((r > 254) && (g < 236)) ? CT_MULTI : CT_FOUND;
+ }
+ if ((g > 173) && ((g < 224))) {
+ return ((r < 243) && (r > 223)) ? CT_FOUND : CT_OWN;
+ }
+ return CT_FOUND;
+ }
+ return CT_MULTI;
+ }
- try {
- if ((bitmap.getPixel(x + POSX_TRADI, y + POSY_TRADI) & 0x00FFFFFF) == COLOR_TRADITIONAL) {
- cache.setType(CacheType.TRADITIONAL);
- return;
+ /**
+ * This method returns detected type from specific pixel from geocaching.com live map level 14 or higher.
+ * It was constructed based on classification tree made by Orange (http://orange.biolab.si/)
+ * Input file was made from every non-transparent pixel of every possible "full" cache icon from GC map
+ *
+ * @param r
+ * Red component of pixel (from 0 - 255)
+ * @param g
+ * Green component of pixel (from 0 - 255)
+ * @param b
+ * Blue component of pixel (from 0 - 255)
+ * @return Value from 0 to 6 representing detected type or state of the cache.
+ */
+ private static int getCacheTypeFromPixel14(int r, int g, int b) {
+ if (b < 140) {
+ if (r > 155) {
+ if (g < 159) {
+ if (r < 173) {
+ return (r > 161) ? CT_MEGAEVENT : CT_OWN;
+ }
+ if (r < 206) {
+ if (b > 49) {
+ return (b > 83) ? CT_EVENT : CT_FOUND;
+ }
+ return (b < 31) ? CT_EARTH : CT_FOUND;
+ }
+ return (r < 221) ? CT_FOUND : CT_MULTI;
+ }
+ if (r > 210) {
+ if (g < 188) {
+ return CT_FOUND;
+ }
+ if (r < 246) {
+ return CT_OWN;
+ }
+ if (r < 254) {
+ return CT_FOUND;
+ }
+ if (r < 255) {
+ return CT_EVENT;
+ }
+ if (g < 208) {
+ return CT_EARTH;
+ }
+ if (g > 225) {
+ return CT_EARTH;
+ }
+ return (b < 36) ? CT_MULTI : CT_OWN;
+ }
+ return (b < 66) ? CT_OWN : CT_EARTH;
+ }
+ if (r < 63) {
+ if (b > 26) {
+ if (b < 29) {
+ return CT_WEBCAM;
+ }
+ if (g > 102) {
+ return CT_CITO;
+ }
+ return (r < 26) ? CT_CITO : CT_WEBCAM;
+ }
+ if (g < 38) {
+ return CT_WEBCAM;
+ }
+ return (r < 41) ? CT_EARTH : CT_TRADITIONAL;
+ }
+ if (b < 119) {
+ if (g < 81) {
+ return CT_WEBCAM;
+ }
+ if (b < 90) {
+ return CT_OWN;
+ }
+ return (r < 104) ? CT_WEBCAM : CT_OWN;
+ }
+ if (r < 132) {
+ return (b < 124) ? CT_MULTI : CT_WHEREIGO;
+ }
+ if (g > 164) {
+ return CT_TRADITIONAL;
+ }
+ if (b < 134) {
+ return CT_OWN;
+ }
+ return (b > 137) ? CT_OWN : CT_WHEREIGO;
+ }
+ if (b < 245) {
+ if (r < 180) {
+ if (b < 218) {
+ if (g < 71) {
+ return CT_MYSTERY;
+ }
+ if (r < 96) {
+ return CT_WHEREIGO;
+ }
+ if (b > 165) {
+ return CT_WHEREIGO;
+ }
+ if (r < 153) {
+ return CT_WHEREIGO;
+ }
+ if (r < 160) {
+ return CT_WEBCAM;
+ }
+ return (r < 162) ? CT_WHEREIGO : CT_WEBCAM;
+ }
+ return (r < 158) ? CT_MEGAEVENT : CT_EARTH;
}
- if ((bitmap.getPixel(x + POSX_MYSTERY, y + POSY_MYSTERY) & 0x00FFFFFF) == COLOR_MYSTERY) {
- cache.setType(CacheType.MYSTERY);
- return;
+ if (g > 232) {
+ if (g > 247) {
+ return CT_CITO;
+ }
+ if (r < 237) {
+ return CT_OWN;
+ }
+ if (g < 238) {
+ return CT_OWN;
+ }
+ if (r > 243) {
+ return CT_WEBCAM;
+ }
+ return (g > 238) ? CT_OWN : CT_WEBCAM;
}
- if ((bitmap.getPixel(x + POSX_MULTI, y + POSY_MULTI) & 0x00FFFFFF) == COLOR_MULTI) {
- cache.setType(CacheType.MULTI);
- return;
+ if (r < 228) {
+ if (b > 238) {
+ return CT_MYSTERY;
+ }
+ if (r < 193) {
+ if (r < 184) {
+ return CT_OWN;
+ }
+ if (g < 186) {
+ return CT_WHEREIGO;
+ }
+ return (r > 189) ? CT_WHEREIGO : CT_OWN;
+ }
+ if (g < 223) {
+ if (r > 216) {
+ return CT_OWN;
+ }
+ if (g > 217) {
+ return CT_WHEREIGO;
+ }
+ if (b > 211) {
+ return CT_WEBCAM;
+ }
+ if (b < 196) {
+ return CT_WEBCAM;
+ }
+ if (r > 210) {
+ return CT_OWN;
+ }
+ return (g > 206) ? CT_WHEREIGO : CT_OWN;
+ }
+ if (g < 224) {
+ return CT_OWN;
+ }
+ return (r < 226) ? CT_WHEREIGO : CT_OWN;
}
- if ((bitmap.getPixel(x + POSX_FOUND, y + POSY_FOUND) & 0x00FFFFFF) == COLOR_FOUND) {
- cache.setFound(true);
+ return (b < 216) ? CT_FOUND : CT_OWN;
+ }
+ if (r < 238) {
+ if (r > 141) {
+ return (r > 185) ? CT_LETTERBOX : CT_CITO;
}
- } catch (IllegalArgumentException e) {
- // intentionally left blank
+ return (r < 41) ? CT_EARTH : CT_LETTERBOX;
}
+ return (r < 243) ? CT_WHEREIGO : CT_OWN;
+ }
+ /**
+ * This method returns detected type from specific pixel from geocaching.com live map level 11 or lower.
+ * It was constructed based on classification tree made by Orange (http://orange.biolab.si/)
+ * Input file was made from every non-transparent pixel of every possible "full" cache icon from GC map
+ *
+ * @param r
+ * Red component of pixel (from 0 - 255)
+ * @param g
+ * Green component of pixel (from 0 - 255)
+ * @param b
+ * Blue component of pixel (from 0 - 255)
+ * @return Value from 0 to 4 representing detected type or state of the cache.
+ */
+ private static int getCacheTypeFromPixel11(int r, int g, int b) {
+ if (b < 139) {
+ if (g > 104) {
+ if (r < 173) {
+ return CT_TRADITIONAL;
+ }
+ return (r > 225) ? CT_MULTI : CT_EVENT;
+ }
+ if (b < 25) {
+ return CT_EVENT;
+ }
+ return (r < 87) ? CT_MYSTERY : CT_EVENT;
+ }
+ if (r > 140) {
+ return (r < 197) ? CT_TRADITIONAL : CT_VIRTUAL;
+ }
+ return CT_MYSTERY;
}
+
}
diff --git a/tests/src/cgeo/geocaching/connector/gc/IconDecoderTest.java b/tests/src/cgeo/geocaching/connector/gc/IconDecoderTest.java
index 3fa17f8..46e64ef 100644
--- a/tests/src/cgeo/geocaching/connector/gc/IconDecoderTest.java
+++ b/tests/src/cgeo/geocaching/connector/gc/IconDecoderTest.java
@@ -15,10 +15,10 @@ public class IconDecoderTest extends AbstractResourceInstrumentationTestCase {
final Bitmap bitmap = getBitmap(R.raw.tile14);
Log.d("Bitmap=" + bitmap.getWidth() + "x" + bitmap.getHeight());
- assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 97, 136, 14).getType());
- assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 226, 104, 14).getType());
- assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 54, 97, 14).getType());
- assertTrue(parseMapPNG(bitmap, 119, 108, 14).isFound());
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 88, 124, 14).getType());
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 228, 104, 14).getType());
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 52, 92, 14).getType());
+ assertTrue(parseMapPNG(bitmap, 108, 112, 14).isFound());
}
private Bitmap getBitmap(int resourceId) {
@@ -73,9 +73,314 @@ public class IconDecoderTest extends AbstractResourceInstrumentationTestCase {
tradi = parseMapPNG(bitmap, 117, 225, 12).getType() == CacheType.TRADITIONAL ? tradi + 1 : tradi;
tradi = parseMapPNG(bitmap, 90, 107, 12).getType() == CacheType.TRADITIONAL ? tradi + 1 : tradi;
+ int found = 0;
+ found = parseMapPNG(bitmap, 150, 124, 12).isFound() ? found + 1 : found;
+ found = parseMapPNG(bitmap, 176, 82, 12).isFound() ? found + 1 : found;
+ found = parseMapPNG(bitmap, 240, 140, 12).isFound() ? found + 1 : found;
+ found = parseMapPNG(bitmap, 211, 127, 12).isFound() ? found + 1 : found;
+
assertEquals(7, multi);
assertEquals(7, mystery);
assertEquals(7, tradi);
+ assertEquals(4, found);
+ }
+
+ public void testParseExtraMap1() {
+ final Bitmap bitmap = getBitmap(R.raw.map1);
+ assertTrue(parseMapPNG(bitmap, 128, 168, 12).isFound()); // GC3AT8B
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 172, 164, 12).getType()); // GC39EXB
+ assertTrue(parseMapPNG(bitmap, 164, 156, 12).isFound()); // GC30M7M
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 204, 72, 12).getType()); // GC3AN5Z
+ assertTrue(parseMapPNG(bitmap, 188, 92, 12).isFound()); // GC37T3R
+ assertTrue(parseMapPNG(bitmap, 164, 132, 12).isFound()); // GC34JME
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 176, 148, 12).getType()); // GC37TCY
+ assertEquals(CacheType.EARTH, parseMapPNG(bitmap, 180, 136, 12).getType()); // GC3947Z
+ assertTrue(parseMapPNG(bitmap, 164, 100, 12).isFound()); // GC2ZY3X
+ assertTrue(parseMapPNG(bitmap, 52, 104, 12).isFound()); // GC29RCW
+ assertTrue(parseMapPNG(bitmap, 168, 88, 12).isFound()); // GC264JZ
+ assertTrue(parseMapPNG(bitmap, 168, 140, 12).isFound()); // GC37RRV
+ }
+
+ public void testParseExtraMap2() {
+ final Bitmap bitmap = getBitmap(R.raw.map2);
+
+ assertTrue(parseMapPNG(bitmap, 132, 136, 12).isFound()); // GC3JDBW
+ assertTrue(parseMapPNG(bitmap, 68, 24, 12).isFound()); // GC2T0AH
+ assertTrue(parseMapPNG(bitmap, 176, 232, 12).isOwn()); // GC2RPBX
+ assertTrue(parseMapPNG(bitmap, 148, 60, 12).isFound()); // GC31FY6
+ assertTrue(parseMapPNG(bitmap, 216, 20, 12).isFound()); // GC2KP3M
+ assertTrue(parseMapPNG(bitmap, 212, 184, 12).isOwn()); // GC30W3K
+ assertTrue(parseMapPNG(bitmap, 148, 72, 12).isOwn()); // GC2RPAZ
+ assertTrue(parseMapPNG(bitmap, 216, 48, 12).isOwn()); // GC2RP8W
+ assertTrue(parseMapPNG(bitmap, 212, 60, 12).isFound()); // GC3CC97
+ assertTrue(parseMapPNG(bitmap, 148, 100, 12).isOwn()); // GC2RPAT
+ assertTrue(parseMapPNG(bitmap, 104, 136, 12).isFound()); // GC3AE31
+ assertTrue(parseMapPNG(bitmap, 52, 96, 12).isOwn()); // GC2RPCH
+ assertTrue(parseMapPNG(bitmap, 172, 156, 12).isOwn()); // GC2RQ07
+ assertTrue(parseMapPNG(bitmap, 116, 56, 12).isFound()); // GC3AYR2
+ assertTrue(parseMapPNG(bitmap, 208, 68, 12).isOwn()); // GC2RP93
+ assertTrue(parseMapPNG(bitmap, 200, 52, 12).isOwn()); // GC2RPAA
+ assertTrue(parseMapPNG(bitmap, 208, 44, 12).isFound()); // GC3HE15
+ assertTrue(parseMapPNG(bitmap, 112, 76, 12).isOwn()); // GC2RPBE
+ assertTrue(parseMapPNG(bitmap, 232, 192, 12).isOwn()); // GC2E1KF
+ assertTrue(parseMapPNG(bitmap, 184, 76, 12).isFound()); // GC2NK5R
+ assertTrue(parseMapPNG(bitmap, 132, 148, 12).isOwn()); // GC2RPBC
+ }
+
+ public void testParseExtraMap3() {
+ final Bitmap bitmap = getBitmap(R.raw.map3);
+
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 44, 0, 12).getType()); // GC1THF5
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 176, 100, 12).getType()); // GC29EGE
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 212, 128, 12).getType()); // GC1VR64
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 220, 56, 12).getType()); // GC1M13A
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 120, 80, 12).getType()); // GC1ZA2Z
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 148, 56, 12).getType()); // GC1MRD8
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 252, 8, 12).getType()); // GC3AGEX
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 76, 108, 12).getType()); // GC2C5RB
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 228, 188, 12).getType()); // GC33TWE
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 232, 128, 12).getType()); // GC38QDJ
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 228, 160, 12).getType()); // GC2G8M1
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 184, 64, 12).getType()); // GC2FYH4
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 60, 132, 12).getType()); // GC299CV
+ assertEquals(CacheType.EVENT, parseMapPNG(bitmap, 244, 124, 12).getType()); // GC3E5FW
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 200, 160, 12).getType()); // GC29NR9
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 216, 116, 12).getType()); // GC17P5R
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 144, 92, 12).getType()); // GC1WYN3
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 80, 4, 12).getType()); // GC2Z90W
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 216, 148, 12).getType()); // GC29M3P
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 176, 148, 12).getType()); // GC2HJ88
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 68, 72, 12).getType()); // GC1VRB4
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 232, 100, 12).getType()); // GC29EG4
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 220, 68, 12).getType()); // GC2YXH8
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 248, 156, 12).getType()); // GC1F277
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 208, 80, 12).getType()); // GC2NV6T
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 60, 92, 12).getType()); // GC2Y2YY
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 188, 168, 12).getType()); // GC26RT7
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 224, 124, 12).getType()); // GC1ZBPC
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 144, 80, 12).getType()); // GC29NQJ
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 192, 124, 12).getType()); // GC1QRAP
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 104, 116, 12).getType()); // GC29NR1
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 240, 44, 12).getType()); // GC35KYR
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 168, 0, 12).getType()); // GC1VR78
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 200, 84, 12).getType()); // GC2YR8Z
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 52, 160, 12).getType()); // GC1MTD8
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 236, 156, 12).getType()); // GCYW8A
}
+
+ public void testParseExtraMap4() {
+ final Bitmap bitmap = getBitmap(R.raw.map4);
+
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 124, 84, 12).getType()); // GC2M3CD
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 92, 140, 12).getType()); // GC1W2A2
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 156, 108, 12).getType()); // GC3FR70
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 44, 72, 12).getType()); // GC10W91
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 104, 36, 12).getType()); // GCRC1W
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 88, 36, 12).getType()); // GC30PQF
+ assertTrue(parseMapPNG(bitmap, 116, 36, 12).isFound()); // GC17VWA
+ assertEquals(CacheType.EARTH, parseMapPNG(bitmap, 28, 56, 12).getType()); // GC1E6A6
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 96, 72, 12).getType()); // GCMVAC
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 140, 48, 12).getType()); // GCZPE4
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 88, 84, 12).getType()); // GC16G8B
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 116, 48, 12).getType()); // GCZPEB
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 148, 8, 12).getType()); // GC19QQ4
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 68, 124, 12).getType()); // GCXJGD
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 88, 156, 12).getType()); // GC1VNAE
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 24, 24, 12).getType()); // GC1AY4H
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 180, 60, 12).getType()); // GC3K4HB
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 56, 104, 12).getType()); // GC2M4EH
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 12, 132, 12).getType()); // GC2B92G
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 240, 180, 12).getType()); // GC2YJ88
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 220, 140, 12).getType()); // GC2AWBC
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 124, 44, 12).getType()); // GC16V66
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 116, 104, 12).getType()); // GC2MN5V
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 212, 4, 12).getType()); // GC3BF7V
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 168, 40, 12).getType()); // GC1PB21
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 252, 56, 12).getType()); // GC22VTB
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 108, 64, 12).getType()); // GCVE3B
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 20, 140, 12).getType()); // GC1R041
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 124, 244, 12).getType()); // GC3DWEA
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 240, 136, 12).getType()); // GC249ZE
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 124, 56, 12).getType()); // GC1X0XJ
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 56, 16, 12).getType()); // GC2ZVGB
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 164, 164, 12).getType()); // GC3D65W
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 240, 128, 12).getType()); // GC33KV9
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 220, 244, 12).getType()); // GC21VT0
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 84, 24, 12).getType()); // GC1949K
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 104, 88, 12).getType()); // GC1FKZY
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 56, 248, 12).getType()); // GC2Y5Z4
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 72, 32, 12).getType()); // GC395J6
+ assertTrue(parseMapPNG(bitmap, 180, 4, 12).isFound()); // GC21MFG
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 96, 100, 12).getType()); // GC1W45E
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 144, 160, 12).getType()); // GC37BA1
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 12, 4, 12).getType()); // GC1K8KR
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 172, 92, 12).getType()); // GC3EZZ4
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 188, 132, 12).getType()); // GC26T9J
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 68, 192, 12).getType()); // GC1ZAMG
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 176, 180, 12).getType()); // GC21EZE
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 172, 76, 12).getType()); // GC1G5PT
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 208, 112, 12).getType()); // GC132VV
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 156, 40, 12).getType()); // GC264J4
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 252, 140, 12).getType()); // GC2JBNE
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 112, 76, 12).getType()); // GC16VKJ
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 16, 156, 12).getType()); // GC2ADX3
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 68, 48, 12).getType()); // GC2AZT1
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 176, 252, 12).getType()); // GC3DWNM
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 4, 156, 12).getType()); // GC30VHE
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 156, 120, 12).getType()); // GC1T9WM
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 40, 48, 12).getType()); // GC30MTZ
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 180, 232, 12).getType()); // GC2XVQA
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 72, 92, 12).getType()); // GC1VVA9
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 0, 132, 12).getType()); // GC1XNN4
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 92, 192, 12).getType()); // GC11D9P
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 52, 84, 12).getType()); // GC2M693
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 176, 196, 12).getType()); // GCZHVE
+ assertTrue(parseMapPNG(bitmap, 140, 108, 12).isFound()); // GC1Q5PW
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 108, 148, 12).getType()); // GC2ZR0C
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 168, 8, 12).getType()); // GCYWQH
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 196, 92, 12).getType()); // GC39VXN
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 148, 136, 12).getType()); // GC2MM6C
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 168, 28, 12).getType()); // GC2H1TG
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 240, 52, 12).getType()); // GC2QTXT
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 152, 148, 12).getType()); // GC3E7QD
+ assertTrue(parseMapPNG(bitmap, 160, 60, 12).isFound()); // GC2J3G9
+ assertTrue(parseMapPNG(bitmap, 160, 100, 12).isFound()); // GC2327G
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 136, 32, 12).getType()); // GC2JVEH
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 208, 164, 12).getType()); // GC1NN15
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 84, 244, 12).getType()); // GC3E5JP
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 172, 16, 12).getType()); // GC1Z581
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 104, 20, 12).getType()); // GC2MENX
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 144, 60, 12).getType()); // GC1V3MG
+ assertTrue(parseMapPNG(bitmap, 228, 56, 12).isFound()); // GC36WZN
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 144, 212, 12).getType()); // GCR9GB
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 180, 68, 12).getType()); // GC3JZ1K
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 228, 104, 12).getType()); // GCQ95T
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 84, 220, 12).getType()); // GCWTVM
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 200, 228, 12).getType()); // GC3CC1A
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 204, 56, 12).getType()); // GC1K0WX
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 244, 208, 12).getType()); // GC1JVXG
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 84, 128, 12).getType()); // GC2XQ6C
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 248, 164, 12).getType()); // GC3B1JK
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 232, 84, 12).getType()); // GC3AT8J
+ assertTrue(parseMapPNG(bitmap, 160, 88, 12).isFound()); // GC2MB4P
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 132, 20, 12).getType()); // GC2NW3F
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 56, 132, 12).getType()); // GC22ERA
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 28, 32, 12).getType()); // GC2EFFK
+ }
+
+ public void testParseExtraMap5() {
+ final Bitmap bitmap = getBitmap(R.raw.map5);
+
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 60, 32, 12).getType()); // GC31DNK
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 200, 120, 12).getType()); // GCP89K
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 144, 152, 12).getType()); // GC22AR8
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 164, 92, 12).getType()); // GC1MFB7
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 16, 212, 12).getType()); // GC12F2K
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 188, 12, 12).getType()); // GC24J14
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 36, 72, 12).getType()); // GC2J8MY
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 152, 140, 12).getType()); // GC1H9WQ
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 44, 40, 12).getType()); // GC31DNZ
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 8, 152, 12).getType()); // GC34YFB
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 200, 216, 12).getType()); // GC30MK5
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 84, 20, 12).getType()); // GC304YY
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 192, 236, 12).getType()); // GC1D6AC
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 220, 48, 12).getType()); // GC1HQ8Y
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 136, 176, 12).getType()); // GC310B7
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 132, 232, 12).getType()); // GC12CR5
+ assertTrue(parseMapPNG(bitmap, 240, 40, 12).isFound()); // GC24GW1
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 140, 116, 12).getType()); // GC2YYE7
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 124, 144, 12).getType()); // GC111RZ
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 48, 128, 12).getType()); // GC13A7V
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 136, 92, 12).getType()); // GC2BKW9
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 200, 184, 12).getType()); // GC30X0C
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 156, 200, 12).getType()); // GC17V4A
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 160, 120, 12).getType()); // GC2ZBWW
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 196, 36, 12).getType()); // GC14X25
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 192, 100, 12).getType()); // GC1HXAX
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 108, 168, 12).getType()); // GC3C043
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 232, 28, 12).getType()); // GC1TEAR
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 200, 204, 12).getType()); // GC3AKFV
+ assertTrue(parseMapPNG(bitmap, 228, 28, 12).isFound()); // GC2NMPR
+ //assertEquals(CacheType.VIRTUAL, parseMapPNG(bitmap, 232, 252, 12).getType()); // GC1AH0N - False detection
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 220, 188, 12).getType()); // GC1ZXDK
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 168, 212, 12).getType()); // GC3A919
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 152, 176, 12).getType()); // GC196WN
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 144, 180, 12).getType()); // GC12RE5
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 176, 116, 12).getType()); // GC1DY2M
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 44, 212, 12).getType()); // GC3MRNT
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 220, 36, 12).getType()); // GC3CWZD
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 48, 160, 12).getType()); // GC1A8E3
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 8, 252, 12).getType()); // GC10W6W
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 60, 92, 12).getType()); // GC2D9DD
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 96, 164, 12).getType()); // GC1Z4QX
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 220, 252, 12).getType()); // GCNEGK
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 32, 188, 12).getType()); // GC10916
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 204, 224, 12).getType()); // GC1CA2Y
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 120, 236, 12).getType()); // GC11B3J
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 248, 24, 12).getType()); // GCKX8C
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 128, 152, 12).getType()); // GC2V6AA
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 196, 48, 12).getType()); // GC2YG95
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 48, 64, 12).getType()); // GCHGR8
+ assertEquals(CacheType.EVENT, parseMapPNG(bitmap, 188, 96, 12).getType()); // GC3KBPK
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 208, 140, 12).getType()); // GC1C9B0
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 164, 100, 12).getType()); // GC29JGA
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 156, 28, 12).getType()); // GCN690
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 232, 20, 12).getType()); // GC18Z53
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 220, 152, 12).getType()); // GC18RB6
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 200, 248, 12).getType()); // GC2378H
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 248, 244, 12).getType()); // GCV8QA
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 12, 232, 12).getType()); // GC2MXDG
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 48, 248, 12).getType()); // GCTHJR
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 216, 200, 12).getType()); // GC1EPM5
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 232, 60, 12).getType()); // GC2N0PB
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 88, 56, 12).getType()); // GC1ZWNX
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 248, 56, 12).getType()); // GC1N11P
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 100, 180, 12).getType()); // GCM6AE
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 220, 124, 12).getType()); // GC2A1RQ
+ assertTrue(parseMapPNG(bitmap, 212, 4, 12).isFound()); // GC1TVKE
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 28, 212, 12).getType()); // GC2A1RR
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 128, 84, 12).getType()); // GC16AWC
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 220, 16, 12).getType()); // GC282V9
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 112, 240, 12).getType()); // GC18VT5
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 80, 248, 12).getType()); // GC10YEK
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 224, 228, 12).getType()); // GC1EA70
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 232, 244, 12).getType()); // GC14PNY
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 108, 32, 12).getType()); // GC2MMPN
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 144, 188, 12).getType()); // GC1CCF4
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 228, 208, 12).getType()); // GCV8C2
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 104, 252, 12).getType()); // GCTRPF
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 176, 92, 12).getType()); // GCRF8G
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 120, 140, 12).getType()); // GC210B9
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 204, 240, 12).getType()); // GC16NTW
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 192, 224, 12).getType()); // GC2PTVN
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 76, 116, 12).getType()); // GC1RPG0
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 144, 200, 12).getType()); // GC1FZ4T
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 172, 36, 12).getType()); // GC1ZYG8
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 248, 196, 12).getType()); // GC17FJQ
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 88, 140, 12).getType()); // GC1KWK0
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 168, 196, 12).getType()); // GC17MNG
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 20, 252, 12).getType()); // GC13M6V
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 120, 172, 12).getType()); // GC3B30A
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 104, 92, 12).getType()); // GC2GY9D
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 128, 120, 12).getType()); // GC2Y90M
+ assertTrue(parseMapPNG(bitmap, 204, 40, 12).isFound()); // GC1BZ6P
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 56, 76, 12).getType()); // GC10K7X
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 196, 108, 12).getType()); // GC1F0R5
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 120, 196, 12).getType()); // GC1KQQW
+ }
+
+ public void testParseExtraMap11() {
+ final Bitmap bitmap = getBitmap(R.raw.map11);
+ assertEquals(CacheType.EVENT, parseMapPNG(bitmap, 132, 16, 11).getType());
+ assertEquals(CacheType.MULTI, parseMapPNG(bitmap, 104, 48, 11).getType());
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 128, 124, 11).getType());
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 228, 8, 11).getType());
+ assertEquals(CacheType.TRADITIONAL, parseMapPNG(bitmap, 160, 156, 11).getType());
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 208, 176, 11).getType());
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 252, 24, 11).getType());
+ assertEquals(CacheType.MYSTERY, parseMapPNG(bitmap, 216, 96, 11).getType());
+ assertEquals(CacheType.EARTH, parseMapPNG(bitmap, 24, 212, 11).getType());
+ }
+
}