@@ -97,37 +97,36 @@ class Cache(object):
9797 }
9898
9999 _possible_types = {
100- "Traditional Cache" ,
101- "Multi-Cache" ,
102- "Unknown Cache" ,
103- "Mystery Cache" ,
104- "Letterbox Hybrid" ,
105- "Event Cache" ,
106- "Mega-Event Cache" ,
107- "Giga-Event Cache" ,
108- "Earthcache" ,
109- "Cache In Trash Out Event" ,
110- "Webcam Cache" ,
111- "Virtual Cache" ,
112- "Wherigo Cache" ,
113- "Lost And Found Event Cache" ,
114- "Project Ape Cache" ,
115- "Groundspeak Hq" ,
116- "Gps Adventures Exhibit" ,
117- "Groundspeak Block Party" ,
118- "Locationless (Reverse) Cache" ,
100+ # key is cache image url, used for parsing: http://www.geocaching.com/images/WptTypes/[KEY].gif
101+ "2" : "Traditional Cache" ,
102+ "3" : "Multi-cache" ,
103+ "8" : "Mystery Cache" ,
104+ "__8" : "Unknown Cache" , # same as Mystery, key not used
105+ "5" : "Letterbox hybrid" ,
106+ "6" : "Event Cache" ,
107+ "mega" : "Mega-Event Cache" ,
108+ "giga" : "Giga-Event Cache" ,
109+ "earthcache" : "Earthcache" ,
110+ "13" : "Cache in Trash out Event" ,
111+ "11" : "Webcam Cache" ,
112+ "4" : "Virtual Cache" ,
113+ "1858" : "Wherigo Cache" ,
114+ "10Years_32" : "Lost and Found Event Cache" ,
115+ "ape_32" : "Project Ape Cache" ,
116+ "HQ_32" : "Groundspeak HQ" ,
117+ "1304" : "GPS Adventures Exhibit" ,
118+ "4738" : "Groundspeak Block Party" ,
119+ "12" : "Locationless (Reverse) Cache" ,
119120 }
120121
121122 _possible_sizes = {
122- "nano" ,
123- "micro" ,
124- "small" ,
125- "regular" ,
126- "large" ,
127- "very large" ,
128- "not chosen" ,
129- "virtual" ,
130- "other"
123+ "micro" : "micro" ,
124+ "small" : "small" ,
125+ "regular" : "regular" ,
126+ "large" : "large" ,
127+ "not_chosen" : "not chosen" ,
128+ "virtual" : "virtual" ,
129+ "other" : "other" ,
131130 }
132131
133132 def __init__ (self , wp , geocaching , * , name = None , cache_type = None , location = None , state = None ,
@@ -225,11 +224,14 @@ def cache_type(self):
225224
226225 @cache_type .setter
227226 def cache_type (self , cache_type ):
228- cache_type = cache_type .strip (). title ()
227+ cache_type = cache_type .strip ()
229228 cache_type = cache_type .replace ("Geocache" , "Cache" )
230- if cache_type not in self ._possible_types :
229+ if cache_type in self ._possible_types .values (): # try to search in values
230+ self ._cache_type = cache_type
231+ elif cache_type in self ._possible_types .keys (): # not in values => it must be a key
232+ self ._cache_type = self ._possible_types [cache_type ]
233+ else :
231234 raise ValueError ("Cache type '{}' is not possible." .format (cache_type ))
232- self ._cache_type = cache_type
233235
234236 @property
235237 @lazy_loaded
@@ -257,9 +259,12 @@ def size(self):
257259 @size .setter
258260 def size (self , size ):
259261 size = size .strip ().lower ()
260- if size not in self ._possible_sizes :
262+ if size in self ._possible_sizes .values (): # try to search in values
263+ self ._size = size
264+ elif size in self ._possible_sizes .keys (): # not in values => it must be a key
265+ self ._size = self ._possible_sizes [size ]
266+ else :
261267 raise ValueError ("Size '{}' is not possible." .format (size ))
262- self ._size = size
263268
264269 @property
265270 @lazy_loaded
@@ -372,3 +377,7 @@ def pm_only(self):
372377 @pm_only .setter
373378 def pm_only (self , pm_only ):
374379 self ._pm_only = bool (pm_only )
380+
381+ def inside_area (self , area ):
382+ """Calculate if geocache is inside given area"""
383+ return area .inside_area (self .location )
0 commit comments