geobox 2.0.1__py3-none-any.whl → 2.2.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 +61 -63
- geobox/aio/__init__.py +61 -63
- geobox/aio/api.py +489 -473
- geobox/aio/apikey.py +263 -263
- geobox/aio/attachment.py +341 -339
- geobox/aio/base.py +261 -262
- geobox/aio/basemap.py +196 -196
- geobox/aio/dashboard.py +340 -342
- geobox/aio/feature.py +23 -33
- geobox/aio/field.py +315 -321
- geobox/aio/file.py +72 -72
- geobox/aio/layout.py +340 -341
- geobox/aio/log.py +23 -23
- geobox/aio/map.py +1033 -1034
- geobox/aio/model3d.py +415 -415
- geobox/aio/mosaic.py +696 -696
- geobox/aio/plan.py +314 -314
- geobox/aio/query.py +693 -693
- geobox/aio/raster.py +907 -869
- geobox/aio/raster_analysis.py +740 -0
- geobox/aio/route.py +4 -4
- geobox/aio/scene.py +340 -342
- geobox/aio/settings.py +18 -18
- geobox/aio/task.py +404 -402
- geobox/aio/tile3d.py +337 -339
- geobox/aio/tileset.py +102 -103
- geobox/aio/usage.py +52 -51
- geobox/aio/user.py +506 -507
- geobox/aio/vector_tool.py +1968 -0
- geobox/aio/vectorlayer.py +315 -306
- geobox/aio/version.py +272 -273
- geobox/aio/view.py +1019 -983
- geobox/aio/workflow.py +340 -341
- geobox/api.py +18 -2
- geobox/apikey.py +262 -262
- geobox/attachment.py +336 -337
- geobox/base.py +384 -384
- geobox/basemap.py +194 -194
- geobox/dashboard.py +339 -341
- geobox/enums.py +432 -348
- geobox/feature.py +5 -5
- geobox/field.py +320 -320
- geobox/file.py +4 -4
- geobox/layout.py +339 -340
- geobox/log.py +4 -4
- geobox/map.py +1031 -1032
- geobox/model3d.py +410 -410
- geobox/mosaic.py +696 -696
- geobox/plan.py +313 -313
- geobox/query.py +691 -691
- geobox/raster.py +907 -863
- geobox/raster_analysis.py +737 -0
- geobox/scene.py +341 -342
- geobox/settings.py +194 -194
- geobox/task.py +399 -400
- geobox/tile3d.py +337 -338
- geobox/tileset.py +4 -4
- geobox/usage.py +3 -3
- geobox/user.py +503 -503
- geobox/vector_tool.py +1968 -0
- geobox/vectorlayer.py +5 -5
- geobox/version.py +272 -272
- geobox/view.py +981 -981
- geobox/workflow.py +338 -339
- {geobox-2.0.1.dist-info → geobox-2.2.0.dist-info}/METADATA +15 -1
- geobox-2.2.0.dist-info/RECORD +72 -0
- geobox-2.0.1.dist-info/RECORD +0 -68
- {geobox-2.0.1.dist-info → geobox-2.2.0.dist-info}/WHEEL +0 -0
- {geobox-2.0.1.dist-info → geobox-2.2.0.dist-info}/licenses/LICENSE +0 -0
- {geobox-2.0.1.dist-info → geobox-2.2.0.dist-info}/top_level.txt +0 -0
geobox/aio/file.py
CHANGED
|
@@ -7,27 +7,27 @@ import aiohttp
|
|
|
7
7
|
import sys
|
|
8
8
|
|
|
9
9
|
from .base import AsyncBase
|
|
10
|
-
from .task import
|
|
11
|
-
from .feature import
|
|
10
|
+
from .task import AsyncTask
|
|
11
|
+
from .feature import AsyncFeature
|
|
12
12
|
from ..enums import FileFormat, PublishFileType, InputGeomType, FileType
|
|
13
13
|
from ..utils import clean_data, get_save_path, get_unique_filename
|
|
14
14
|
from ..exception import ApiRequestError
|
|
15
15
|
|
|
16
16
|
if TYPE_CHECKING:
|
|
17
17
|
from . import AsyncGeoboxClient
|
|
18
|
-
from .user import
|
|
19
|
-
from ..api import GeoboxClient
|
|
20
|
-
from ..file import File
|
|
18
|
+
from .user import AsyncUser
|
|
19
|
+
from ..api import GeoboxClient
|
|
20
|
+
from ..file import File
|
|
21
21
|
|
|
22
22
|
|
|
23
|
-
class
|
|
23
|
+
class AsyncFile(AsyncBase):
|
|
24
24
|
|
|
25
25
|
BASE_ENDPOINT: str = 'files/'
|
|
26
26
|
|
|
27
27
|
def __init__(self,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
api: 'AsyncGeoboxClient',
|
|
29
|
+
uuid: str,
|
|
30
|
+
data: Optional[Dict] = {}):
|
|
31
31
|
"""
|
|
32
32
|
Constructs all the necessary attributes for the File object.
|
|
33
33
|
|
|
@@ -46,7 +46,7 @@ class File(AsyncBase):
|
|
|
46
46
|
Returns:
|
|
47
47
|
str: A string representation of the File object.
|
|
48
48
|
"""
|
|
49
|
-
return f"
|
|
49
|
+
return f"AsyncFile(uuid={self.uuid}, file_name={self.name}, file_type={self.file_type.value})"
|
|
50
50
|
|
|
51
51
|
|
|
52
52
|
@property
|
|
@@ -84,7 +84,7 @@ class File(AsyncBase):
|
|
|
84
84
|
|
|
85
85
|
|
|
86
86
|
@classmethod
|
|
87
|
-
async def upload_file(cls, api: 'AsyncGeoboxClient', path: str, user_id: int = None, scan_archive: bool = True) -> '
|
|
87
|
+
async def upload_file(cls, api: 'AsyncGeoboxClient', path: str, user_id: int = None, scan_archive: bool = True) -> 'AsyncFile':
|
|
88
88
|
"""
|
|
89
89
|
[async] Upload a file to the GeoBox API.
|
|
90
90
|
|
|
@@ -95,7 +95,7 @@ class File(AsyncBase):
|
|
|
95
95
|
scan_archive (bool, optional): Whether to scan the archive for layers. default: True
|
|
96
96
|
|
|
97
97
|
Returns:
|
|
98
|
-
|
|
98
|
+
AsyncFile: The uploaded file instance.
|
|
99
99
|
|
|
100
100
|
Raises:
|
|
101
101
|
ValueError: If the file type is invalid.
|
|
@@ -103,9 +103,9 @@ class File(AsyncBase):
|
|
|
103
103
|
|
|
104
104
|
Example:
|
|
105
105
|
>>> from geobox.aio import AsyncGeoboxClient
|
|
106
|
-
>>> from geobox.aio.file import
|
|
106
|
+
>>> from geobox.aio.file import AsyncFile
|
|
107
107
|
>>> async with AsyncGeoboxClient() as client:
|
|
108
|
-
>>> file = await
|
|
108
|
+
>>> file = await AsyncFile.upload_file(client, path='path/to/file.shp')
|
|
109
109
|
or
|
|
110
110
|
>>> file = await client.upload_file(path='path/to/file.shp')
|
|
111
111
|
"""
|
|
@@ -125,7 +125,7 @@ class File(AsyncBase):
|
|
|
125
125
|
|
|
126
126
|
|
|
127
127
|
@classmethod
|
|
128
|
-
async def get_files(cls, api:'AsyncGeoboxClient', **kwargs) -> Union[List['
|
|
128
|
+
async def get_files(cls, api:'AsyncGeoboxClient', **kwargs) -> Union[List['AsyncFile'], int]:
|
|
129
129
|
"""
|
|
130
130
|
[async] Retrieves a list of files.
|
|
131
131
|
|
|
@@ -144,13 +144,13 @@ class File(AsyncBase):
|
|
|
144
144
|
shared (bool): Whether to return shared files. default is False.
|
|
145
145
|
|
|
146
146
|
Returns:
|
|
147
|
-
List[
|
|
147
|
+
List[AsyncFile] | int: A list of File objects or the total number of results.
|
|
148
148
|
|
|
149
149
|
Example:
|
|
150
150
|
>>> from geobox.aio import AsyncGeoboxClient
|
|
151
|
-
>>> from geobox.aio.file import
|
|
151
|
+
>>> from geobox.aio.file import AsyncFile
|
|
152
152
|
>>> async with AsyncGeoboxClient() as client:
|
|
153
|
-
>>> files = await
|
|
153
|
+
>>> files = await AsyncFile.get_files(client, search_fields='name', search='GIS', order_by='name', skip=10, limit=10)
|
|
154
154
|
or
|
|
155
155
|
>>> files = await client.get_files(search_fields='name', search='GIS', order_by='name', skip=10, limit=10)
|
|
156
156
|
"""
|
|
@@ -170,7 +170,7 @@ class File(AsyncBase):
|
|
|
170
170
|
|
|
171
171
|
|
|
172
172
|
@classmethod
|
|
173
|
-
async def get_file(cls, api: 'AsyncGeoboxClient', uuid: str, user_id: int = None) -> '
|
|
173
|
+
async def get_file(cls, api: 'AsyncGeoboxClient', uuid: str, user_id: int = None) -> 'AsyncFile':
|
|
174
174
|
"""
|
|
175
175
|
[async] Retrieves a file by its UUID.
|
|
176
176
|
|
|
@@ -180,16 +180,16 @@ class File(AsyncBase):
|
|
|
180
180
|
user_id (int, optional): specific user. privileges required.
|
|
181
181
|
|
|
182
182
|
Returns:
|
|
183
|
-
|
|
183
|
+
AsyncFile: The retrieved file instance.
|
|
184
184
|
|
|
185
185
|
Raises:
|
|
186
186
|
NotFoundError: If the file with the specified UUID is not found.
|
|
187
187
|
|
|
188
188
|
Example:
|
|
189
189
|
>>> from geobox.aio import AsyncGeoboxClient
|
|
190
|
-
>>> from geobox.aio.file import
|
|
190
|
+
>>> from geobox.aio.file import AsyncFile
|
|
191
191
|
>>> async with AsyncGeoboxClient() as client:
|
|
192
|
-
>>> file = await
|
|
192
|
+
>>> file = await AsyncFile.get_file(client, uuid="12345678-1234-5678-1234-567812345678")
|
|
193
193
|
or
|
|
194
194
|
>>> file = await client.get_file(uuid="12345678-1234-5678-1234-567812345678")
|
|
195
195
|
"""
|
|
@@ -197,11 +197,11 @@ class File(AsyncBase):
|
|
|
197
197
|
'f': 'json',
|
|
198
198
|
'user_id': user_id
|
|
199
199
|
}
|
|
200
|
-
return await super()._get_detail(api, cls.BASE_ENDPOINT, f'{uuid}/info', params, factory_func=lambda api, item:
|
|
200
|
+
return await super()._get_detail(api, cls.BASE_ENDPOINT, f'{uuid}/info', params, factory_func=lambda api, item: AsyncFile(api, item['uuid'], item))
|
|
201
201
|
|
|
202
202
|
|
|
203
203
|
@classmethod
|
|
204
|
-
async def get_files_by_name(cls, api: 'AsyncGeoboxClient', name: str, user_id: int = None) -> List['
|
|
204
|
+
async def get_files_by_name(cls, api: 'AsyncGeoboxClient', name: str, user_id: int = None) -> List['AsyncFile']:
|
|
205
205
|
"""
|
|
206
206
|
[async] Get files by name
|
|
207
207
|
|
|
@@ -211,13 +211,13 @@ class File(AsyncBase):
|
|
|
211
211
|
user_id (int, optional): specific user. privileges required.
|
|
212
212
|
|
|
213
213
|
Returns:
|
|
214
|
-
List[
|
|
214
|
+
List[AsyncFile]: returns files that matches the given name
|
|
215
215
|
|
|
216
216
|
Example:
|
|
217
217
|
>>> from geobox.aio import AsyncGeoboxClient
|
|
218
|
-
>>> from geobox.aio.file import
|
|
218
|
+
>>> from geobox.aio.file import AsyncFile
|
|
219
219
|
>>> async with AsyncGeoboxClient() as client:
|
|
220
|
-
>>> files = await
|
|
220
|
+
>>> files = await AsyncFile.get_files_by_name(client, name='test')
|
|
221
221
|
or
|
|
222
222
|
>>> files = await client.get_files_by_name(name='test')
|
|
223
223
|
"""
|
|
@@ -253,14 +253,14 @@ class File(AsyncBase):
|
|
|
253
253
|
return None
|
|
254
254
|
|
|
255
255
|
return tqdm(unit="B",
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
256
|
+
total=int(self.size),
|
|
257
|
+
file=sys.stdout,
|
|
258
|
+
dynamic_ncols=True,
|
|
259
|
+
desc="Downloading",
|
|
260
|
+
unit_scale=True,
|
|
261
|
+
unit_divisor=1024,
|
|
262
|
+
ascii=True
|
|
263
|
+
)
|
|
264
264
|
|
|
265
265
|
|
|
266
266
|
async def download(self, save_path: str = None, progress_bar: bool = True, file_name: str = None, overwrite: bool = False) -> str:
|
|
@@ -284,9 +284,9 @@ class File(AsyncBase):
|
|
|
284
284
|
|
|
285
285
|
Example:
|
|
286
286
|
>>> from geobox.aio import AsyncGeoboxClient
|
|
287
|
-
>>> from geobox.aio.file import
|
|
287
|
+
>>> from geobox.aio.file import AsyncFile
|
|
288
288
|
>>> async with AsyncGeoboxClient() as client:
|
|
289
|
-
>>> file = await
|
|
289
|
+
>>> file = await AsyncFile.get_file(client, uuid="12345678-1234-5678-1234-567812345678")
|
|
290
290
|
>>> await file.download(save_path='path/to/save/')
|
|
291
291
|
"""
|
|
292
292
|
if not self.uuid:
|
|
@@ -331,26 +331,26 @@ class File(AsyncBase):
|
|
|
331
331
|
|
|
332
332
|
Example:
|
|
333
333
|
>>> from geobox.aio import AsyncGeoboxClient
|
|
334
|
-
>>> from geobox.aio.file import
|
|
334
|
+
>>> from geobox.aio.file import AsyncFile
|
|
335
335
|
>>> async with AsyncGeoboxClient() as client:
|
|
336
|
-
>>> file = await
|
|
336
|
+
>>> file = await AsyncFile.get_file(client, uuid="12345678-1234-5678-1234-567812345678")
|
|
337
337
|
>>> await file.delete()
|
|
338
338
|
"""
|
|
339
|
-
return await super().
|
|
339
|
+
return await super()._delete(self.endpoint)
|
|
340
340
|
|
|
341
341
|
|
|
342
342
|
async def publish(self,
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
343
|
+
name: str,
|
|
344
|
+
publish_as: 'PublishFileType' = None,
|
|
345
|
+
input_geom_type: 'InputGeomType' = None,
|
|
346
|
+
input_layer: str = None,
|
|
347
|
+
input_dataset: str = None,
|
|
348
|
+
user_id: int = None,
|
|
349
|
+
input_srid: int = AsyncFeature.BASE_SRID,
|
|
350
|
+
file_encoding: str = "UTF-8",
|
|
351
|
+
replace_domain_codes_by_values: bool = False,
|
|
352
|
+
report_errors: bool = True,
|
|
353
|
+
as_terrain: bool = False) -> 'AsyncTask':
|
|
354
354
|
"""
|
|
355
355
|
[async] Publishes a file as a layer.
|
|
356
356
|
|
|
@@ -376,9 +376,9 @@ class File(AsyncBase):
|
|
|
376
376
|
|
|
377
377
|
Example:
|
|
378
378
|
>>> from geobox.aio import AsyncGeoboxClient
|
|
379
|
-
>>> from geobox.aio.file import
|
|
379
|
+
>>> from geobox.aio.file import AsyncFile
|
|
380
380
|
>>> async with AsyncGeoboxClient() as client:
|
|
381
|
-
>>> file = await
|
|
381
|
+
>>> file = await AsyncFile.get_file(client, uuid="12345678-1234-5678-1234-567812345678")
|
|
382
382
|
>>> await file.publish(publish_as=PublishFileType.VECTOR,
|
|
383
383
|
... layer_name='my_layer',
|
|
384
384
|
... input_geom_type=InputGeomType.POINT,
|
|
@@ -425,11 +425,11 @@ class File(AsyncBase):
|
|
|
425
425
|
})
|
|
426
426
|
endpoint = urljoin(self.endpoint, 'publish/')
|
|
427
427
|
response = await self.api.post(endpoint, data, is_json=False)
|
|
428
|
-
task = await
|
|
428
|
+
task = await AsyncTask.get_task(self.api, response.get('task_id'))
|
|
429
429
|
return task
|
|
430
430
|
|
|
431
431
|
|
|
432
|
-
async def share(self, users: List['
|
|
432
|
+
async def share(self, users: List['AsyncUser']) -> None:
|
|
433
433
|
"""
|
|
434
434
|
[async] Shares the file with specified users.
|
|
435
435
|
|
|
@@ -441,37 +441,37 @@ class File(AsyncBase):
|
|
|
441
441
|
|
|
442
442
|
Example:
|
|
443
443
|
>>> from geobox.aio import AsyncGeoboxClient
|
|
444
|
-
>>> from geobox.aio.file import
|
|
444
|
+
>>> from geobox.aio.file import AsyncFile
|
|
445
445
|
>>> async with AsyncGeoboxClient() as client:
|
|
446
|
-
>>> file = await
|
|
446
|
+
>>> file = await AsyncFile.get_file(client, uuid="12345678-1234-5678-1234-567812345678")
|
|
447
447
|
>>> users = await client.search_users(search='John')
|
|
448
448
|
>>> await file.share(users=users)
|
|
449
449
|
"""
|
|
450
450
|
await super()._share(self.endpoint, users)
|
|
451
451
|
|
|
452
452
|
|
|
453
|
-
async def unshare(self, users: List['
|
|
453
|
+
async def unshare(self, users: List['AsyncUser']) -> None:
|
|
454
454
|
"""
|
|
455
455
|
[async] Unshares the file with specified users.
|
|
456
456
|
|
|
457
457
|
Args:
|
|
458
|
-
users (List[
|
|
458
|
+
users (List[AsyncUser]): The list of users objects to unshare the file with.
|
|
459
459
|
|
|
460
460
|
Returns:
|
|
461
461
|
None
|
|
462
462
|
|
|
463
463
|
Example:
|
|
464
464
|
>>> from geobox.aio import AsyncGeoboxClient
|
|
465
|
-
>>> from geobox.aio.file import
|
|
465
|
+
>>> from geobox.aio.file import AsyncFile
|
|
466
466
|
>>> async with AsyncGeoboxClient() as client:
|
|
467
|
-
>>> file = await
|
|
467
|
+
>>> file = await AsyncFile.get_file(client, uuid="12345678-1234-5678-1234-567812345678")
|
|
468
468
|
>>> await users = client.search_users(search='John')
|
|
469
469
|
>>> await file.unshare(users=users)
|
|
470
470
|
"""
|
|
471
471
|
await super()._unshare(self.endpoint, users)
|
|
472
472
|
|
|
473
473
|
|
|
474
|
-
async def get_shared_users(self, search: str = None, skip: int = 0, limit: int = 10) -> List['
|
|
474
|
+
async def get_shared_users(self, search: str = None, skip: int = 0, limit: int = 10) -> List['AsyncUser']:
|
|
475
475
|
"""
|
|
476
476
|
[async] Retrieves the list of users the file is shared with.
|
|
477
477
|
|
|
@@ -481,13 +481,13 @@ class File(AsyncBase):
|
|
|
481
481
|
limit (int, optional): The maximum number of users to retrieve.
|
|
482
482
|
|
|
483
483
|
Returns:
|
|
484
|
-
List[
|
|
484
|
+
List[AsyncUser]: The list of shared users.
|
|
485
485
|
|
|
486
486
|
Example:
|
|
487
487
|
>>> from geobox.aio import AsyncGeoboxClient
|
|
488
|
-
>>> from geobox.aio.file import
|
|
488
|
+
>>> from geobox.aio.file import AsyncFile
|
|
489
489
|
>>> async with AsyncGeoboxClient() as client:
|
|
490
|
-
>>> file = await
|
|
490
|
+
>>> file = await AsyncFile.get_file(client, uuid="12345678-1234-5678-1234-567812345678")
|
|
491
491
|
>>> await file.get_shared_users(search='John', skip=0, limit=10)
|
|
492
492
|
"""
|
|
493
493
|
params = {
|
|
@@ -498,25 +498,25 @@ class File(AsyncBase):
|
|
|
498
498
|
return await super()._get_shared_users(self.endpoint, params)
|
|
499
499
|
|
|
500
500
|
|
|
501
|
-
def to_sync(self, sync_client: '
|
|
501
|
+
def to_sync(self, sync_client: 'GeoboxClient') -> 'File':
|
|
502
502
|
"""
|
|
503
503
|
Switch to sync version of the file instance to have access to the sync methods
|
|
504
504
|
|
|
505
505
|
Args:
|
|
506
|
-
sync_client (
|
|
506
|
+
sync_client (GeoboxClient): The sync version of the GeoboxClient instance for making requests.
|
|
507
507
|
|
|
508
508
|
Returns:
|
|
509
|
-
|
|
509
|
+
File: the async instance of the file.
|
|
510
510
|
|
|
511
511
|
Example:
|
|
512
512
|
>>> from geobox import Geoboxclient
|
|
513
513
|
>>> from geobox.aio import AsyncGeoboxClient
|
|
514
|
-
>>> from geobox.aio.file import
|
|
514
|
+
>>> from geobox.aio.file import AsyncFile
|
|
515
515
|
>>> client = GeoboxClient()
|
|
516
516
|
>>> async with AsyncGeoboxClient() as async_client:
|
|
517
|
-
>>> file = await
|
|
517
|
+
>>> file = await AsyncFile.get_file(async_client, uuid="12345678-1234-5678-1234-567812345678")
|
|
518
518
|
>>> sync_file = file.to_sync(client)
|
|
519
519
|
"""
|
|
520
|
-
from ..file import File
|
|
520
|
+
from ..file import File
|
|
521
521
|
|
|
522
|
-
return
|
|
522
|
+
return File(api=sync_client, uuid=self.uuid, data=self.data)
|