DataSourceRequest

Added in version 1.1.

class DataSourceRequest(**properties: Any)

Superclasses: Object

Represents a request to a DataSource for a tile.

Data sources can return a tile multiple times. For example, a TileDownloader may return cached data first, then later return data from a network service when it arrives. This allows the map to be rendered as quickly as possible without waiting for the network unnecessarily.

Conventional async/finish method pairs don’t support multiple returns. Instead, start_request is available, which returns a DataSourceRequest whose properties, data and error, update as data becomes available. The notify signal can be used to watch for these changes. When the request is done and no more data will be returned, completed is set to True.

DataSource implementations can use a subclass of DataSourceRequest, but the base class should be sufficient in most cases.

Constructors

class DataSourceRequest
classmethod new(x: int, y: int, zoom_level: int) DataSourceRequest

Creates a new DataSourceRequest.

Only implementations of start_request should need to construct a new request object.

Added in version 1.1.

Parameters:
  • x – X coordinate of the requested tile

  • y – Y coordinate of the requested tile

  • zoom_level – Zoom level of the requested tile

Methods

class DataSourceRequest
complete() None

Marks the request as complete. No more data or errors may be emitted.

This can only be called if data has been emitted. If there is no data, use emit_error instead, which will automatically complete the request.

Added in version 1.1.

emit_data(data: Bytes, complete: bool) None

Emits tile data as a response to the request. This sets the data property.

If complete is True, then completed is set to True as well.

Added in version 1.1.

Parameters:
  • data – the data to emit

  • completeTrue to also complete the request, False otherwise

emit_error(error: GError) None

Emits a fatal error in response to the request. This completes the request, so no more data or errors can be emitted after this. Non-fatal errors should not be reported.

If data was previously set, it will be cleared.

Added in version 1.1.

Parameters:

error – an error

get_data() Bytes | None

Gets the latest data from the request.

Added in version 1.1.

get_error() GError | None

Gets the latest error from the request.

Added in version 1.1.

get_x() int

Gets the X coordinate of the requested tile.

Added in version 1.1.

get_y() int

Gets the Y coordinate of the requested tile.

Added in version 1.1.

get_zoom_level() int

Gets the zoom level of the requested tile.

Added in version 1.1.

is_completed() bool

Gets whether the request has been completed. Completed requests will not receive new data or errors.

Added in version 1.1.

Properties

class DataSourceRequest
props.completed: bool

True if the request has been completed, otherwise False. A completed request will not receive further updates to either data or error.

Added in version 1.1.

props.data: Bytes

The most recent data for the tile, if available. If an error is emitted, this will be set to None.

Added in version 1.1.

props.error: GError

The error that occurred during the request, if any.

Added in version 1.1.

props.x: int

The X coordinate of the requested tile.

Added in version 1.1.

props.y: int

The Y coordinate of the requested tile.

Added in version 1.1.

props.zoom_level: int

The zoom level of the requested tile.

Added in version 1.1.

Fields

class DataSourceRequest
parent_instance