Async View

The async View module provides functionality for working with views.

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

Bases: AsyncVectorLayer

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

Initialize an async VectorLayerView instance.

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

  • uuid (str) – The UUID of the vector layer view.

  • layer_type (LayerType) – The type of the vector layer view.

  • data (Dict, optional) – The data of the vector layer view.

Return type:

None

__repr__()[source]

Return a string representation of the AsyncVectorLayerView instance.

Returns:

A string representation of the AsyncVectorLayerView instance.

Return type:

str

property vector_layer: AsyncVectorLayer

Get the vector layer.

Returns:

The vector layer.

Return type:

VectorLayer

Example

>>> from geobox.aio import AsyncGeoboxClient
>>> from geobox.aio.view import AsyncVectorLayerView
>>> async with AsyncGeoboxClient() as client:
>>>     view = await AsyncVectorLayerView.get_view(client, uuid='e21e085a-8d30-407d-a740-ca9be9122c42')
>>>     view.vector_layer
async classmethod get_views(api, **kwargs)[source]

[async] Get vector layer views.

Parameters:

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

Keyword Arguments:
  • layer_id (int) – The id of the source vector layer.

  • include_settings (bool) – Whether to include the settings of the layer. default is False.

  • 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) – Whether to return the count of the layer views. default is False.

  • skip (int) – The number of layer views to skip. minimum is 0.

  • limit (int) – The maximum number of layer views to return. minimum is 1. default is 10.

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

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

Returns:

A list of AsyncVectorLayerView instances or the layer views count if return_count is True.

Return type:

list[AsyncVectorLayerView] | int

Example

>>> from geobox.aio import AsyncGeoboxClient
>>> from geobox.aio.view import AsyncVectorLayerView
>>> async with AsyncGeoboxClient() as client:
>>>     views = await AsyncVectorLayerView.get_views(client,
...                                              layer_id=1,
...                                              include_settings=True,
...                                              search="test",
...                                              search_fields="name",
...                                              order_by="name A",
...                                              return_count=False,
...                                              skip=0,
...                                              limit=10,
...                                              shared=True)
or
>>>     views = await client.get_views(layer_id=1,
...                                     include_settings=True,
...                                     search="test",
...                                     search_fields="name",
...                                     order_by="name A",
...                                     return_count=False,
...                                     skip=0,
...                                     limit=10,
...                                     shared=True)
async classmethod get_views_by_ids(api, ids, user_id=None, include_settings=False)[source]

[async] Get vector layer views by their IDs.

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

  • ids (List[int]) – list of comma separated layer ids to be returned. e.g. 1, 2, 3

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

  • include_settings (bool, optional) – Whether to include the settings of the vector layer views. default is False.

Returns:

A list of AsyncVectorLayerView instances.

Return type:

List[AsyncVectorLayerView]

Example

>>> from geobox.aio import AsyncGeoboxClient
>>> from geobox.aio.view import AsyncVectorLayerView
>>> async with AsyncGeoboxClient() as client:
>>>     views = await AsyncVectorLayerView.get_views_by_ids(client, ids=[1,2,3])
or
>>>     views = await client.get_views_by_ids(ids=[1,2,3])
async classmethod get_view(api, uuid, user_id=None)[source]

[async] Get a specific vector layer view by its UUID.

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

  • uuid (str) – The UUID of the vector layer view.

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

Returns:

A AsyncVectorLayerView instance.

Return type:

AsyncVectorLayerView

Example

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

[async] Get a view by name

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

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

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

Returns:

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

Return type:

AsyncVectorLayerView | None

Example

>>> from geobox.aio import AsyncGeoboxClient
>>> from geobox.aio.view import AsyncVectorLayerView
>>> async with AsyncGeoboxClient() as client:
>>>     view = await AsyncVectorLayerView.get_view_by_name(client, name='test')
or
>>>     view = await client.get_view_by_name(name='test')
async update(**kwargs)[source]

[async] Update the vector layer view.

Keyword Arguments:
  • name (str) – The name of the vector layer view.

  • display_name (str) – The display name of the vector layer view.

  • description (str) – The description of the vector layer view.

Returns:

The updated vector layer view.

Return type:

Dict

Raises:

ValidationError – If the update data is invalid.

Example

>>> from geobox.aio import AsyncGeoboxClient
>>> from geobox.aio.view import AsyncVectorLayerView
>>> async with AsyncGeoboxClient() as client:
>>>     view = await AsyncVectorLayerView.get_view(client, uuid="12345678-1234-5678-1234-567812345678")
>>>     await view.update(name="new_name")
>>>     await view.update(display_name="new_display_name")
>>>     await view.update(description="new_description")
async delete()[source]

[async] Delete the vector layer view.

Returns:

None

Return type:

None

Example

>>> from geobox.aio import AsyncGeoboxClient
>>> from geobox.aio.view import AsyncVectorLayerView
>>> async with AsyncGeoboxClient() as client:
>>>     view = async AsyncVectorLayerView.get_view(client, uuid="12345678-1234-5678-1234-567812345678")
>>>     async view.delete()
async share(users)[source]

[async] Shares the view with specified users.

Parameters:

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

Returns:

None

Return type:

None

Example

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

[async] Unshares the view with specified users.

Parameters:

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

Returns:

None

Return type:

None

Example

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

[async] Retrieves the list of users the view 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.view import AsyncVectorLayerView
>>> async with AsyncGeoboxClient() as client:
>>>     view = await AsyncVectorLayerView.get_view(client, uuid="12345678-1234-5678-1234-567812345678")
>>>     await view.get_shared_users(search='John', skip=0, limit=10)
async get_fields()[source]

[async] Get all fields in the vector layer view.

Returns:

A list of Field instances representing the vector layer view’s fields.

Return type:

List[AsyncField]

Raises:

ApiRequestError – If the API request fails.

Example

>>> from geobox.aio import AsyncGeoboxClient
>>> from geobox.aio.view import AsyncVectorLayerView
>>> async with AsyncGeoboxClient() as client:
>>>     view = await AsyncVectorLayerView.get_view(client, uuid="12345678-1234-5678-1234-567812345678")
>>>     fields = await view.get_fields()
async get_field(field_id)[source]

[async] Get a specific field by its ID or name.

Parameters:

field_id (int) – The ID of the field to retrieve.

Returns:

The requested field instance.

Return type:

AsyncField

Raises:
  • NotFoundError – If the field with the specified ID is not found.

  • ApiRequestError – If the API request fails.

Example

>>> from geobox.aio import AsyncGeoboxClient
>>> from geobox.aio.view import AsyncVectorLayerView
>>> async with AsyncGeoboxClient() as client:
>>>     view = await AsyncVectorLayerView.get_view(client, uuid="12345678-1234-5678-1234-567812345678")
>>>     field = await view.get_field(id=1)
async get_field_by_name(name)[source]

[async] Get a specific field by its name.

Parameters:

name (str, optional) – The name of the field to retrieve.

Returns:

The requested field instance.

Return type:

AsyncField

Raises:

NotFoundError – If the field with the specified name is not found.

Example

>>> from geobox.aio import AsyncGeoboxClient
>>> from geobox.aio.view import AsyncVectorLayerView
>>> async with AsyncGeoboxClient() as client:
>>>     view = await AsyncVectorLayerView.get_view(client, uuid="12345678-1234-5678-1234-567812345678")
>>>     field = await view.get_field_by_name(name='test')
async calculate_field(target_field, expression, q=None, bbox=None, bbox_srid=None, feature_ids=None, run_async=True, user_id=None)[source]

[async] Calculate values for a field based on an expression.

Parameters:
  • target_field (str) – The field to calculate values for.

  • expression (str) – The expression to use for calculation.

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

  • bbox (Optional[List[float]]) – Bounding box to filter features.

  • bbox_srid (Optional[int]) – Spatial reference ID for the bounding box.

  • feature_ids (Optional[List[int]]) – List of specific feature IDs to include.

  • run_async (Optional[bool]) – Whether to run the calculation asynchronously.

  • user_id (Optional[int]) – ID of the user running the calculation.

Returns:

The task instance of the calculation operation or the api response if the run_async=False.

Return type:

AsyncTask | Dict

Raises:
  • ValidationError – If the calculation parameters are invalid.

  • ApiRequestError – If the API request fails.

Example

>>> from geobox.aio import AsyncGeoboxClient
>>> from geobox.aio.view import AsyncVectorLayerView
>>> async with AsyncGeoboxClient() as client:
>>>     view = await AsyncVectorLayerView.get_view(client, uuid="12345678-1234-5678-1234-567812345678")
>>>     task = await view.calculate_field(target_field="target_field",
...         expression="expression",
...         q="name like 'my_layer'",
...         bbox=[10, 20, 30, 40],
...         bbox_srid=3857,
...         feature_ids=[1, 2, 3],
...         run_async=True)
async get_features(geojson=False, **kwargs)[source]

[async] Get features from the layer with optional filtering and pagination.

Parameters:

geojson (bool, optional) – If True, returns the raw API response (GeoJSON dict). If False, returns a list of Feature objects. default: False.

Keyword Arguments:
  • quant_factor (int) – Quantization factor. This parameter is only used by topojson encoder and is ignored for other formats. Higher quantizaion value means higher geometry precision. default is 1000000.

  • skip (int) – Number of features to skip. default is 0.

  • limit (int) – Maximum number of features to return. default is 100.

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

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

  • skip_geometry (bool) – Whether to exclude geometry data. default is False.

  • return_count (bool) – Whether to return total count. default is False.

  • feature_ids (List[int]) – comma separated list of feature ids which should be filtered.

  • select_fields (str) – comma separated field names which should be included to the result. default is “[ALL]”.

  • skip_fields (str) – comma separated field names which should be excluded from the result.

  • out_srid (int) – srid (epsg code) of result features. e.g. 4326. default is 3857

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

  • q (str) – query filter based on OGC CQL standard. e.g. Name LIKE ‘%GIS%’ AND INTERSECTS(geometry, ‘SRID=3857;POLYGON((4901948 2885079, 7049893 2885079, 7049893 4833901, 4901948 4833901, 4901948 2885079))’).

  • bbox (str) – Bounding box to filter features by. e.g. [50.275, 35.1195, 51.4459, 36.0416].

  • bbox_srid (int) – srid (epsg code) of bbox. e.g. 4326. default is 3857.

Returns:

A list of Feature instances or the geojson api response if geojson=True or the features count if return_count is True.

Return type:

List[Feature] | Dict | int

Example

>>> from geobox.aio import AsyncGeoboxClient
>>> from geobox.aio.view import AsyncVectorLayerView
>>> async with AsyncGeoboxClient() as client:
>>>     layer = await AsyncVectorLayerView(api=client, name="my_layer", layer_type=LayerType.Point)
>>>     features = await layer.get_features(quant_factor=1000000,
...         skip=0,
...         limit=100,
...         skip_geometry=False,
...         return_count=False,
...         select_fields="fclass, osm_id",
...         out_srid=4326,
...         bbox_srid=4326)
async get_feature(feature_id, out_srid=3857)[source]

[async] Get a specific feature by its ID.

Parameters:
  • feature_id (int) – The ID of the feature to retrieve.

  • out_srid (int, optional) – Output spatial reference ID

Returns:

The requested feature instance.

Return type:

AsyncFeature

Raises:

NotFoundError – If the feature with the specified ID is not found.

Example

>>> from geobox.aio import AsyncGeoboxClient
>>> from geobox.aio.view import AsyncVectorLayerView
>>> async with AsyncGeoboxClient() as client:
>>>     view = await AsyncVectorLayerView.get_view(client, uuid="12345678-1234-5678-1234-567812345678")
>>>     feature = await view.get_feature(id=1)
async create_feature(geojson)[source]

[async] Create a new feature in the layer.

Parameters:

geojson (dict) – The feature data including properties and geometry.

Returns:

The newly created feature instance.

Return type:

AsyncFeature

Raises:

ValidationError – If the feature data is invalid.

Example

>>> from geobox.aio import AsyncGeoboxClient
>>> from geobox.aio.view import AsyncVectorLayerView
>>> async with AsyncGeoboxClient() as client:
>>>     view = await AsyncVectorLayerView.get_view(client, uuid="12345678-1234-5678-1234-567812345678")
>>>     feature = await view.create_feature(geojson=geojson)
async delete_features(q=None, bbox=None, bbox_srid=None, feature_ids=None, run_async=True, user_id=None)[source]

[async] Delete features from the layer based on specified criteria.

Parameters:
  • q (Optional[str]) – Query to filter features to delete.

  • bbox (Optional[List[float]]) – Bounding box to filter features.

  • bbox_srid (Optional[int]) – Spatial reference ID for the bounding box.

  • feature_ids (Optional[List[int]]) – List of specific feature IDs to delete.

  • run_async (Optional[bool]) – Whether to run the deletion asynchronously.

  • user_id (Optional[int]) – ID of the user performing the deletion.

Returns:

The task instance of the deletion operation or the api response if run_async=False.

Return type:

AsyncTask | Dict

Raises:

ValidationError – If the deletion parameters are invalid.

Example

>>> from geobox.aio import AsyncGeoboxClient
>>> from geobox.aio.view import AsyncVectorLayerView
>>> async with AsyncGeoboxClient() as client:
>>>     view = await AsyncVectorLayerView.get_view(client, uuid="12345678-1234-5678-1234-567812345678")
>>>     await view.delete_features(q="name like 'my_layer'",
...         bbox=[10, 20, 30, 40],
...         bbox_srid=3857,
...         feature_ids=[1, 2, 3],
...         run_async=True)
async import_features(file, input_geom_type=None, input_layer_name=None, input_dataset=None, user_id=None, input_srid=None, file_encoding='utf-8', replace_domain_codes_by_values=False, report_errors=True)[source]

[async] Import features from a file into the layer.

Parameters:
  • file (File) – file object to import.

  • input_geom_type (InputGeomType, optional) – Type of geometry in the input file.

  • input_layer_name (str, optional) – Name of the layer in the input file.

  • input_dataset (str, optional) – Name of the dataset in the input file.

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

  • input_srid (int, optional) – Spatial reference ID of the input data.

  • file_encoding (str, optional) – Character encoding of the input file.

  • replace_domain_codes_by_values (bool, optional) – Whether to replace domain codes with values.

  • report_errors (bool, optional) – Whether to report import errors.

Returns:

The task instance of the import operation.

Return type:

Task

Raises:

ValidationError – If the import parameters are invalid.

Example

>>> from geobox.aio import AsyncGeoboxClient
>>> from geobox.aio.view import AsyncVectorLayerView
>>> async with AsyncGeoboxClient() as client:
>>>     view = await AsyncVectorLayerView.get_view(client, uuid="12345678-1234-5678-1234-567812345678")
>>>     file = await client.get_file(uuid="12345678-1234-5678-1234-567812345678")
>>>     task = await view.import_features(file=file,
...         input_geom_type=InputGeomType.POINT,
...         input_layer="my_layer",
...         input_dataset="my_dataset",
...         input_srid=3857,
...         file_encoding="utf-8",
...         replace_domain_codes_by_values=False,
...         report_errors=True)
async export_features(out_filename, out_format, replace_domain_codes_by_values=False, run_async=True, bbox=None, out_srid=None, zipped=True, feature_ids=None, bbox_srid=None, q=None, fields=None)[source]

[async] Export features from the layer to a file.

Parameters:
  • out_filename (str) – Name of the output file.

  • out_format (FileOutputFormat) – Format of the output file (e.g., ‘Shapefile’, ‘GPKG’, ‘GeoJSON’, ‘CSV’, ‘KML’, ‘DXF’).

  • replace_domain_codes_by_values (bool, optional) – Whether to replace domain codes with values.

  • run_async (bool, optional) – Whether to run the export asynchronously.

  • bbox (List[float], optional) – Bounding box to filter features.

  • out_srid (int, optional) – Spatial reference ID for the output.

  • zipped (bool, optional) – Whether to compress the output file.

  • feature_ids (List[int], optional) – List of specific feature IDs to export.

  • bbox_srid (int, optional) – Spatial reference ID for the bounding box.

  • q (str, optional) – Query to filter features.

  • fields (List[str], optional) – List of fields to include in the export.

Returns:

The task instance of the export operation or the api response if run_async=False.

Return type:

AsyncTask | Dict

Raises:
  • ValidationError – If the export parameters are invalid.

  • ApiRequestError – If the API request fails.

Example

>>> from geobox.aio import AsyncGeoboxClient
>>> from geobox.aio.view import AsyncVectorLayerView
>>> async with AsyncGeoboxClient() as client:
>>>     view = await AsyncVectorLayerView.get_view(client, uuid="12345678-1234-5678-1234-567812345678")
>>>     task = await view.export_features(out_filename="output.shp",
...         out_format="shp",
...         replace_domain_codes_by_values=False,
...         run_async=True,
...         bbox=[10, 20, 30, 40],
...         out_srid=3857,
...         zipped=True,
...         feature_ids=[1, 2, 3])
property tile_pbf_url: str

Get a vector tile pbf url for the view.

Returns:

the vector tile url.

Return type:

str

Example

>>> from geobox.aio import AsyncGeoboxClient
>>> from geobox.aio.view import AsyncVectorLayerView
>>> async with AsyncGeoboxClient() as client:
>>>     view = await AsyncVectorLayerView.get_view(client, uuid="12345678-1234-5678-1234-567812345678")
>>>     url = view.tile_pbf_url
async get_tile_json()[source]

[async] Get the vector tile JSON configuration for the layer.

Returns:

The vector tile JSON configuration.

Return type:

Dict

Example

>>> from geobox.aio import AsyncGeoboxClient
>>> from geobox.aio.view import AsyncVectorLayerView
>>> async with AsyncGeoboxClient() as client:
>>>     view = await AsyncVectorLayerView.get_view(client, uuid="12345678-1234-5678-1234-567812345678")
>>>     tile_json = await view.get_tile_json()
property settings: Dict

[async] Get the layer’s settings.

Returns:

The layer settings.

Return type:

Dict

Example

>>> from geobox.aio import AsyncGeoboxClient
>>> from geobox.aio.view import AsyncVectorLayerView
>>> async with AsyncGeoboxClient() as client:
>>>     view = await AsyncVectorLayerView.get_view(client, uuid="12345678-1234-5678-1234-567812345678")
>>>     setting = await view.settings
async update_settings(settings)[source]

[async] Update the settings

settings (Dict): settings dictionary

Returns:

updated settings

Return type:

Dict

Parameters:

settings (Dict)

Example

>>> from geobox.aio import AsyncGeoboxClient
>>> async with AsyncGeoboxClient() as client:
>>>     view1 = await client.get_view(uuid="12345678-1234-5678-1234-567812345678")
>>>     view2 = await client.get_view(uuid="12345678-1234-5678-1234-567812345678")
>>>     await view1.update_settings(view2.settings)
async set_settings(**kwargs)[source]

[async] Set the settings of the Vector Layer.

Keyword Arguments:
  • title_field (str) – The field to use as the title.

  • domain_display_type (str) – The type of domain display.

  • allow_export (bool) – Whether to allow export.

  • editable (bool) – Whether to allow editing.

  • edit_geometry (bool) – Whether to allow editing the geometry.

  • editable_attributes (str) – The attributes to allow editing.

  • allow_insert (bool) – Whether to allow inserting.

  • allow_delete (bool) – Whether to allow deleting.

  • min_zoom (int) – The minimum zoom level.

  • max_zoom (int) – The maximum zoom level.

  • max_features (int) – The maximum number of features.

  • filter_features (bool) – Whether to filter features.

  • fields (List[str]) – The fields to include in the layer.

  • use_cache (bool) – Whether to use caching.

  • cache_until_zoom (int) – The zoom level to cache until.

Returns:

The updated settings.

Return type:

Dict

Raises:

ValidationError – If the settings data is invalid.

Example

>>> from geobox.aio import AsyncGeoboxClient
>>> from geobox.aio.view import AsyncVectorLayerView
>>> async with AsyncGeoboxClient() as client:
>>>     view = await AsyncVectorLayerView.get_view(client, uuid="12345678-1234-5678-1234-567812345678")
>>>     await view.set_setting(title_field="name",
...         domain_display_type="Value",
...         allow_export=True,
...         editable=True,
...         edit_geometry=True,
...         editable_attributes="[ALL]",
...         allow_insert=True,
...         allow_delete=True,
...         min_zoom=0,
...         max_zoom=24,
...         max_features=65536,
...         filter_features=True,
...         fields=["id"],
...         use_cache=True,
...         cache_until_zoom=17)
async seed_cache(from_zoom=None, to_zoom=None, ignore_cache=False, workers=1, user_id=None)[source]

[async] Seed the cache for the view.

Parameters:
  • from_zoom (int, optional) – The zoom level to start caching from.

  • to_zoom (int, optional) – The zoom level to stop caching at.

  • ignore_cache (bool, optional) – Whether to ignore the cache. default is False.

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

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

Returns:

The task instance of the cache seeding operation.

Return type:

List[Task]

Example

>>> from geobox.aio import AsyncGeoboxClient
>>> from geobox.aio.view import AsyncVectorLayerView
>>> async with AsyncGeoboxClient() as client:
>>>     view = await AsyncVectorLayerView.get_view(client, uuid="12345678-1234-5678-1234-567812345678")
>>>     task = await view.cache_seed(from_zoom=0, to_zoom=10, ignore_cache=False, workers=1)
async clear_cache()[source]

[async] Clear the view’s cache.

Returns:

None

Return type:

None

Example

>>> from geobox.aio import AsyncGeoboxClient
>>> from geobox.aio.view import AsyncVectorLayerView
>>> async with AsyncGeoboxClient() as client:
>>>     view = await AsyncVectorLayerView.get_view(client, uuid="12345678-1234-5678-1234-567812345678")
>>>     await view.clear_cache()
property cache_size: int

[async] Get the size of the view’s cache.

Returns:

The size of the view’s cache.

Return type:

int

Example

>>> from geobox.aio import AsyncGeoboxClient
>>> from geobox.aio.view import AsyncVectorLayerView
>>> async with AsyncGeoboxClient() as client:
>>>     view = await AsyncVectorLayerView.get_view(client, uuid="12345678-1234-5678-1234-567812345678")
>>>     await view.cache_size
async update_stats()[source]

[async] Update the view’s statistics.

Returns:

None

Return type:

None

Example

>>> from geobox.aio import AsyncGeoboxClient
>>> from geobox.aio.view import AsyncVectorLayerView
>>> async with AsyncGeoboxClient() as client:
>>>     view = await AsyncVectorLayerView.get_view(client, uuid="12345678-1234-5678-1234-567812345678")
>>>     await view.update_stats()
async prune_edited_areas()[source]

[async] Prune edited areas. This method eliminates edited areas when there are too many of them. Cache builder uses this edited areas for partial cache generating.

Returns:

None

Return type:

None

Example

>>> from geobox.aio import AsyncGeoboxClient
>>> from geobox.aio.view import AsyncVectorLayerView
>>> async with AsyncGeoboxClient() as client:
>>>     view = await AsyncVectorLayerView.get_view(client, uuid="12345678-1234-5678-1234-567812345678")
>>>     await view.prune_edited_areas()
async get_attachments(**kwargs)[source]

[async] Get the resouces attachments

Keyword Arguments:
  • element_id (str) – the id of the element with attachment.

  • search (str) – search term for keyword-based searching among all textual fields.

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

  • skip (int) – Number of items to skip. default is 0.

  • limit (int) – Number of items to return. default is 10.

  • return_count (bool) – Whether to return total count. default is False.

Returns:

A list of attachments instances or the total number of attachments.

Return type:

List[AsyncAttachment] | int

Raises:

TypeError – if the resource type is not supported

Example

>>> from geobox.aio import AsyncGeoboxClient
>>> from geobox.aio.view import AsyncVectorLayerView
>>> async with AsyncGeoboxClient() as client:
>>>     view = await AsyncVectorLayerView.get_view(client, uuid="12345678-1234-5678-1234-567812345678")
>>>     await view.get_attachments()
async create_attachment(name, loc_x, loc_y, file, feature=None, display_name=None, description=None)[source]

[async] Create a new Attachment.

Parameters:
  • name (str) – The name of the scene.

  • loc_x (int) – x parameter of the attachment location.

  • loc_y (int) – y parameter of the attachment location.

  • file (AsyncFile) – the file object.

  • feature (AsyncFeature, optional) – the feature object.

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

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

Returns:

The newly created Attachment instance.

Return type:

Attachment

Raises:

ValidationError – If the Attachment data is invalid.

Example

>>> from geobox.aio import AsyncGeoboxClient
>>> from geobox.aio.view import AsyncVectorLayerView
>>> async with AsyncGeoboxClient() as client:
>>>     view = await AsyncVectorLayerView.get_view(client, uuid="12345678-1234-5678-1234-567812345678")
>>>     files = await client.get_files()
>>>     file = file[0]
>>>     await view.create_attachment(name='test', loc_x=10, loc_y=10, file=file)
async generate_thumbnail()[source]

[async] Generate thumbnail for the view

Returns:

the api response

Return type:

Dict

Example

>>> from geobox.aio import AsyncGeoboxClient
>>> from geobox.aio.view import AsyncVectorLayerView
>>> async with AsyncGeoboxClient() as client:
>>>     view = await client.get_view(uuid="12345678-1234-5678-1234-567812345678")
or
>>>     view = await AsyncVectorLayer.get_view(client, uuid="12345678-1234-5678-1234-567812345678")
>>>     await view.generate_thumbnail()
async save_as_vector_layer(out_layer_name, q=None, bbox=None, bbox_srid=None, fields=None, schema_only=False, run_async=True)[source]

[async] Copy filtered/selected features of a vector layer view into a new vector layer.

Parameters:
  • out_layer_name (str) – the output vector layer name

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

  • bbox (str, optional) – Bounding box to filter features

  • bbox_srid (int, optional) – Spatial reference ID for the bounding box

  • fields (str, optional) – Comma separated list of fields

  • feature_ids (str, optional) – Comma seprated feature ids

  • schema_only (bool, optional) – Whether to save the layer schema only

  • run_async (bool, optional) – Whether to run the task asynchronously

Returns:

a task instance if ‘run_async == True’, else the task result dictionary

Return type:

AsyncTask | Dict

Example

>>> from geobox.aio import AsyncGeoboxClient
>>> from geobox.aio.view import AsyncVectorLayerView
>>> async with AsyncGeoboxClient() as client:
>>>     layer = await client.get_vector(uuid="12345678-1234-5678-1234-567812345678")
or
>>>     layer = await AsyncVectorLayerView.get_vector(client, uuid="12345678-1234-5678-1234-567812345678")
>>>     await layer.save_as_vector_layer(out_layer_name='test')