geobox 1.4.1__py3-none-any.whl → 2.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- geobox/__init__.py +2 -2
- geobox/aio/__init__.py +63 -0
- geobox/aio/api.py +2640 -0
- geobox/aio/apikey.py +263 -0
- geobox/aio/attachment.py +339 -0
- geobox/aio/base.py +262 -0
- geobox/aio/basemap.py +196 -0
- geobox/aio/dashboard.py +342 -0
- geobox/aio/feature.py +527 -0
- geobox/aio/field.py +321 -0
- geobox/aio/file.py +522 -0
- geobox/aio/layout.py +341 -0
- geobox/aio/log.py +145 -0
- geobox/aio/map.py +1034 -0
- geobox/aio/model3d.py +415 -0
- geobox/aio/mosaic.py +696 -0
- geobox/aio/plan.py +315 -0
- geobox/aio/query.py +702 -0
- geobox/aio/raster.py +869 -0
- geobox/aio/route.py +63 -0
- geobox/aio/scene.py +342 -0
- geobox/aio/settings.py +194 -0
- geobox/aio/task.py +402 -0
- geobox/aio/tile3d.py +339 -0
- geobox/aio/tileset.py +672 -0
- geobox/aio/usage.py +243 -0
- geobox/aio/user.py +507 -0
- geobox/aio/vectorlayer.py +1363 -0
- geobox/aio/version.py +273 -0
- geobox/aio/view.py +983 -0
- geobox/aio/workflow.py +341 -0
- geobox/api.py +14 -13
- geobox/apikey.py +28 -1
- geobox/attachment.py +27 -1
- geobox/base.py +4 -4
- geobox/basemap.py +30 -1
- geobox/dashboard.py +27 -0
- geobox/feature.py +33 -13
- geobox/field.py +33 -21
- geobox/file.py +40 -46
- geobox/layout.py +28 -1
- geobox/log.py +31 -7
- geobox/map.py +56 -5
- geobox/model3d.py +98 -19
- geobox/mosaic.py +47 -7
- geobox/plan.py +29 -3
- geobox/query.py +41 -5
- geobox/raster.py +45 -13
- geobox/scene.py +26 -0
- geobox/settings.py +30 -1
- geobox/task.py +28 -6
- geobox/tile3d.py +27 -1
- geobox/tileset.py +26 -5
- geobox/usage.py +32 -1
- geobox/user.py +62 -6
- geobox/utils.py +34 -0
- geobox/vectorlayer.py +59 -4
- geobox/version.py +25 -1
- geobox/view.py +54 -15
- geobox/workflow.py +27 -1
- {geobox-1.4.1.dist-info → geobox-2.0.0.dist-info}/METADATA +4 -1
- geobox-2.0.0.dist-info/RECORD +68 -0
- geobox-1.4.1.dist-info/RECORD +0 -38
- {geobox-1.4.1.dist-info → geobox-2.0.0.dist-info}/WHEEL +0 -0
- {geobox-1.4.1.dist-info → geobox-2.0.0.dist-info}/licenses/LICENSE +0 -0
- {geobox-1.4.1.dist-info → geobox-2.0.0.dist-info}/top_level.txt +0 -0
geobox/model3d.py
CHANGED
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
from typing import Dict, List, Optional, Optional, Union, TYPE_CHECKING
|
|
2
2
|
from urllib.parse import urljoin, urlencode
|
|
3
|
+
import os
|
|
4
|
+
import zipfile
|
|
5
|
+
import sys
|
|
3
6
|
|
|
4
7
|
from .base import Base
|
|
5
8
|
from .exception import ApiRequestError
|
|
9
|
+
from .utils import get_save_path
|
|
6
10
|
|
|
7
11
|
if TYPE_CHECKING:
|
|
8
12
|
from . import GeoboxClient
|
|
9
13
|
from .user import User
|
|
14
|
+
from .aio import AsyncGeoboxClient
|
|
15
|
+
from .aio.model3d import Model as AsyncModel
|
|
16
|
+
|
|
10
17
|
|
|
11
18
|
class Model(Base):
|
|
12
|
-
|
|
13
|
-
A class representing a 3D model in Geobox.
|
|
14
|
-
"""
|
|
19
|
+
|
|
15
20
|
BASE_ENDPOINT = '3dmodels/'
|
|
16
21
|
|
|
17
22
|
def __init__(self,
|
|
@@ -216,33 +221,83 @@ class Model(Base):
|
|
|
216
221
|
super().delete(self.endpoint)
|
|
217
222
|
|
|
218
223
|
|
|
219
|
-
def
|
|
224
|
+
def _create_progress_bar(self) -> 'tqdm':
|
|
225
|
+
"""Creates a progress bar for the task."""
|
|
226
|
+
try:
|
|
227
|
+
from tqdm.auto import tqdm
|
|
228
|
+
except ImportError:
|
|
229
|
+
from .api import logger
|
|
230
|
+
logger.warning("[tqdm] extra is required to show the progress bar. install with: pip insatll geobox[tqdm]")
|
|
231
|
+
return None
|
|
232
|
+
|
|
233
|
+
return tqdm(unit="B",
|
|
234
|
+
total=int(self.size),
|
|
235
|
+
file=sys.stdout,
|
|
236
|
+
dynamic_ncols=True,
|
|
237
|
+
desc="Downloading",
|
|
238
|
+
unit_scale=True,
|
|
239
|
+
unit_divisor=1024,
|
|
240
|
+
ascii=True
|
|
241
|
+
)
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
def download(self, save_path: str = None, progress_bar: bool = True) -> str:
|
|
220
245
|
"""
|
|
221
|
-
|
|
246
|
+
Download the 3D model, save it as a .glb file, zip it, and return the zip file path.
|
|
247
|
+
|
|
248
|
+
Args:
|
|
249
|
+
save_path (str, optional): Directory where the file should be saved.
|
|
250
|
+
progress_bar (bool, optional): Whether to show a progress bar. Default: True
|
|
222
251
|
|
|
223
252
|
Returns:
|
|
224
|
-
|
|
253
|
+
str: Path to the .zip file containing the .glb model.
|
|
225
254
|
|
|
226
255
|
Raises:
|
|
227
256
|
ApiRequestError: If the API request fails.
|
|
228
257
|
|
|
229
258
|
Example:
|
|
230
259
|
>>> from geobox import GeoboxClient
|
|
231
|
-
>>> from geobox.model3d import Model
|
|
232
260
|
>>> client = GeoboxClient()
|
|
233
|
-
>>> model =
|
|
234
|
-
>>>
|
|
235
|
-
>>> # Save the content to a file
|
|
236
|
-
>>> with open('model.gltf', 'wb') as f:
|
|
237
|
-
... f.write(content)
|
|
261
|
+
>>> model = client.get_models()[0]
|
|
262
|
+
>>> model.download()
|
|
238
263
|
"""
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
if
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
264
|
+
if not self.uuid:
|
|
265
|
+
raise ValueError("Model UUID is required to download content")
|
|
266
|
+
|
|
267
|
+
if self.data.get('obj'):
|
|
268
|
+
model = self.api.get_model(self.obj)
|
|
269
|
+
else:
|
|
270
|
+
model = self
|
|
271
|
+
|
|
272
|
+
save_path = get_save_path(save_path)
|
|
273
|
+
os.makedirs(save_path, exist_ok=True)
|
|
274
|
+
|
|
275
|
+
endpoint = urljoin(model.api.base_url, f"{model.endpoint}/content/")
|
|
276
|
+
with model.api.session.get(endpoint, stream=True) as response:
|
|
277
|
+
if response.status_code != 200:
|
|
278
|
+
raise ApiRequestError(f"Failed to get model content: {response.status_code}")
|
|
279
|
+
|
|
280
|
+
glb_filename = f"{model.name}.glb"
|
|
281
|
+
glb_path = os.path.join(save_path, glb_filename)
|
|
282
|
+
|
|
283
|
+
with open(glb_path, "wb") as f:
|
|
284
|
+
pbar = model._create_progress_bar() if progress_bar else None
|
|
285
|
+
for chunk in response.iter_content(chunk_size=8192):
|
|
286
|
+
f.write(chunk)
|
|
287
|
+
if pbar:
|
|
288
|
+
pbar.update(len(chunk))
|
|
289
|
+
pbar.refresh()
|
|
290
|
+
if pbar:
|
|
291
|
+
pbar.close()
|
|
292
|
+
|
|
293
|
+
zip_filename = f"{model.name}.zip"
|
|
294
|
+
zip_path = os.path.join(save_path, zip_filename)
|
|
295
|
+
with zipfile.ZipFile(zip_path, "w", zipfile.ZIP_DEFLATED) as zipf:
|
|
296
|
+
zipf.write(glb_path, arcname=os.path.basename(glb_path))
|
|
297
|
+
|
|
298
|
+
os.remove(glb_path)
|
|
299
|
+
|
|
300
|
+
return os.path.abspath(zip_path)
|
|
246
301
|
|
|
247
302
|
|
|
248
303
|
@property
|
|
@@ -330,3 +385,27 @@ class Model(Base):
|
|
|
330
385
|
'limit': limit
|
|
331
386
|
}
|
|
332
387
|
return super()._get_shared_users(self.endpoint, params)
|
|
388
|
+
|
|
389
|
+
|
|
390
|
+
def to_async(self, async_client: 'AsyncGeoboxClient') -> 'AsyncModel':
|
|
391
|
+
"""
|
|
392
|
+
Switch to async version of the 3d model instance to have access to the async methods
|
|
393
|
+
|
|
394
|
+
Args:
|
|
395
|
+
async_client (AsyncGeoboxClient): The async version of the GeoboxClient instance for making requests.
|
|
396
|
+
|
|
397
|
+
Returns:
|
|
398
|
+
geobox.aio.model3d.Model: the async instance of the 3d model.
|
|
399
|
+
|
|
400
|
+
Example:
|
|
401
|
+
>>> from geobox import Geoboxclient
|
|
402
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
403
|
+
>>> from geobox.model3d import Model
|
|
404
|
+
>>> client = GeoboxClient()
|
|
405
|
+
>>> model = Model.get_model(client, uuid="12345678-1234-5678-1234-567812345678")
|
|
406
|
+
>>> async with AsyncGeoboxClient() as async_client:
|
|
407
|
+
>>> async_model = model.to_async(async_client)
|
|
408
|
+
"""
|
|
409
|
+
from .aio.model3d import Model as AsyncModel
|
|
410
|
+
|
|
411
|
+
return AsyncModel(api=async_client, uuid=self.uuid, data=self.data)
|
geobox/mosaic.py
CHANGED
|
@@ -8,15 +8,12 @@ if TYPE_CHECKING:
|
|
|
8
8
|
from . import GeoboxClient
|
|
9
9
|
from .user import User
|
|
10
10
|
from .task import Task
|
|
11
|
+
from .aio import AsyncGeoboxClient
|
|
12
|
+
from .aio.mosaic import Mosaic as AsyncMosaic
|
|
13
|
+
|
|
11
14
|
|
|
12
15
|
class Mosaic(Raster):
|
|
13
|
-
"""
|
|
14
|
-
A class to represent a Mosaic in Geobox.
|
|
15
16
|
|
|
16
|
-
This class provides methods to interact with the mosaic in Geobox.
|
|
17
|
-
It inherits from the Raster class and provides additional methods to interact with the mosaic.
|
|
18
|
-
It also provides properties to access the mosaic data, and a method to update the mosaic.
|
|
19
|
-
"""
|
|
20
17
|
BASE_ENDPOINT: str = 'mosaics/'
|
|
21
18
|
|
|
22
19
|
def __init__(self,
|
|
@@ -227,7 +224,7 @@ class Mosaic(Raster):
|
|
|
227
224
|
>>> from geobox.mosaic import Mosaic
|
|
228
225
|
>>> client = GeoboxClient()
|
|
229
226
|
>>> mosaic = Mosaic.get_mosaic(client, uuid="12345678-1234-5678-1234-567812345678")
|
|
230
|
-
>>> mosaic.
|
|
227
|
+
>>> mosaic.update(name='new_name', display_name='new_display_name', description='new_description', pixel_selection='new_pixel_selection', min_zoom=10)
|
|
231
228
|
"""
|
|
232
229
|
data = {
|
|
233
230
|
'name': kwargs.get('name'),
|
|
@@ -401,6 +398,25 @@ class Mosaic(Raster):
|
|
|
401
398
|
"""
|
|
402
399
|
return super().settings
|
|
403
400
|
|
|
401
|
+
|
|
402
|
+
def update_settings(self, settings: Dict) -> Dict:
|
|
403
|
+
"""
|
|
404
|
+
Update the settings
|
|
405
|
+
|
|
406
|
+
settings (Dict): settings dictionary
|
|
407
|
+
|
|
408
|
+
Returns:
|
|
409
|
+
Dict: updated settings
|
|
410
|
+
|
|
411
|
+
Example:
|
|
412
|
+
>>> from geobox import GeoboxClient
|
|
413
|
+
>>> client = GeoboxClient()
|
|
414
|
+
>>> mosaic1 = client.get_mosaic(uuid="12345678-1234-5678-1234-567812345678")
|
|
415
|
+
>>> mosaic2 = client.get_mosaic(uuid="12345678-1234-5678-1234-567812345678")
|
|
416
|
+
>>> mosaic1.update_settings(mosaic2.settings)
|
|
417
|
+
"""
|
|
418
|
+
return super().update_settings(settings)
|
|
419
|
+
|
|
404
420
|
|
|
405
421
|
def set_settings(self, **kwargs) -> None:
|
|
406
422
|
"""
|
|
@@ -654,3 +670,27 @@ class Mosaic(Raster):
|
|
|
654
670
|
>>> mosaic.cache_size
|
|
655
671
|
"""
|
|
656
672
|
return super().cache_size
|
|
673
|
+
|
|
674
|
+
|
|
675
|
+
def to_async(self, async_client: 'AsyncGeoboxClient') -> 'AsyncMosaic':
|
|
676
|
+
"""
|
|
677
|
+
Switch to async version of the mosaic instance to have access to the async methods
|
|
678
|
+
|
|
679
|
+
Args:
|
|
680
|
+
async_client (AsyncGeoboxClient): The async version of the GeoboxClient instance for making requests.
|
|
681
|
+
|
|
682
|
+
Returns:
|
|
683
|
+
geobox.aio.mosaic.Mosaic: the async instance of the mosaic.
|
|
684
|
+
|
|
685
|
+
Example:
|
|
686
|
+
>>> from geobox import Geoboxclient
|
|
687
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
688
|
+
>>> from geobox.mosaic import Mosaic
|
|
689
|
+
>>> client = GeoboxClient()
|
|
690
|
+
>>> mosaic = Mosaic.get_mosaic(client, uuid="12345678-1234-5678-1234-567812345678")
|
|
691
|
+
>>> async with AsyncGeoboxClient() as async_client:
|
|
692
|
+
>>> async_mosaic = mosaic.to_async(async_client)
|
|
693
|
+
"""
|
|
694
|
+
from .aio.mosaic import Mosaic as AsyncMosaic
|
|
695
|
+
|
|
696
|
+
return AsyncMosaic(api=async_client, uuid=self.uuid, data=self.data)
|
geobox/plan.py
CHANGED
|
@@ -5,6 +5,8 @@ from .base import Base
|
|
|
5
5
|
|
|
6
6
|
if TYPE_CHECKING:
|
|
7
7
|
from . import GeoboxClient
|
|
8
|
+
from .aio import AsyncGeoboxClient
|
|
9
|
+
from .aio.plan import Plan as AsyncPlan
|
|
8
10
|
|
|
9
11
|
class Plan(Base):
|
|
10
12
|
|
|
@@ -209,7 +211,7 @@ class Plan(Base):
|
|
|
209
211
|
>>> from geobox import GeoboxClient
|
|
210
212
|
>>> from geobox.plan import Plan
|
|
211
213
|
>>> client = GeoboxClient()
|
|
212
|
-
>>> plan =
|
|
214
|
+
>>> plan = Plan.get_plan_by_name(client, name='test')
|
|
213
215
|
or
|
|
214
216
|
>>> plan = client.get_plan_by_name(name='test')
|
|
215
217
|
"""
|
|
@@ -250,7 +252,7 @@ class Plan(Base):
|
|
|
250
252
|
>>> from geobox.plan import Plan
|
|
251
253
|
>>> client = GeoboxClient()
|
|
252
254
|
>>> plan = Plan.get_plan(client, plan_id=1)
|
|
253
|
-
>>> plan.
|
|
255
|
+
>>> plan.update(display_name="New Display Name")
|
|
254
256
|
"""
|
|
255
257
|
data = {
|
|
256
258
|
"name": kwargs.get('name'),
|
|
@@ -285,4 +287,28 @@ class Plan(Base):
|
|
|
285
287
|
>>> plan.delete()
|
|
286
288
|
"""
|
|
287
289
|
super().delete(self.endpoint)
|
|
288
|
-
self.plan_id = None
|
|
290
|
+
self.plan_id = None
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
def to_async(self, async_client: 'AsyncGeoboxClient') -> 'AsyncPlan':
|
|
294
|
+
"""
|
|
295
|
+
Switch to async version of the plan instance to have access to the async methods
|
|
296
|
+
|
|
297
|
+
Args:
|
|
298
|
+
async_client (AsyncGeoboxClient): The async version of the GeoboxClient instance for making requests.
|
|
299
|
+
|
|
300
|
+
Returns:
|
|
301
|
+
geobox.aio.plan.Plan: the async instance of the plan.
|
|
302
|
+
|
|
303
|
+
Example:
|
|
304
|
+
>>> from geobox import Geoboxclient
|
|
305
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
306
|
+
>>> from geobox.plan import Plan
|
|
307
|
+
>>> client = GeoboxClient()
|
|
308
|
+
>>> plan = Plan.get_plan(client, plan_id=1)
|
|
309
|
+
>>> async with AsyncGeoboxClient() as async_client:
|
|
310
|
+
>>> async_plan = plan.to_async(async_client)
|
|
311
|
+
"""
|
|
312
|
+
from .aio.plan import Plan as AsyncPlan
|
|
313
|
+
|
|
314
|
+
return AsyncPlan(api=async_client, plan_id=self.plan_id, data=self.data)
|
geobox/query.py
CHANGED
|
@@ -9,11 +9,11 @@ from .enums import QueryResultType, QueryGeometryType, QueryParamType
|
|
|
9
9
|
if TYPE_CHECKING:
|
|
10
10
|
from . import GeoboxClient
|
|
11
11
|
from .user import User
|
|
12
|
+
from .aio import AsyncGeoboxClient
|
|
13
|
+
from .aio.query import Query as AsyncQuery
|
|
12
14
|
|
|
13
15
|
class Query(Base):
|
|
14
|
-
|
|
15
|
-
A class to interact with queries in GeoBox.
|
|
16
|
-
"""
|
|
16
|
+
|
|
17
17
|
BASE_ENDPOINT: str = 'queries/'
|
|
18
18
|
|
|
19
19
|
def __init__(self,
|
|
@@ -83,6 +83,7 @@ class Query(Base):
|
|
|
83
83
|
>>> client = GeoboxClient()
|
|
84
84
|
>>> query = Query.get_query(client, uuid="12345678-1234-5678-1234-567812345678")
|
|
85
85
|
>>> query.sql = 'SELECT * FROM some_layer'
|
|
86
|
+
>>> query.save()
|
|
86
87
|
"""
|
|
87
88
|
self.data['sql'] = value
|
|
88
89
|
|
|
@@ -126,6 +127,7 @@ class Query(Base):
|
|
|
126
127
|
>>> client = GeoboxClient()
|
|
127
128
|
>>> query = Query.get_query(client, uuid="12345678-1234-5678-1234-567812345678")
|
|
128
129
|
>>> query.params = [{'name': 'layer', 'value': '12345678-1234-5678-1234-567812345678', 'type': 'Layer'}]
|
|
130
|
+
>>> query.save()
|
|
129
131
|
"""
|
|
130
132
|
if not isinstance(self.data.get('params'), list):
|
|
131
133
|
self.data['params'] = []
|
|
@@ -179,7 +181,7 @@ class Query(Base):
|
|
|
179
181
|
|
|
180
182
|
|
|
181
183
|
@classmethod
|
|
182
|
-
def create_query(cls, api: 'GeoboxClient', name: str, display_name: str = None, sql: str = None, params: List = None) -> 'Query':
|
|
184
|
+
def create_query(cls, api: 'GeoboxClient', name: str, display_name: str = None, description:str = None, sql: str = None, params: List = None) -> 'Query':
|
|
183
185
|
"""
|
|
184
186
|
Creates a new query.
|
|
185
187
|
|
|
@@ -187,6 +189,7 @@ class Query(Base):
|
|
|
187
189
|
api (Api): The GeoboxClient instance for making requests.
|
|
188
190
|
name (str): The name of the query.
|
|
189
191
|
display_name (str, optional): The display name of the query.
|
|
192
|
+
description (str, optional): The description of the query.
|
|
190
193
|
sql (str, optional): The SQL statement for the query.
|
|
191
194
|
params (list, optional): The parameters for the SQL statement.
|
|
192
195
|
|
|
@@ -204,6 +207,7 @@ class Query(Base):
|
|
|
204
207
|
data = {
|
|
205
208
|
"name": name,
|
|
206
209
|
"display_name": display_name,
|
|
210
|
+
"description": description,
|
|
207
211
|
"sql": sql,
|
|
208
212
|
"params": params
|
|
209
213
|
}
|
|
@@ -342,6 +346,7 @@ class Query(Base):
|
|
|
342
346
|
or
|
|
343
347
|
>>> query = client.get_query(uuid="12345678-1234-5678-1234-567812345678")
|
|
344
348
|
>>> query.add_param(name='param_name', value='param_value', type=QueryParamType.LAYER)
|
|
349
|
+
>>> query.save()
|
|
345
350
|
"""
|
|
346
351
|
self._check_access()
|
|
347
352
|
|
|
@@ -376,6 +381,7 @@ class Query(Base):
|
|
|
376
381
|
or
|
|
377
382
|
>>> query = client.get_query(uuid="12345678-1234-5678-1234-567812345678")
|
|
378
383
|
>>> query.remove_param(name='param_name')
|
|
384
|
+
>>> query.save()
|
|
379
385
|
"""
|
|
380
386
|
self._check_access()
|
|
381
387
|
|
|
@@ -497,7 +503,6 @@ class Query(Base):
|
|
|
497
503
|
>>> from geobox.query import Query
|
|
498
504
|
>>> client = GeoboxClient()
|
|
499
505
|
>>> query = Query.get_query(client, uuid="12345678-1234-5678-1234-567812345678")
|
|
500
|
-
>>> query.sql = "SELECT * FROM some_layer"
|
|
501
506
|
>>> query.save()
|
|
502
507
|
"""
|
|
503
508
|
self.params = [item for item in self.params if item.get('value')]
|
|
@@ -618,6 +623,13 @@ class Query(Base):
|
|
|
618
623
|
|
|
619
624
|
Returns:
|
|
620
625
|
str: The thumbnail URL.
|
|
626
|
+
|
|
627
|
+
Example:
|
|
628
|
+
>>> from geobox import GeoboxClient
|
|
629
|
+
>>> from geobox.query import Query
|
|
630
|
+
>>> client = GeoboxClient()
|
|
631
|
+
>>> query = Query.get_query(client, uuid="12345678-1234-5678-1234-567812345678")
|
|
632
|
+
>>> query.thumbnail
|
|
621
633
|
"""
|
|
622
634
|
self._check_access()
|
|
623
635
|
return super().thumbnail()
|
|
@@ -663,3 +675,27 @@ class Query(Base):
|
|
|
663
675
|
response = self.api.post(endpoint, data)
|
|
664
676
|
task = Task.get_task(self.api, response.get('task_id'))
|
|
665
677
|
return task
|
|
678
|
+
|
|
679
|
+
|
|
680
|
+
def to_async(self, async_client: 'AsyncGeoboxClient') -> 'AsyncQuery':
|
|
681
|
+
"""
|
|
682
|
+
Switch to async version of the query instance to have access to the async methods
|
|
683
|
+
|
|
684
|
+
Args:
|
|
685
|
+
async_client (AsyncGeoboxClient): The async version of the GeoboxClient instance for making requests.
|
|
686
|
+
|
|
687
|
+
Returns:
|
|
688
|
+
geobox.aio.query.Query: the async instance of the query.
|
|
689
|
+
|
|
690
|
+
Example:
|
|
691
|
+
>>> from geobox import Geoboxclient
|
|
692
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
693
|
+
>>> from geobox.query import Query
|
|
694
|
+
>>> client = GeoboxClient()
|
|
695
|
+
>>> query = Query.get_query(client, uuid="12345678-1234-5678-1234-567812345678")
|
|
696
|
+
>>> async with AsyncGeoboxClient() as async_client:
|
|
697
|
+
>>> async_query = query.to_async(async_client)
|
|
698
|
+
"""
|
|
699
|
+
from .aio.query import Query as AsyncQuery
|
|
700
|
+
|
|
701
|
+
return AsyncQuery(api=async_client, uuid=self.uuid, data=self.data)
|
geobox/raster.py
CHANGED
|
@@ -12,15 +12,11 @@ from .task import Task
|
|
|
12
12
|
if TYPE_CHECKING:
|
|
13
13
|
from . import GeoboxClient
|
|
14
14
|
from .user import User
|
|
15
|
+
from .aio import AsyncGeoboxClient
|
|
16
|
+
from .aio.raster import Raster as AsyncRaster
|
|
15
17
|
|
|
16
18
|
class Raster(Base):
|
|
17
|
-
"""
|
|
18
|
-
A class to represent a Raster in Geobox.
|
|
19
19
|
|
|
20
|
-
This class provides functionality to interact with rasters in Geobox.
|
|
21
|
-
It supports various operations including CRUD operations on rasters, as well as advanced operations like getting statistics, points, and tiles.
|
|
22
|
-
It also provides properties to access the raster data, and a method to download the raster.
|
|
23
|
-
"""
|
|
24
20
|
BASE_ENDPOINT: str = 'rasters/'
|
|
25
21
|
|
|
26
22
|
def __init__(self,
|
|
@@ -322,13 +318,6 @@ class Raster(Base):
|
|
|
322
318
|
|
|
323
319
|
Raises:
|
|
324
320
|
ValueError: If save_path does not end with a '/'.
|
|
325
|
-
|
|
326
|
-
Example:
|
|
327
|
-
>>> from geobox import GeoboxClient
|
|
328
|
-
>>> from geobox.file import File
|
|
329
|
-
>>> from geobox import GeoboxClient
|
|
330
|
-
>>> client = GeoboxClient()
|
|
331
|
-
>>> file_path = File.get_file(client, uuid="12345678-1234-5678-1234-567812345678")
|
|
332
321
|
"""
|
|
333
322
|
# If save_path is provided, check if it ends with a '/'
|
|
334
323
|
if save_path and save_path.endswith('/'):
|
|
@@ -641,6 +630,25 @@ class Raster(Base):
|
|
|
641
630
|
>>> raster.settings
|
|
642
631
|
"""
|
|
643
632
|
return super()._get_settings(self.endpoint)
|
|
633
|
+
|
|
634
|
+
|
|
635
|
+
def update_settings(self, settings: Dict) -> Dict:
|
|
636
|
+
"""
|
|
637
|
+
Update the settings
|
|
638
|
+
|
|
639
|
+
settings (Dict): settings dictionary
|
|
640
|
+
|
|
641
|
+
Returns:
|
|
642
|
+
Dict: updated settings
|
|
643
|
+
|
|
644
|
+
Example:
|
|
645
|
+
>>> from geobox import GeoboxClient
|
|
646
|
+
>>> client = GeoboxClient()
|
|
647
|
+
>>> raster1 = client.get_raster(uuid="12345678-1234-5678-1234-567812345678")
|
|
648
|
+
>>> raster2 = client.get_raster(uuid="12345678-1234-5678-1234-567812345678")
|
|
649
|
+
>>> raster1.update_settings(raster2.settings)
|
|
650
|
+
"""
|
|
651
|
+
return super()._set_settings(self.endpoint, settings)
|
|
644
652
|
|
|
645
653
|
|
|
646
654
|
def set_settings(self, **kwargs) -> None:
|
|
@@ -829,3 +837,27 @@ class Raster(Base):
|
|
|
829
837
|
>>> raster.cache_size
|
|
830
838
|
"""
|
|
831
839
|
return super()._cache_size(self.endpoint)
|
|
840
|
+
|
|
841
|
+
|
|
842
|
+
def to_async(self, async_client: 'AsyncGeoboxClient') -> 'AsyncRaster':
|
|
843
|
+
"""
|
|
844
|
+
Switch to async version of the raster instance to have access to the async methods
|
|
845
|
+
|
|
846
|
+
Args:
|
|
847
|
+
async_client (AsyncGeoboxClient): The async version of the GeoboxClient instance for making requests.
|
|
848
|
+
|
|
849
|
+
Returns:
|
|
850
|
+
geobox.aio.raster.Raster: the async instance of the raster.
|
|
851
|
+
|
|
852
|
+
Example:
|
|
853
|
+
>>> from geobox import Geoboxclient
|
|
854
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
855
|
+
>>> from geobox.raster import Raster
|
|
856
|
+
>>> client = GeoboxClient()
|
|
857
|
+
>>> raster = Raster.get_raster(client, uuid="12345678-1234-5678-1234-567812345678")
|
|
858
|
+
>>> async with AsyncGeoboxClient() as async_client:
|
|
859
|
+
>>> async_raster = raster.to_async(async_client)
|
|
860
|
+
"""
|
|
861
|
+
from .aio.raster import Raster as AsyncRaster
|
|
862
|
+
|
|
863
|
+
return AsyncRaster(api=async_client, uuid=self.uuid, data=self.data)
|
geobox/scene.py
CHANGED
|
@@ -6,6 +6,8 @@ from .base import Base
|
|
|
6
6
|
if TYPE_CHECKING:
|
|
7
7
|
from . import GeoboxClient
|
|
8
8
|
from .user import User
|
|
9
|
+
from .aio import AsyncGeoboxClient
|
|
10
|
+
from .aio.scene import Scene as AsyncScene
|
|
9
11
|
|
|
10
12
|
class Scene(Base):
|
|
11
13
|
|
|
@@ -314,3 +316,27 @@ class Scene(Base):
|
|
|
314
316
|
'limit': limit
|
|
315
317
|
}
|
|
316
318
|
return super()._get_shared_users(self.endpoint, params)
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
def to_async(self, async_client: 'AsyncGeoboxClient') -> 'AsyncScene':
|
|
322
|
+
"""
|
|
323
|
+
Switch to async version of the scene instance to have access to the async methods
|
|
324
|
+
|
|
325
|
+
Args:
|
|
326
|
+
async_client (AsyncGeoboxClient): The async version of the GeoboxClient instance for making requests.
|
|
327
|
+
|
|
328
|
+
Returns:
|
|
329
|
+
geobox.aio.scene.Scene: the async instance of the scene.
|
|
330
|
+
|
|
331
|
+
Example:
|
|
332
|
+
>>> from geobox import Geoboxclient
|
|
333
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
334
|
+
>>> from geobox.scene import Scene
|
|
335
|
+
>>> client = GeoboxClient()
|
|
336
|
+
>>> scene = Scene.get_scene(client, uuid="12345678-1234-5678-1234-567812345678")
|
|
337
|
+
>>> async with AsyncGeoboxClient() as async_client:
|
|
338
|
+
>>> async_scene = scene.to_async(async_client)
|
|
339
|
+
"""
|
|
340
|
+
from .aio.scene import Scene as AsyncScene
|
|
341
|
+
|
|
342
|
+
return AsyncScene(api=async_client, uuid=self.uuid, data=self.data)
|
geobox/settings.py
CHANGED
|
@@ -8,6 +8,9 @@ from .enums import MaxLogPolicy, InvalidDataPolicy, LoginFailurePolicy, MaxConcu
|
|
|
8
8
|
|
|
9
9
|
if TYPE_CHECKING:
|
|
10
10
|
from . import GeoboxClient
|
|
11
|
+
from .aio import AsyncGeoboxClient
|
|
12
|
+
from .aio.settings import SystemSettings as AsyncSystemSettings
|
|
13
|
+
|
|
11
14
|
|
|
12
15
|
class SystemSettings(Base):
|
|
13
16
|
|
|
@@ -163,4 +166,30 @@ class SystemSettings(Base):
|
|
|
163
166
|
"blocked_ip_addresses": kwargs.get('blocked_ip_addresses'),
|
|
164
167
|
|
|
165
168
|
}
|
|
166
|
-
return super()._update(self.BASE_ENDPOINT, data)
|
|
169
|
+
return super()._update(self.BASE_ENDPOINT, data)
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
def to_async(self, async_client: 'AsyncGeoboxClient') -> 'AsyncSystemSettings':
|
|
173
|
+
"""
|
|
174
|
+
Switch to async version of the system settings instance to have access to the async methods
|
|
175
|
+
|
|
176
|
+
Args:
|
|
177
|
+
async_client (AsyncGeoboxClient): The async version of the GeoboxClient instance for making requests.
|
|
178
|
+
|
|
179
|
+
Returns:
|
|
180
|
+
geobox.aio.settings.SystemSettings: the async instance of the system settings.
|
|
181
|
+
|
|
182
|
+
Example:
|
|
183
|
+
>>> from geobox import Geoboxclient
|
|
184
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
185
|
+
>>> from geobox.setting import SystemSettings
|
|
186
|
+
>>> client = GeoboxClient()
|
|
187
|
+
>>> settings = SystemSetting.get_system_settings(client)
|
|
188
|
+
or
|
|
189
|
+
>>> settings = client.get_system_settings()
|
|
190
|
+
>>> async with AsyncGeoboxClient() as async_client:
|
|
191
|
+
>>> async_settings = settings.to_async(async_client)
|
|
192
|
+
"""
|
|
193
|
+
from .aio.settings import SystemSettings as AsyncSystemSettings
|
|
194
|
+
|
|
195
|
+
return AsyncSystemSettings(api=async_client, data=self.data)
|
geobox/task.py
CHANGED
|
@@ -12,15 +12,12 @@ if TYPE_CHECKING:
|
|
|
12
12
|
from .model3d import Model
|
|
13
13
|
from .file import File
|
|
14
14
|
from .tile3d import Tile3d
|
|
15
|
+
from .aio import AsyncGeoboxClient
|
|
16
|
+
from .aio.task import Task as AsyncTask
|
|
17
|
+
|
|
15
18
|
|
|
16
19
|
class Task(Base):
|
|
17
|
-
"""
|
|
18
|
-
A class to represent a task in Geobox.
|
|
19
20
|
|
|
20
|
-
This class provides functionality to interact with tasks in Geobox.
|
|
21
|
-
It supports various operations including getting tasks, as well as advanced operations like waiting for a task to finish.
|
|
22
|
-
It also provides properties to access the task data, and a method to abort the task.
|
|
23
|
-
"""
|
|
24
21
|
BASE_ENDPOINT: str = 'tasks/'
|
|
25
22
|
|
|
26
23
|
def __init__(self,
|
|
@@ -377,3 +374,28 @@ class Task(Base):
|
|
|
377
374
|
"""
|
|
378
375
|
return super()._get_detail(api, cls.BASE_ENDPOINT, uuid, factory_func=lambda api, item: Task(api, item['uuid'], item))
|
|
379
376
|
|
|
377
|
+
|
|
378
|
+
def to_async(self, async_client: 'AsyncGeoboxClient') -> 'AsyncTask':
|
|
379
|
+
"""
|
|
380
|
+
Switch to async version of the task instance to have access to the async methods
|
|
381
|
+
|
|
382
|
+
Args:
|
|
383
|
+
async_client (AsyncGeoboxClient): The async version of the GeoboxClient instance for making requests.
|
|
384
|
+
|
|
385
|
+
Returns:
|
|
386
|
+
geobox.aio.task.Task: the async instance of the task.
|
|
387
|
+
|
|
388
|
+
Example:
|
|
389
|
+
>>> from geobox import Geoboxclient
|
|
390
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
391
|
+
>>> from geobox.task import Task
|
|
392
|
+
>>> client = GeoboxClient()
|
|
393
|
+
>>> task = Task.get_task(client, uuid="12345678-1234-5678-1234-567812345678")
|
|
394
|
+
or
|
|
395
|
+
>>> task = client.get_task(uuid="12345678-1234-5678-1234-567812345678")
|
|
396
|
+
>>> async with AsyncGeoboxClient() as async_client:
|
|
397
|
+
>>> async_task = task.to_async(async_client)
|
|
398
|
+
"""
|
|
399
|
+
from .aio.task import Task as AsyncTask
|
|
400
|
+
|
|
401
|
+
return AsyncTask(api=async_client, uuid=self.uuid, data=self.data)
|
geobox/tile3d.py
CHANGED
|
@@ -6,6 +6,8 @@ from .base import Base
|
|
|
6
6
|
if TYPE_CHECKING:
|
|
7
7
|
from . import GeoboxClient
|
|
8
8
|
from .user import User
|
|
9
|
+
from .aio import AsyncGeoboxClient
|
|
10
|
+
from .aio.tile3d import Tile3d as AsyncTile3d
|
|
9
11
|
|
|
10
12
|
|
|
11
13
|
class Tile3d(Base):
|
|
@@ -310,4 +312,28 @@ class Tile3d(Base):
|
|
|
310
312
|
>>> tile_json = tile.get_tileset_json()
|
|
311
313
|
"""
|
|
312
314
|
endpoint = urljoin(self.endpoint, 'tileset.json')
|
|
313
|
-
return self.api.get(endpoint)
|
|
315
|
+
return self.api.get(endpoint)
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
def to_async(self, async_client: 'AsyncGeoboxClient') -> 'AsyncTile3d':
|
|
319
|
+
"""
|
|
320
|
+
Switch to async version of the 3d tile instance to have access to the async methods
|
|
321
|
+
|
|
322
|
+
Args:
|
|
323
|
+
async_client (AsyncGeoboxClient): The async version of the GeoboxClient instance for making requests.
|
|
324
|
+
|
|
325
|
+
Returns:
|
|
326
|
+
geobox.aio.tile3d.Tile3d: the async instance of the 3d tile.
|
|
327
|
+
|
|
328
|
+
Example:
|
|
329
|
+
>>> from geobox import Geoboxclient
|
|
330
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
331
|
+
>>> from geobox.tile3d import Tile3d
|
|
332
|
+
>>> client = GeoboxClient()
|
|
333
|
+
>>> tile = Tile3d.get_3dtile(api=client, uuid="12345678-1234-5678-1234-567812345678")
|
|
334
|
+
>>> async with AsyncGeoboxClient() as async_client:
|
|
335
|
+
>>> async_tile = tile.to_async(async_client)
|
|
336
|
+
"""
|
|
337
|
+
from .aio.tile3d import Tile3d as AsyncTile3d
|
|
338
|
+
|
|
339
|
+
return AsyncTile3d(api=async_client, uuid=self.uuid, data=self.data)
|