Tileset

The Tileset module provides functionality for working with tilesets.

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

Bases: Base

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

Constructs all the necessary attributes for the Tilesets object.

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

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

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

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

Create a new tileset.

Parameters:
  • api (GeoboxClient) – The GeoboxClient 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:

Tileset

Example

>>> from geobox import GeoboxClient
>>> from geobox.tileset import Tileset
>>> client = GeoboxClient()
>>> layer = client.get_vector(uuid="12345678-1234-5678-1234-567812345678")
>>> view = client.get_view(uuid="12345678-1234-5678-1234-567812345678")
>>> tileset = Tileset.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 = client.create_tileset(name="your_tileset_name",
...                                     display_name="Your Tileset",
...                                     description="Your description",
...                                     min_zoom=0,
...                                     max_zoom=14,
...                                     layers=[layer, view])
classmethod get_tilesets(api, **kwargs)[source]

Retrieves a list of tilesets.

Parameters:

api (GeoboxClient) – The GeoboxClient 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[Tileset] | int

Example

>>> from geobox import GeoboxClient
>>> from geobox.tileset import Tileset
>>> client = GeoboxClient()
>>> tilesets = Tileset.get_tilesets(client,
...     q="name LIKE '%your_tileset_name%'",
...     order_by="name A",
...     skip=0,
...     limit=10,
... )
or
>>> tilesets = client.get_tilesets(q="name LIKE '%your_tileset_name%'",
...     order_by="name A",
...     skip=0,
...     limit=10,
... )
classmethod get_tilesets_by_ids(api, ids, user_id=None)[source]

Retrieves a list of tilesets by their IDs.

Parameters:
  • api (GeoboxClient) – The GeoboxClient 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[Tileset]

Example

>>> from geobox import GeoboxClient
>>> from geobox.tileset import Tileset
>>> client = GeoboxClient()
>>> tilesets = Tileset.get_tilesets_by_ids(client, ids=['123', '456'])
or
>>> tilesets = client.get_tilesets_by_ids(ids=['123', '456'])
classmethod get_tileset(api, uuid)[source]

Retrieves a tileset by its UUID.

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

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

Returns:

The retrieved tileset instance.

Return type:

Tileset

Example

>>> from geobox import GeoboxClient
>>> from geobox.tileset import Tileset
>>> client = GeoboxClient()
>>> tileset = Tileset.get_tileset(client, uuid="12345678-1234-5678-1234-567812345678")
or
>>> tileset = client.get_tileset(uuid="12345678-1234-5678-1234-567812345678")
classmethod get_tileset_by_name(api, name, user_id=None)[source]

Get a tileset by name

Parameters:
  • api (GeoboxClient) – The GeoboxClient 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:

Tileset | None

Example

>>> from geobox import GeoboxClient
>>> from geobox.tileset import Tileset
>>> client = GeoboxClient()
>>> tileset = VectorLayer.get_tileset_by_name(client, name='test')
or
>>> tileset = client.get_tileset_by_name(name='test')
update(**kwargs)[source]

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 import GeoboxClient
>>> from geobox.tileset import Tileset
>>> client = GeoboxClient()
>>> tileset = Tileset.get_tileset(client, uuid="12345678-1234-5678-1234-567812345678")
>>> tileset.update_tileset(
...     name="new_name",
...     display_name="New Display Name",
...     description="New description",
...     min_zoom=0,
...     max_zoom=14
... )
delete()[source]

Deletes the tileset.

Raises:

ValueError – if the tileset uuid is not set.

Returns:

None

Return type:

None

Example

>>> from geobox import GeoboxClient
>>> from geobox.vectorlayer import VectorLayer
>>> client = GeoboxClient()
>>> tileset = Tileset.get_tileset(client, uuid="12345678-1234-5678-1234-567812345678")
>>> tileset.delete()
get_layers(**kwargs)[source]

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 instances.

Return type:

List

Raises:

ApiRequestError – If the API request fails.

Example:

Returns:

A list of VectorLayer or VectorLayerView instances.

Return type:

List

Example

>>> from geobox import GeoboxClient
>>> from geobox.tileset import Tileset
>>> client = GeoboxClient()
>>> tileset = Tileset.get_tileset(client, uuid="12345678-1234-5678-1234-567812345678")
>>> layers = tileset.get_layers()
add_layer(layer)[source]

Adds a layer to the tileset.

Parameters:

layer (VectorLayer | VectorLayerView) – 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 import GeoboxClient
>>> from geobox.tileset import Tileset
>>> client = GeoboxClient()
>>> tileset = Tileset.get_tileset(client, uuid="12345678-1234-5678-1234-567812345678")
>>> layer = client.get_vector(uuid="12345678-1234-5678-1234-567812345678")
>>> tileset.add_layer(layer)
delete_layer(layer)[source]

Deletes a layer from the tileset.

Parameters:

layer (VectorLayer | VectorLayerView) – 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 import GeoboxClient
>>> from geobox.tileset import Tileset
>>> client = GeoboxClient()
>>> tileset = Tileset.get_tileset(client, uuid="12345678-1234-5678-1234-567812345678")
>>> layer = client.get_vector(uuid="12345678-1234-5678-1234-567812345678")
>>> tileset.delete_layer(layer)
share(users)[source]

Shares the file with specified users.

Parameters:

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

Returns:

None

Return type:

None

Example

>>> from geobox import GeoboxClient
>>> from geobox.tileset import Tileset
>>> client = GeoboxClient()
>>> tileset = Tileset.get_tileset(client, uuid="12345678-1234-5678-1234-567812345678")
>>> users = client.search_usesrs(search='John')
>>> tileset.share(users=users)
unshare(users)[source]

Unshares the file with specified users.

Parameters:

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

Returns:

None

Return type:

None

Example

>>> from geobox import GeoboxClient
>>> from geobox.tileset import Tileset
>>> client = GeoboxClient()
>>> tileset = Tileset.get_tileset(client, uuid="12345678-1234-5678-1234-567812345678")
>>> users = client.search_usesrs(search='John')
>>> tileset.unshare(users=users)
get_shared_users(search=None, skip=0, limit=10)[source]

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[User]

Example

>>> from geobox import GeoboxClient
>>> from geobox.tileset import Tileset
>>> client = GeoboxClient()
>>> tileset = Tileset.get_tileset(client, uuid="12345678-1234-5678-1234-567812345678")
>>> tileset.get_shared_users(search='John', skip=0, limit=10)
get_tile_json()[source]

Retrieves the tile JSON configuration.

Returns:

The tile JSON configuration.

Return type:

Dict

Example

>>> from geobox import GeoboxClient
>>> from geobox.tileset import Tileset
>>> client = GeoboxClient()
>>> tileset = Tileset.get_tileset(client, uuid="12345678-1234-5678-1234-567812345678")
>>> tileset.get_tile_json()
update_tileset_extent()[source]

Updates the extent of the tileset.

Returns:

The response from the API.

Return type:

Dict

Example

>>> from geobox import GeoboxClient
>>> from geobox.tileset import Tileset
>>> client = GeoboxClient()
>>> tileset = Tileset.get_tileset(client, uuid="12345678-1234-5678-1234-567812345678")
>>> 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 import GeoboxClient
>>> from geobox.tileset import Tileset
>>> client = GeoboxClient()
>>> tileset = Tileset.get_tileset(client, uuid="12345678-1234-5678-1234-567812345678")
>>> tileset.get_tile_tileset(x=1, y=1, z=1)
seed_cache(from_zoom=0, to_zoom=14, extent=[], workers=1, user_id=0)[source]

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[Task]

Raises:

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

Example

>>> from geobox import GeoboxClient
>>> from geobox.tileset import Tileset
>>> client = GeoboxClient()
>>> tileset = Tileset.get_tileset(client, uuid="12345678-1234-5678-1234-567812345678")
>>> tileset.seed_cache(from_zoom=0, to_zoom=14, extent=[], workers=1)
update_cache(from_zoom, to_zoom, extents=None, user_id=0)[source]

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]

property cache_size: int

Retrieves the size of the cache of the tileset.

Returns:

The size of the cache of the tileset.

Return type:

int

clear_cache()[source]

Clears the cache of the tileset.

Returns:

None

Return type:

None

Example

>>> from geobox import GeoboxClient
>>> from geobox.tileset import Tileset
>>> client = GeoboxClient()
>>> tileset = Tileset.get_tileset(client, uuid="12345678-1234-5678-1234-567812345678")
>>> tileset.clear_cache()