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.
Files changed (70) hide show
  1. geobox/__init__.py +61 -63
  2. geobox/aio/__init__.py +61 -63
  3. geobox/aio/api.py +489 -473
  4. geobox/aio/apikey.py +263 -263
  5. geobox/aio/attachment.py +341 -339
  6. geobox/aio/base.py +261 -262
  7. geobox/aio/basemap.py +196 -196
  8. geobox/aio/dashboard.py +340 -342
  9. geobox/aio/feature.py +23 -33
  10. geobox/aio/field.py +315 -321
  11. geobox/aio/file.py +72 -72
  12. geobox/aio/layout.py +340 -341
  13. geobox/aio/log.py +23 -23
  14. geobox/aio/map.py +1033 -1034
  15. geobox/aio/model3d.py +415 -415
  16. geobox/aio/mosaic.py +696 -696
  17. geobox/aio/plan.py +314 -314
  18. geobox/aio/query.py +693 -693
  19. geobox/aio/raster.py +907 -869
  20. geobox/aio/raster_analysis.py +740 -0
  21. geobox/aio/route.py +4 -4
  22. geobox/aio/scene.py +340 -342
  23. geobox/aio/settings.py +18 -18
  24. geobox/aio/task.py +404 -402
  25. geobox/aio/tile3d.py +337 -339
  26. geobox/aio/tileset.py +102 -103
  27. geobox/aio/usage.py +52 -51
  28. geobox/aio/user.py +506 -507
  29. geobox/aio/vector_tool.py +1968 -0
  30. geobox/aio/vectorlayer.py +315 -306
  31. geobox/aio/version.py +272 -273
  32. geobox/aio/view.py +1019 -983
  33. geobox/aio/workflow.py +340 -341
  34. geobox/api.py +18 -2
  35. geobox/apikey.py +262 -262
  36. geobox/attachment.py +336 -337
  37. geobox/base.py +384 -384
  38. geobox/basemap.py +194 -194
  39. geobox/dashboard.py +339 -341
  40. geobox/enums.py +432 -348
  41. geobox/feature.py +5 -5
  42. geobox/field.py +320 -320
  43. geobox/file.py +4 -4
  44. geobox/layout.py +339 -340
  45. geobox/log.py +4 -4
  46. geobox/map.py +1031 -1032
  47. geobox/model3d.py +410 -410
  48. geobox/mosaic.py +696 -696
  49. geobox/plan.py +313 -313
  50. geobox/query.py +691 -691
  51. geobox/raster.py +907 -863
  52. geobox/raster_analysis.py +737 -0
  53. geobox/scene.py +341 -342
  54. geobox/settings.py +194 -194
  55. geobox/task.py +399 -400
  56. geobox/tile3d.py +337 -338
  57. geobox/tileset.py +4 -4
  58. geobox/usage.py +3 -3
  59. geobox/user.py +503 -503
  60. geobox/vector_tool.py +1968 -0
  61. geobox/vectorlayer.py +5 -5
  62. geobox/version.py +272 -272
  63. geobox/view.py +981 -981
  64. geobox/workflow.py +338 -339
  65. {geobox-2.0.1.dist-info → geobox-2.2.0.dist-info}/METADATA +15 -1
  66. geobox-2.2.0.dist-info/RECORD +72 -0
  67. geobox-2.0.1.dist-info/RECORD +0 -68
  68. {geobox-2.0.1.dist-info → geobox-2.2.0.dist-info}/WHEEL +0 -0
  69. {geobox-2.0.1.dist-info → geobox-2.2.0.dist-info}/licenses/LICENSE +0 -0
  70. {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 Task
11
- from .feature import Feature
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 User
19
- from ..api import GeoboxClient as SyncGeoboxClient
20
- from ..file import File as SyncFile
18
+ from .user import AsyncUser
19
+ from ..api import GeoboxClient
20
+ from ..file import File
21
21
 
22
22
 
23
- class File(AsyncBase):
23
+ class AsyncFile(AsyncBase):
24
24
 
25
25
  BASE_ENDPOINT: str = 'files/'
26
26
 
27
27
  def __init__(self,
28
- api: 'AsyncGeoboxClient',
29
- uuid: str,
30
- data: Optional[Dict] = {}):
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"File(uuid={self.uuid}, file_name={self.name}, file_type={self.file_type.value})"
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) -> 'File':
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
- File: The uploaded file instance.
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 File
106
+ >>> from geobox.aio.file import AsyncFile
107
107
  >>> async with AsyncGeoboxClient() as client:
108
- >>> file = await File.upload_file(client, path='path/to/file.shp')
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['File'], int]:
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[File] | int: A list of File objects or the total number of results.
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 File
151
+ >>> from geobox.aio.file import AsyncFile
152
152
  >>> async with AsyncGeoboxClient() as client:
153
- >>> files = await File.get_files(client, search_fields='name', search='GIS', order_by='name', skip=10, limit=10)
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) -> 'File':
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
- File: The retrieved file instance.
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 File
190
+ >>> from geobox.aio.file import AsyncFile
191
191
  >>> async with AsyncGeoboxClient() as client:
192
- >>> file = await File.get_file(client, uuid="12345678-1234-5678-1234-567812345678")
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: File(api, item['uuid'], 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['File']:
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[File]: returns files that matches the given name
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 File
218
+ >>> from geobox.aio.file import AsyncFile
219
219
  >>> async with AsyncGeoboxClient() as client:
220
- >>> files = await File.get_files_by_name(client, name='test')
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
- 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
- )
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 File
287
+ >>> from geobox.aio.file import AsyncFile
288
288
  >>> async with AsyncGeoboxClient() as client:
289
- >>> file = await File.get_file(client, uuid="12345678-1234-5678-1234-567812345678")
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 File
334
+ >>> from geobox.aio.file import AsyncFile
335
335
  >>> async with AsyncGeoboxClient() as client:
336
- >>> file = await File.get_file(client, uuid="12345678-1234-5678-1234-567812345678")
336
+ >>> file = await AsyncFile.get_file(client, uuid="12345678-1234-5678-1234-567812345678")
337
337
  >>> await file.delete()
338
338
  """
339
- return await super().delete(self.endpoint)
339
+ return await super()._delete(self.endpoint)
340
340
 
341
341
 
342
342
  async def publish(self,
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 = Feature.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) -> 'Task':
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 File
379
+ >>> from geobox.aio.file import AsyncFile
380
380
  >>> async with AsyncGeoboxClient() as client:
381
- >>> file = await File.get_file(client, uuid="12345678-1234-5678-1234-567812345678")
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 Task.get_task(self.api, response.get('task_id'))
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['User']) -> None:
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 File
444
+ >>> from geobox.aio.file import AsyncFile
445
445
  >>> async with AsyncGeoboxClient() as client:
446
- >>> file = await File.get_file(client, uuid="12345678-1234-5678-1234-567812345678")
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['User']) -> None:
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[User]): The list of users objects to unshare the file with.
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 File
465
+ >>> from geobox.aio.file import AsyncFile
466
466
  >>> async with AsyncGeoboxClient() as client:
467
- >>> file = await File.get_file(client, uuid="12345678-1234-5678-1234-567812345678")
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['User']:
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[User]: The list of shared users.
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 File
488
+ >>> from geobox.aio.file import AsyncFile
489
489
  >>> async with AsyncGeoboxClient() as client:
490
- >>> file = await File.get_file(client, uuid="12345678-1234-5678-1234-567812345678")
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: 'SyncGeoboxClient') -> 'SyncFile':
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 (SyncGeoboxClient): The sync version of the GeoboxClient instance for making requests.
506
+ sync_client (GeoboxClient): The sync version of the GeoboxClient instance for making requests.
507
507
 
508
508
  Returns:
509
- geobox.file.File: the async instance of the file.
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 File
514
+ >>> from geobox.aio.file import AsyncFile
515
515
  >>> client = GeoboxClient()
516
516
  >>> async with AsyncGeoboxClient() as async_client:
517
- >>> file = await File.get_file(async_client, uuid="12345678-1234-5678-1234-567812345678")
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 as SyncFile
520
+ from ..file import File
521
521
 
522
- return SyncFile(api=sync_client, uuid=self.uuid, data=self.data)
522
+ return File(api=sync_client, uuid=self.uuid, data=self.data)