Shumate.DataSourceRequest¶
- Subclasses:
None
Methods¶
- Inherited:
- Structs:
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
Properties¶
Name |
Type |
Flags |
Short Description |
---|---|---|---|
r/en |
completed |
||
r/en |
data |
||
r/en |
error |
||
r/w/co/en |
x |
||
r/w/co/en |
y |
||
r/w/co/en |
zoom-level |
Signals¶
- Inherited:
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
---|---|---|---|
parent_instance |
r |
Class Details¶
- class Shumate.DataSourceRequest(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
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:
- Returns:
a new [class`DataSourceRequest`]
- Return type:
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:
data (
GLib.Bytes
) – the data to emitcomplete (
bool
) –True
to also complete the request,False
otherwise
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 toTrue
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
orNone
Gets the latest data from the request.
New in version 1.1.
- get_error()¶
- Returns:
The latest error, if any.
- Return type:
GLib.Error
orNone
Gets the latest error from the request.
New in version 1.1.
- get_x()¶
- Returns:
the X coordinate
- Return type:
Gets the X coordinate of the requested tile.
New in version 1.1.
- get_y()¶
- Returns:
the Y coordinate
- Return type:
Gets the Y coordinate of the requested tile.
New in version 1.1.
- get_zoom_level()¶
- Returns:
the zoom level
- Return type:
Gets the zoom level of the requested tile.
New in version 1.1.
Property Details¶
- Shumate.DataSourceRequest.props.completed¶
- Name:
completed
- Type:
- Default Value:
- Flags:
True
if the request has been completed, otherwiseFalse
. 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:
- Default Value:
- Flags:
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:
- Default Value:
- Flags:
The error that occurred during the request, if any.
New in version 1.1.
- Shumate.DataSourceRequest.props.x¶
- Name:
x
- Type:
- Default Value:
0
- Flags:
The X coordinate of the requested tile.
New in version 1.1.
- Shumate.DataSourceRequest.props.y¶
- Name:
y
- Type:
- Default Value:
0
- Flags:
The Y coordinate of the requested tile.
New in version 1.1.
- Shumate.DataSourceRequest.props.zoom_level¶
- Name:
zoom-level
- Type:
- Default Value:
0
- Flags:
The zoom level of the requested tile.
New in version 1.1.