Shumate.DataSourceRequest

g GObject.Object GObject.Object Shumate.DataSourceRequest Shumate.DataSourceRequest GObject.Object->Shumate.DataSourceRequest

Subclasses:

None

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

new (x, y, zoom_level)

complete ()

emit_data (data, complete)

emit_error (error)

get_data ()

get_error ()

get_x ()

get_y ()

get_zoom_level ()

is_completed ()

Virtual Methods

Inherited:

GObject.Object (7)

Properties

Name

Type

Flags

Short Description

completed

bool

r/en

completed

data

GLib.Bytes

r/en

data

error

GLib.Error

r/en

error

x

int

r/w/co/en

x

y

int

r/w/co/en

y

zoom-level

int

r/w/co/en

zoom-level

Signals

Inherited:

GObject.Object (1)

Fields

Inherited:

GObject.Object (1)

Name

Type

Access

Description

parent_instance

GObject.Object

r

Class Details

class Shumate.DataSourceRequest(**kwargs)
Bases:

GObject.Object

Abstract:

No

Structure:

Shumate.DataSourceRequestClass

Represents a request to a [class`DataSource`] for a tile.

Data sources can return a tile multiple times. For example, a [class`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, [method`DataSource`.start_request] is available, which returns a [class`DataSourceRequest`] whose properties, [property`DataSourceRequest`:py:data::data<Shumate.DataSourceRequest.props.data>] and [property`DataSourceRequest`:py:data::error<Shumate.DataSourceRequest.props.error>], update as data becomes available. The [signal`GObject`.Object::notify] signal can be used to watch for these changes. When the request is done and no more data will be returned, [property`DataSourceRequest`:py:data::completed<Shumate.DataSourceRequest.props.completed>] is set to True.

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

New in version 1.1.

classmethod new(x, y, zoom_level)
Parameters:
  • x (int) – X coordinate of the requested tile

  • y (int) – Y coordinate of the requested tile

  • zoom_level (int) – Zoom level of the requested tile

Returns:

a new [class`DataSourceRequest`]

Return type:

Shumate.DataSourceRequest

Creates a new [class`DataSourceRequest`].

Only implementations of [vfunc`DataSource`.start_request] should need to construct a new request object.

New in version 1.1.

complete()

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 [method`DataSourceRequest`.emit_error] instead, which will automatically complete the request.

New in version 1.1.

emit_data(data, complete)
Parameters:

Emits tile data as a response to the request. This sets the [property`DataSourceRequest`:py:data::data<Shumate.DataSourceRequest.props.data>] property.

If complete is True, then [property`DataSourceRequest`:py:data::completed<Shumate.DataSourceRequest.props.completed>] is set to True as well.

New in version 1.1.

emit_error(error)
Parameters:

error (GLib.Error) – an error

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 [property`DataSourceRequest`:py:data::data<Shumate.DataSourceRequest.props.data>] was previously set, it will be cleared.

New in version 1.1.

get_data()
Returns:

The latest data, if any.

Return type:

GLib.Bytes or None

Gets the latest data from the request.

New in version 1.1.

get_error()
Returns:

The latest error, if any.

Return type:

GLib.Error or None

Gets the latest error from the request.

New in version 1.1.

get_x()
Returns:

the X coordinate

Return type:

int

Gets the X coordinate of the requested tile.

New in version 1.1.

get_y()
Returns:

the Y coordinate

Return type:

int

Gets the Y coordinate of the requested tile.

New in version 1.1.

get_zoom_level()
Returns:

the zoom level

Return type:

int

Gets the zoom level of the requested tile.

New in version 1.1.

is_completed()
Returns:

True if the request is completed, otherwise False

Return type:

bool

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

New in version 1.1.

Property Details

Shumate.DataSourceRequest.props.completed
Name:

completed

Type:

bool

Default Value:

False

Flags:

READABLE, EXPLICIT_NOTIFY

True if the request has been completed, otherwise False. A completed request will not receive further updates to either [property`DataSourceRequest`:py:data::data<Shumate.DataSourceRequest.props.data>] or [property`DataSourceRequest`:py:data::error<Shumate.DataSourceRequest.props.error>].

New in version 1.1.

Shumate.DataSourceRequest.props.data
Name:

data

Type:

GLib.Bytes

Default Value:

None

Flags:

READABLE, EXPLICIT_NOTIFY

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

New in version 1.1.

Shumate.DataSourceRequest.props.error
Name:

error

Type:

GLib.Error

Default Value:

None

Flags:

READABLE, EXPLICIT_NOTIFY

The error that occurred during the request, if any.

New in version 1.1.

Shumate.DataSourceRequest.props.x
Name:

x

Type:

int

Default Value:

0

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY, EXPLICIT_NOTIFY

The X coordinate of the requested tile.

New in version 1.1.

Shumate.DataSourceRequest.props.y
Name:

y

Type:

int

Default Value:

0

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY, EXPLICIT_NOTIFY

The Y coordinate of the requested tile.

New in version 1.1.

Shumate.DataSourceRequest.props.zoom_level
Name:

zoom-level

Type:

int

Default Value:

0

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY, EXPLICIT_NOTIFY

The zoom level of the requested tile.

New in version 1.1.