def get_collected_coordinates(self, format, include_unknown = True, htmlcallback = lambda x: x, shorten_callback = lambda x: x): cache = self cache.display_text = "Geocache: %s" % cache.get_latlon(format) cache.comment = "Original coordinate given in the cache description." clist = {0: cache} i = 1 # waypoints for w in self.get_waypoints(): if not (w['lat'] == -1 and w['lon'] == -1): coord = geo.Coordinate(w['lat'], w['lon'], w['name']) coord.comment = htmlcallback(w['comment']) latlon = coord.get_latlon(format) elif not include_unknown: continue else: coord = geo.Coordinate(None, None, w['name']) coord.comment = htmlcallback(w['comment']) latlon = '???' coord.display_text = "%s - %s - %s\n%s" % (w['name'], latlon, w['id'], shorten_callback(htmlcallback(w['comment']))) clist[i] = coord i += 1 # parsed from notes for coord in geo.search_coordinates(self.notes): coord.display_text = "manually entered: %s" % coord.get_latlon(format) coord.comment = "This coordinate was manually entered in the notes field." clist[i] = coord i += 1 # cache calc if self.calc != None: for coord in self.calc.get_solutions(): if coord == False: continue coord.display_text = "calculated: %s = %s" % (coord.name, coord.get_latlon(format)) coord.comment = "This coordinate was calculated:\n%s = %s" % (coord.name, coord.get_latlon(format)) clist[i] = coord i += 1 for coord in self.calc.get_plain_coordinates(): if coord == False: continue coord.display_text = "found: %s" % (coord.get_latlon(format)) coord.comment = "This coordinate was found in the description." clist[i] = coord i += 1 return clist
def get_collected_coordinates(self, format, include_unknown = True, htmlcallback = lambda x: x, shorten_callback = lambda x: x, skip_calc = False): cache = self cache.display_text = "Geocache: %s" % cache.get_latlon(format) cache.comment = "Original coordinate given in the cache description." cache.user_coordinate_id = None clist = {0: cache} check_double = [] i = 1 # waypoints for w in self.get_waypoints(): if not (w['lat'] == -1 and w['lon'] == -1): coord = geo.Coordinate(w['lat'], w['lon'], w['id']) coord.comment = htmlcallback(w['comment']) latlon = coord.get_latlon(format) elif not include_unknown: continue else: coord = geo.Coordinate(None, None, w['name']) coord.comment = htmlcallback(w['comment']) latlon = '???' check_double.append(latlon) coord.user_coordinate_id = None coord.title = w['name'] coord.display_text = "%s - %s - %s\n%s" % (w['name'], latlon, w['id'], shorten_callback(htmlcallback(w['comment']))) clist[i] = coord i += 1 logger.debug("Added coordinate, name=%r, title=%r, user_coordinate_id=%r" % (coord.name, coord.title, coord.user_coordinate_id)) # read from local user_coordinates for id, local in self.get_user_coordinates(self.USER_TYPE_COORDINATE): coord = geo.Coordinate(local['value'][0], local['value'][1], name=local['name']) text = local['name'] if local['name'] != '' else 'manually entered' coord.display_text = "%s: %s" % (text, coord.get_latlon(format)) coord.title = "Entered" coord.comment = "This coordinate was manually entered." coord.user_coordinate_id = id clist[i] = coord i += 1 logger.debug("Added coordinate, name=%r, title=%r, user_coordinate_id=%r" % (coord.name, coord.title, coord.user_coordinate_id)) # cache calc if self.calc != None and not skip_calc: logger.debug("Evaluating cache calc coordinates") for coord, source in self.calc.get_solutions(): if coord == False: continue if type(source) == int: source_string = self.get_user_coordinate(source)['name'] coord.user_coordinate_id = source else: source_string = source coord.user_coordinate_id = None coord.title = "Solution" coord.display_text = "%s: %s = %s" % (source_string, coord.name, coord.get_latlon(format)) coord.comment = "From %s:\n%s = %s" % (source_string, coord.name, coord.get_latlon(format)) clist[i] = coord i += 1 logger.debug("Added coordinate, name=%r, title=%r, user_coordinate_id=%r" % (coord.name, coord.title, coord.user_coordinate_id)) # cache calc - plain coordinates for coord, source in self.calc.get_plain_coordinates(): if coord == False: logger.debug("Coordinate is false: %r" % coord) continue if type(source) == int: source_string = self.get_user_coordinate(source)['name'] coord.user_coordinate_id = source else: source_string = source coord.user_coordinate_id = None latlon = coord.get_latlon(format) if latlon in check_double: logger.debug("Coordinate is already in the list: %r" % coord) continue coord.title = "From Text" coord.display_text = "%s: %s" % (source_string, latlon) coord.comment = "Found in %s." % source_string clist[i] = coord i += 1 logger.debug("Added coordinate, name=%r, title=%r, user_coordinate_id=%r" % (coord.name, coord.title, coord.user_coordinate_id)) # parsed from notes for coord in geo.search_coordinates(self.notes): coord.title = "From Notes" coord.display_text = "from notes: %s" % coord.get_latlon(format) coord.comment = "This coordinate was manually entered in the notes field." coord.user_coordinate_id = None clist[i] = coord i += 1 logger.debug("Added coordinate, name=%r, title=%r, user_coordinate_id=%r" % (coord.name, coord.title, coord.user_coordinate_id)) return clist