def load_from_file(uri): """Determine the correct subclass to instantiate. Also time everything and report how long it took. Raises IOError if the file extension is unknown, or no track points were found. """ start_time = clock() try: gpx = globals()[uri[-3:].upper() + 'File'](uri) except KeyError: raise IOError Widgets.status_message(_('%d points loaded in %.2fs.') % (len(gpx.tracks), clock() - start_time), True) if len(gpx.tracks) < 2: return TrackFile.instances.add(gpx) MapView.emit('realize') MapView.set_zoom_level(MapView.get_max_zoom_level()) MapView.ensure_visible(TrackFile.get_bounding_box(), False) TrackFile.update_range() Camera.set_all_found_timezone(gpx.start.geotimezone)
def search_completed(self, entry, model, itr): """Go to the selected location.""" self.last_search = itr.copy() MapView.emit('realize') MapView.set_zoom_level(MapView.get_max_zoom_level()) Widgets.redraw_interface() MapView.center_on(*model.get(itr, LATITUDE, LONGITUDE)) MapView.set_zoom_level(11)