def load_gpx_from_file(self, uri): """Parse GPX data, drawing each GPS track segment on the map.""" start_time = clock() gpx = get_trackfile(uri) self.status_message(_('%d points loaded in %.2fs.') % (len(gpx.tracks), clock() - start_time), True) if len(gpx.tracks) < 2: return metadata.alpha = min(metadata.alpha, gpx.alpha) metadata.omega = max(metadata.omega, gpx.omega) map_view.emit('realize') map_view.set_zoom_level(map_view.get_max_zoom_level()) bounds = Champlain.BoundingBox.new() for trackfile in known_trackfiles.values(): for polygon in trackfile.polygons: bounds.compose(polygon.get_bounding_box()) map_view.ensure_visible(bounds, False) for camera in known_cameras.values(): camera.set_found_timezone(gpx.timezone)
def tearDown(self): """Undo whatever mess the testsuite created.""" clear_all_gpx() for camera in known_cameras.values(): camera.photos.clear() for photo in photos.values(): gui.labels.layer.remove_marker(photo.label) photos.clear() modified.clear() selected.clear() gui.liststore.clear() system('git checkout demo') for key in app.gst.list_keys(): app.gst.reset(key)
def test_camera_offsets(self): """Make sure that camera offsets function correctly.""" gui.open_files([DEMOFILES[1]]) spinbutton = known_cameras.values()[0].offset photo = photos.values()[0] for delta in (1, 10, 100, 600, -711): start = [photo.timestamp, spinbutton.get_value(), photo.camera.gst.get_int('offset')] spinbutton.set_value(start[1] + delta) end = [photo.timestamp, spinbutton.get_value(), photo.camera.gst.get_int('offset')] # Check that the photo timestamp, spinbutton value, and gsettings # key have all changed by precisely the same amount. for i, num in enumerate(start): self.assertEqual(end[i] - num, delta)
def open_files(self, files): """Attempt to load all of the specified files.""" self.progressbar.show() invalid, total = [], len(files) for i, name in enumerate(files, 1): self.redraw_interface(i / total, basename(name)) try: try: self.load_img_from_file(name) except IOError: self.load_gpx_from_file(name) except IOError: invalid.append(basename(name)) if len(invalid) > 0: self.status_message(_('Could not open: ') + ', '.join(invalid)) # Ensure camera has found correct timezone regardless of the order # that the GPX/KML files were loaded in. for camera in known_cameras.values(): camera.set_timezone() self.progressbar.hide() self.labels.selection.emit('changed') map_view.emit('animation-completed')