Пример #1
0
    def load_from_file(uri):
        """Coordinates instantiation of various classes.

        Ensures that related Photograph, Camera, CameraView, and Label are all
        instantiated together.
        """
        photo = Photograph(uri)

        Label(photo)

        photo.read()

        Widgets.empty_camera_list.hide()

        camera_id, camera_name = Camera.generate_id(photo.camera_info)
        camera = Camera(camera_id)
        camera.add_photo(photo)

        CameraView(camera, camera_name)

        # If the user has selected the lookup method, then the timestamp
        # was probably calculated incorrectly the first time (before the
        # timezone was discovered). So call it again to get the correct value.
        if camera.timezone_method == 'lookup':
            photo.calculate_timestamp(camera.offset)

        Widgets.button_sensitivity()

        return photo
Пример #2
0
    def load_from_file(uri):
        """Determine the correct subclass to instantiate.

        Also time everything and report how long it took. Raises OSError 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 OSError

        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)
Пример #3
0
    def load_from_file(uri):
        """Determine the correct subclass to instantiate.

        Also time everything and report how long it took. Raises OSError 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 OSError

        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)
Пример #4
0
    def load_from_file(uri):
        """Coordinates instantiation of various classes.

        Ensures that related Photograph, Camera, CameraView, and Label are all
        instantiated together.
        """
        photo = Photograph(uri)

        Label(photo)

        photo.read()

        Widgets.empty_camera_list.hide()

        camera_id, camera_name = Camera.generate_id(photo.camera_info)
        camera = Camera(camera_id)
        camera.add_photo(photo)

        CameraView(camera, camera_name)

        # If the user has selected the lookup method, then the timestamp
        # was probably calculated incorrectly the first time (before the
        # timezone was discovered). So call it again to get the correct value.
        if camera.timezone_method == 'lookup':
            photo.calculate_timestamp(camera.offset)

        Widgets.button_sensitivity()

        return photo