Async Tileset

The async Tileset module provides functionality for working with tilesets.

class AsyncTileset(api, uuid, data={})[source]

Bases: AsyncBase

Parameters:
BASE_ENDPOINT: str = 'tilesets/'
__init__(api, uuid, data={})[source]

Constructs all the necessary attributes for the Tilesets object.

Parameters:
  • api (AsyncGeoboxClient) – The AsyncGeoboxClient instance for making requests.

  • uuid (str) – The UUID of the tileset.

  • data (Dict, optional) – The data of the tileset.

async classmethod create_tileset(api, name, layers, display_name=None, description=None, min_zoom=None, max_zoom=None, user_id=None)[source]

[async] Create a new tileset.

Parameters:
  • api (AsyncGeoboxClient) – The AsyncGeoboxClient instance for making requests.

  • name (str) – The name of the tileset.

  • layers (List[VectorLayer | VectorLayerView]) – list of vectorlayer and view objects to add to tileset.

  • display_name (str, optional) – The display name of the tileset.

  • description (str, optional) – The description of the tileset.

  • min_zoom (int, optional) – The minimum zoom level of the tileset.

  • max_zoom (int, optional) – The maximum zoom level of the tileset.

  • user_id (int, optional) – Specific user. privileges required.

Returns:

The created tileset instance.

Return type:

AsyncTileset

Example

>>> from geobox.aio import AsyncGeoboxClient
>>> from geobox.aio.tileset import AsyncTileset
>>> async with AsyncGeoboxClient() as client:
>>>     layer = await client.get_vector(uuid="12345678-1234-5678-1234-567812345678")
>>>     view = await client.get_view(uuid="12345678-1234-5678-1234-567812345678")
>>>     tileset = await AsyncTileset.create_tileset(client,
...                                             name="your_tileset_name",
...                                             display_name="Your Tileset",
...                                             description="Your description",
...                                             min_zoom=0,
...                                             max_zoom=14,
...                                             layers=[layer, view])
or
>>>     tileset = await client.create_tileset(name="your_tileset_name",
...                                             display_name="Your Tileset",
...                                             description="Your description",
...                                             min_zoom=0,
...                                             max_zoom=14,
...                                             layers=[layer, view])
async classmethod get_tilesets(api, **kwargs)[source]

[async] Retrieves a list of tilesets.

Parameters:

api (AsyncGeoboxClient) – The AsyncGeoboxClient instance for making requests.

Keyword Arguments:
  • q (str) – query filter based on OGC CQL standard. e.g. “field1 LIKE ‘%GIS%’ AND created_at > ‘2021-01-01’”

  • search (str) – search term for keyword-based searching among search_fields or all textual fields if search_fields does not have value. NOTE: if q param is defined this param will be ignored.

  • search_fields (str) – comma separated list of fields for searching.

  • order_by (str) – comma separated list of fields for sorting results [field1 A|D, field2 A|D, …]. e.g. name A, type D. NOTE: “A” denotes ascending order and “D” denotes descending order.

  • return_count (bool) – if True, returns the total number of tilesets matching the query. default is False.

  • skip (int) – number of records to skip. default is 0.

  • limit (int) – number of records to return. default is 10.

  • user_id (int) – Specific user. privileges required.

  • shared (bool) – Whether to return shared tilesets. default is False.

Returns:

A list of Tileset instances or the total number of tilesets

Return type:

List[AsyncTileset] | int

Example

>>> from geobox.aio import AsyncGeoboxClient
>>> from geobox.aio.tileset import AsyncTileset
>>> async with AsyncGeoboxClient() as client:
>>>     tilesets = await AsyncTileset.get_tilesets(client,
...         q="name LIKE '%your_tileset_name%'",
...         order_by="name A",
...         skip=0,
...         limit=10,
...     )
or
>>>     tilesets = await client.get_tilesets(q="name LIKE '%your_tileset_name%'",
...         order_by="name A",
...         skip=0,
...         limit=10,
...     )
async classmethod get_tilesets_by_ids(api, ids, user_id=None)[source]

[async] Retrieves a list of tilesets by their IDs.

Parameters:
  • api (AsyncGeoboxClient) – The AsyncGeoboxClient instance for making requests.

  • ids (List[str]) – The list of tileset IDs.

  • user_id (int, optional) – Specific user. privileges required.

Returns:

A list of Tileset instances.

Return type:

List[AsyncTileset]

Example

>>> from geobox.aio import AsyncGeoboxClient
>>> from geobox.aio.tileset import AsyncTileset
>>> async with AsyncGeoboxClient() as client:
>>>     tilesets = await AsyncTileset.get_tilesets_by_ids(client, ids=['123', '456'])
or
>>>     tilesets = await client.get_tilesets_by_ids(ids=['123', '456'])
async classmethod get_tileset(api, uuid)[source]

[async] Retrieves a tileset by its UUID.

Parameters:
  • api (AsyncGeoboxClient) – The AsyncGeoboxClient instance for making requests.

  • uuid (str) – The UUID of the tileset.

Returns:

The retrieved tileset instance.

Return type:

AsyncTileset

Example

>>> from geobox.aio import AsyncGeoboxClient
>>> from geobox.aio.tileset import AsyncTileset
>>> async with AsyncGeoboxClient() as client:
>>>     tileset = await AsyncTileset.get_tileset(client, uuid="12345678-1234-5678-1234-567812345678")
or
>>>     tileset = await client.get_tileset(uuid="12345678-1234-5678-1234-567812345678")
async classmethod get_tileset_by_name(api, name, user_id=None)[source]

[async] Get a tileset by name

Parameters:
  • api (AsyncGeoboxClient) – The AsyncGeoboxClient instance for making requests.

  • name (str) – the name of the tileset to get

  • user_id (int, optional) – specific user. privileges required.

Returns:

returns the tileset if a tileset matches the given name, else None

Return type:

AsyncTileset | None

Example

>>> from geobox.aio import AsyncGeoboxClient
>>> from geobox.aio.tileset import AsyncTileset
>>> async with AsyncGeoboxClient() as client:
>>>     tileset = await VectorLayer.get_tileset_by_name(client, name='test')
or
>>>     tileset = await client.get_tileset_by_name(name='test')
async update(**kwargs)[source]

[async] Updates the properties of the tileset.

Keyword Arguments:
  • name (str) – The new name of the tileset.

  • display_name (str) – The new display name of the tileset.

  • description (str) – The new description of the tileset.

  • min_zoom (int) – The new minimum zoom level of the tileset.

  • max_zoom (int) – The new maximum zoom level of the tileset.

Returns:

None

Return type:

None

Example

>>> from geobox.aio import AsyncGeoboxClient
>>> from geobox.aio.tileset import AsyncTileset
>>> async with AsyncGeoboxClient() as client:
>>>     tileset = await AsyncTileset.get_tileset(client, uuid="12345678-1234-5678-1234-567812345678")
>>>     await tileset.update_tileset(
...         name="new_name",
...         display_name="New Display Name",
...         description="New description",
...         min_zoom=0,
...         max_zoom=14
...     )
async delete()[source]

[async] Deletes the tileset.

Raises:

ValueError – if the tileset uuid is not set.

Returns:

None

Return type:

None

Example

>>> from geobox.aio import AsyncGeoboxClient
>>> from geobox.aio.tileset import AsyncTileset
>>> async with AsyncGeoboxClient() as client:
>>>     tileset = await AsyncTileset.get_tileset(client, uuid="12345678-1234-5678-1234-567812345678")
>>>     await tileset.delete()
async get_layers(**kwargs)[source]

[async] Retrieves the layers of the tileset with optional parameters.

Keyword Arguments:
  • q (str) – query filter based on OGC CQL standard. e.g. “field1 LIKE ‘%GIS%’ AND created_at > ‘2021-01-01’”

  • search (str) – search term for keyword-based searching among search_fields or all textual fields if search_fields does not have value. NOTE: if q param is defined this param will be ignored.

  • search_fields (str) – comma separated list of fields for searching.

  • order_by (str) – comma separated list of fields for sorting results [field1 A|D, field2 A|D, …]. e.g. name A, type D. NOTE: “A” denotes ascending order and “D” denotes descending order.

  • return_count (bool) – if True, returns the total number of layers matching the query. default is False.

  • skip (int) – number of records to skip. default is 0.

  • limit (int) – number of records to return. default is 10.

  • user_id (int) – specific user. privileges required.

  • shared (bool) – if True, returns only the layers that has been shared with you. default is False.

Returns:

A list of VectorLayer or VectorLayerView instances.

Return type:

AsyncVectorLayer | AsyncVectorLayerView

Example

>>> from geobox.aio import AsyncGeoboxClient
>>> from geobox.aio.tileset import AsyncTileset
>>> async with AsyncGeoboxClient() as client:
>>>     tileset = await AsyncTileset.get_tileset(client, uuid="12345678-1234-5678-1234-567812345678")
>>>     layers = await tileset.get_layers()
async add_layer(layer)[source]

[async] Adds a layer to the tileset.

Parameters:

layer (AsyncVectorLayer | AsyncVectorLayerView) – the layer object to add to the tileset

Returns:

None

Raises:

ValueError – if the layer input is not a ‘VectorLayer’ or ‘VetorLayerview’ object

Return type:

None

Example

>>> from geobox.aio import AsyncGeoboxClient
>>> from geobox.aio.tileset import AsyncTileset
>>> async with AsyncGeoboxClient() as client:
>>>     tileset = await AsyncTileset.get_tileset(client, uuid="12345678-1234-5678-1234-567812345678")
>>>     layer = await client.get_vector(uuid="12345678-1234-5678-1234-567812345678")
>>>     await tileset.add_layer(layer)
async delete_layer(layer)[source]

[async] Deletes a layer from the tileset.

Parameters:

layer (AsyncVectorLayer | AsyncVectorLayerView) – the layer object to delete from the tileset

Returns:

None

Raises:

ValueError – if the layer input is not a ‘VectorLayer’ or ‘VetorLayerview’ object

Return type:

None

Example

>>> from geobox.aio import AsyncGeoboxClient
>>> from geobox.aio.tileset import AsyncTileset
>>> async with AsyncGeoboxClient() as client:
>>>     tileset = await AsyncTileset.get_tileset(client, uuid="12345678-1234-5678-1234-567812345678")
>>>     layer = await client.get_vector(uuid="12345678-1234-5678-1234-567812345678")
>>>     await tileset.delete_layer(layer)
async share(users)[source]

[async] Shares the file with specified users.

Parameters:

users (List[AsyncUser]) – The list of user IDs to share the file with.

Returns:

None

Return type:

None

Example

>>> from geobox.aio import AsyncGeoboxClient
>>> from geobox.aio.tileset import AsyncTileset
>>> async with AsyncGeoboxClient() as client:
>>>     tileset = await AsyncTileset.get_tileset(client, uuid="12345678-1234-5678-1234-567812345678")
>>>     users = await client.search_usesrs(search='John')
>>>     await tileset.share(users=users)
async unshare(users)[source]

[async] Unshares the file with specified users.

Parameters:

users (List[AsyncUser]) – The list of user IDs to unshare the file with.

Returns:

None

Return type:

None

Example

>>> from geobox.aio import AsyncGeoboxClient
>>> from geobox.aio.tileset import AsyncTileset
>>> async with AsyncGeoboxClient() as client:
>>>     tileset = await AsyncTileset.get_tileset(client, uuid="12345678-1234-5678-1234-567812345678")
>>>     users = await client.search_usesrs(search='John')
>>>     await tileset.unshare(users=users)
async get_shared_users(search=None, skip=0, limit=10)[source]

[async] Retrieves the list of users the file is shared with.

Parameters:
  • search (str, optional) – The search query.

  • skip (int, optional) – The number of users to skip.

  • limit (int, optional) – The maximum number of users to retrieve.

Returns:

The list of shared users.

Return type:

List[AsyncUser]

Example

>>> from geobox.aio import AsyncGeoboxClient
>>> from geobox.aio.tileset import AsyncTileset
>>> async with AsyncGeoboxClient() as client:
>>>     tileset = await AsyncTileset.get_tileset(client, uuid="12345678-1234-5678-1234-567812345678")
>>>     await tileset.get_shared_users(search='John', skip=0, limit=10)
async get_tile_json()[source]

[async] Retrieves the tile JSON configuration.

Returns:

The tile JSON configuration.

Return type:

Dict

Example

>>> from geobox.aio import AsyncGeoboxClient
>>> from geobox.aio.tileset import AsyncTileset
>>> async with AsyncGeoboxClient() as client:
>>>     tileset = await AsyncTileset.get_tileset(client, uuid="12345678-1234-5678-1234-567812345678")
>>>     await tileset.get_tile_json()
async update_tileset_extent()[source]

[async] Updates the extent of the tileset.

Returns:

The response from the API.

Return type:

Dict

Example

>>> from geobox.aio import AsyncGeoboxClient
>>> from geobox.aio.tileset import AsyncTileset
>>> async with AsyncGeoboxClient() as client:
>>>     tileset = await AsyncTileset.get_tileset(client, uuid="12345678-1234-5678-1234-567812345678")
>>>     await tileset.update_tileset_extent()
get_tile_pbf_url(x='{x}', y='{y}', z='{z}')[source]

Retrieves a tile from the tileset.

Parameters:
  • x (int, optional) – The x coordinate of the tile.

  • y (int, optioanl) – The y coordinate of the tile.

  • z (int, optional) – The zoom level of the tile.

Returns:

The url of the tile.

Return type:

str

Example

>>> from geobox.aio import AsyncGeoboxClient
>>> from geobox.aio.tileset import AsyncTileset
>>> async with AsyncGeoboxClient() as client:
>>>     tileset = await AsyncTileset.get_tileset(client, uuid="12345678-1234-5678-1234-567812345678")
>>>     await tileset.get_tile_tileset(x=1, y=1, z=1)
async seed_cache(from_zoom=0, to_zoom=14, extent=[], workers=1, user_id=0)[source]

[async] Seeds the cache of the tileset.

Parameters:
  • from_zoom (int, optional) – The starting zoom level.

  • to_zoom (int, optional) – The ending zoom level.

  • extent (list, optional) – The extent of the tileset.

  • workers (int, optional) – The number of workers to use.

  • user_id (int, optional) – The user ID.

Returns:

list of task objects.

Return type:

List[AsyncTask]

Raises:

ValueError – If the number of workers is not one of the following: 1, 2, 4, 8, 12, 16, 20, 24.

Example

>>> from geobox.aio import AsyncGeoboxClient
>>> from geobox.aio.tileset import AsyncTileset
>>> async with AsyncGeoboxClient() as client:
>>>     tileset = await AsyncTileset.get_tileset(client, uuid="12345678-1234-5678-1234-567812345678")
>>>     await tileset.seed_cache(from_zoom=0, to_zoom=14, extent=[], workers=1)
async update_cache(from_zoom, to_zoom, extents=None, user_id=0)[source]

[async] Updates the cache of the tileset.

Parameters:
  • from_zoom (int) – The starting zoom level.

  • to_zoom (int) – The ending zoom level.

  • extents (List[List[float]], optional) – The list of extents to update the cache for.

  • user_id (int, optional) – The user ID.

Returns:

list of task objects.

Return type:

List[Task]

Example

>>> from geobox.aio import AsyncGeoboxClient
>>> from geobox.aio.tileset import AsyncTileset
>>> async with AsyncGeoboxClient() as client:
>>>     tileset = await AsyncTileset.get_tileset(client, uuid="12345678-1234-5678-1234-567812345678")
>>>     await tileset.update_cache(from_zoom=0, to_zoom=14, extent=[])
property cache_size: int

[async] Retrieves the size of the cache of the tileset.

Returns:

The size of the cache of the tileset.

Return type:

int

Example

>>> from geobox.aio import AsyncGeoboxClient
>>> from geobox.aio.tileset import AsyncTileset
>>> async with AsyncGeoboxClient() as client:
>>>     tileset = await AsyncTileset.get_tileset(client, uuid="12345678-1234-5678-1234-567812345678")
>>>     await tileset.cache_size
async clear_cache()[source]

[async] Clears the cache of the tileset.

Returns:

None

Return type:

None

Example

>>> from geobox.aio import AsyncGeoboxClient
>>> from geobox.aio.tileset import AsyncTileset
>>> async with AsyncGeoboxClient() as client:
>>>     tileset = await AsyncTileset.get_tileset(client, uuid="12345678-1234-5678-1234-567812345678")
>>>     await tileset.clear_cache()