geobox 1.4.2__py3-none-any.whl → 2.0.1__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 (66) hide show
  1. geobox/__init__.py +2 -2
  2. geobox/aio/__init__.py +63 -0
  3. geobox/aio/api.py +2640 -0
  4. geobox/aio/apikey.py +263 -0
  5. geobox/aio/attachment.py +339 -0
  6. geobox/aio/base.py +262 -0
  7. geobox/aio/basemap.py +196 -0
  8. geobox/aio/dashboard.py +342 -0
  9. geobox/aio/feature.py +527 -0
  10. geobox/aio/field.py +321 -0
  11. geobox/aio/file.py +522 -0
  12. geobox/aio/layout.py +341 -0
  13. geobox/aio/log.py +145 -0
  14. geobox/aio/map.py +1034 -0
  15. geobox/aio/model3d.py +415 -0
  16. geobox/aio/mosaic.py +696 -0
  17. geobox/aio/plan.py +315 -0
  18. geobox/aio/query.py +693 -0
  19. geobox/aio/raster.py +869 -0
  20. geobox/aio/route.py +63 -0
  21. geobox/aio/scene.py +342 -0
  22. geobox/aio/settings.py +194 -0
  23. geobox/aio/task.py +402 -0
  24. geobox/aio/tile3d.py +339 -0
  25. geobox/aio/tileset.py +672 -0
  26. geobox/aio/usage.py +243 -0
  27. geobox/aio/user.py +507 -0
  28. geobox/aio/vectorlayer.py +1363 -0
  29. geobox/aio/version.py +273 -0
  30. geobox/aio/view.py +983 -0
  31. geobox/aio/workflow.py +341 -0
  32. geobox/api.py +14 -15
  33. geobox/apikey.py +28 -1
  34. geobox/attachment.py +27 -1
  35. geobox/base.py +4 -4
  36. geobox/basemap.py +30 -1
  37. geobox/dashboard.py +27 -0
  38. geobox/feature.py +33 -13
  39. geobox/field.py +33 -21
  40. geobox/file.py +40 -46
  41. geobox/layout.py +28 -1
  42. geobox/log.py +31 -7
  43. geobox/map.py +34 -2
  44. geobox/model3d.py +31 -37
  45. geobox/mosaic.py +28 -7
  46. geobox/plan.py +29 -3
  47. geobox/query.py +39 -14
  48. geobox/raster.py +26 -13
  49. geobox/scene.py +26 -0
  50. geobox/settings.py +30 -1
  51. geobox/task.py +28 -6
  52. geobox/tile3d.py +27 -1
  53. geobox/tileset.py +26 -5
  54. geobox/usage.py +32 -1
  55. geobox/user.py +62 -6
  56. geobox/utils.py +34 -0
  57. geobox/vectorlayer.py +40 -4
  58. geobox/version.py +25 -1
  59. geobox/view.py +37 -17
  60. geobox/workflow.py +27 -1
  61. {geobox-1.4.2.dist-info → geobox-2.0.1.dist-info}/METADATA +4 -1
  62. geobox-2.0.1.dist-info/RECORD +68 -0
  63. geobox-1.4.2.dist-info/RECORD +0 -38
  64. {geobox-1.4.2.dist-info → geobox-2.0.1.dist-info}/WHEEL +0 -0
  65. {geobox-1.4.2.dist-info → geobox-2.0.1.dist-info}/licenses/LICENSE +0 -0
  66. {geobox-1.4.2.dist-info → geobox-2.0.1.dist-info}/top_level.txt +0 -0
geobox/aio/tile3d.py ADDED
@@ -0,0 +1,339 @@
1
+ from typing import List, Dict, Optional, TYPE_CHECKING, Union
2
+ from urllib.parse import urljoin
3
+
4
+ from .base import AsyncBase
5
+
6
+ if TYPE_CHECKING:
7
+ from . import AsyncGeoboxClient
8
+ from .user import User
9
+ from ..api import GeoboxClient as SyncGeoboxClient
10
+ from ..tile3d import Tile3d as SyncTile3d
11
+
12
+
13
+ class Tile3d(AsyncBase):
14
+
15
+ BASE_ENDPOINT = '3dtiles/'
16
+
17
+ def __init__(self,
18
+ api: 'AsyncGeoboxClient',
19
+ uuid: str,
20
+ data: Optional[Dict] = {}):
21
+ """
22
+ Initialize a 3D Tile instance.
23
+
24
+ Args:
25
+ api (AsyncGeoboxClient): The AsyncGeoboxClient instance for making requests.
26
+ name (str): The name of the 3D Tile.
27
+ uuid (str): The unique identifier for the 3D Tile.
28
+ data (Dict): The data of the 3D Tile.
29
+ """
30
+ super().__init__(api, uuid=uuid, data=data)
31
+
32
+
33
+ @classmethod
34
+ async def get_3dtiles(cls, api: 'AsyncGeoboxClient', **kwargs) -> Union[List['Tile3d'], int]:
35
+ """
36
+ [async] Get list of 3D Tiles with optional filtering and pagination.
37
+
38
+ Args:
39
+ api (AsyncGeoboxClient): The AsyncGeoboxClient instance for making requests.
40
+
41
+ Keyword Args:
42
+ q (str): query filter based on OGC CQL standard. e.g. "field1 LIKE '%GIS%' AND created_at > '2021-01-01'"
43
+ 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.
44
+ search_fields (str): comma separated list of fields for searching.
45
+ 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.
46
+ return_count (bool): Whether to return total count. default is False.
47
+ skip (int): Number of items to skip. default is 0.
48
+ limit (int): Number of items to return. default is 10.
49
+ user_id (int): Specific user. privileges required.
50
+ shared (bool): Whether to return shared maps. default is False.
51
+
52
+ Returns:
53
+ List[Tile3d] | int: A list of 3D Tile instances or the total number of 3D Tiles.
54
+
55
+ Example:
56
+ >>> from geobox.aio import AsyncGeoboxClient
57
+ >>> from geobox.aio.tile3d import Tile3d
58
+ >>> async with AsyncGeoboxClient() as client:
59
+ >>> tiles = await Tile3d.get_3dtiles(client, q="name LIKE '%My tile%'")
60
+ or
61
+ >>> tiles = await client.get_3dtiles(q="name LIKE '%My tile%'")
62
+ """
63
+ params = {
64
+ 'f': 'json',
65
+ 'q': kwargs.get('q'),
66
+ 'search': kwargs.get('search'),
67
+ 'search_fields': kwargs.get('search_fields'),
68
+ 'order_by': kwargs.get('order_by'),
69
+ 'return_count': kwargs.get('return_count', False),
70
+ 'skip': kwargs.get('skip', 0),
71
+ 'limit': kwargs.get('limit', 10),
72
+ 'user_id': kwargs.get('user_id'),
73
+ 'shared': kwargs.get('shared', False)
74
+ }
75
+ return await super()._get_list(api, cls.BASE_ENDPOINT, params, factory_func=lambda api, item: Tile3d(api, item['uuid'], item))
76
+
77
+
78
+ @classmethod
79
+ async def get_3dtile(cls, api: 'AsyncGeoboxClient', uuid: str, user_id: int = None) -> 'Tile3d':
80
+ """
81
+ [async] Get a 3D Tile by its UUID.
82
+
83
+ Args:
84
+ api (AsyncGeoboxClient): The AsyncGeoboxClient instance for making requests.
85
+ uuid (str): The UUID of the map to 3D Tile.
86
+ user_id (int): Specific user. privileges required.
87
+
88
+ Returns:
89
+ Tile3d: The 3D Tile object.
90
+
91
+ Raises:
92
+ NotFoundError: If the 3D Tile with the specified UUID is not found.
93
+
94
+ Example:
95
+ >>> from geobox.aio import AsyncGeoboxClient
96
+ >>> from geobox.aio.tile3d import Tile3d
97
+ >>> async with AsyncGeoboxClient() as client:
98
+ >>> tile = await Tile3d.get_3dtile(client, uuid="12345678-1234-5678-1234-567812345678")
99
+ or
100
+ >>> tile = await client.get_3dtile(uuid="12345678-1234-5678-1234-567812345678")
101
+ """
102
+ params = {
103
+ 'f': 'json',
104
+ 'user_id': user_id,
105
+ }
106
+ return await super()._get_detail(api, cls.BASE_ENDPOINT, uuid, params, factory_func=lambda api, item: Tile3d(api, item['uuid'], item))
107
+
108
+
109
+ @classmethod
110
+ async def get_3dtile_by_name(cls, api: 'AsyncGeoboxClient', name: str, user_id: int = None) -> Union['Tile3d', None]:
111
+ """
112
+ [async] Get a 3dtile by name
113
+
114
+ Args:
115
+ api (AsyncGeoboxClient): The AsyncGeoboxClient instance for making requests.
116
+ name (str): the name of the 3dtile to get
117
+ user_id (int, optional): specific user. privileges required.
118
+
119
+ Returns:
120
+ Tile3d | None: returns the 3dtile if a 3dtile matches the given name, else None
121
+
122
+ Example:
123
+ >>> from geobox.aio import AsyncGeoboxClient
124
+ >>> from geobox.aio.tile3d import Tile3d
125
+ >>> async with AsyncGeoboxClient() as client:
126
+ >>> tile3d = await Tile3d.get_3dtile_by_name(client, name='test')
127
+ or
128
+ >>> tile3d = await client.get_3dtile_by_name(name='test')
129
+ """
130
+ tile3ds = await cls.get_3dtiles(api, q=f"name = '{name}'", user_id=user_id)
131
+ if tile3ds and tile3ds[0].name == name:
132
+ return tile3ds[0]
133
+ else:
134
+ return None
135
+
136
+
137
+ async def update(self, **kwargs) -> Dict:
138
+ """
139
+ [async] Update the 3D Tile.
140
+
141
+ Keyword Args:
142
+ name (str): The name of the 3D Tile.
143
+ display_name (str): The display name of the 3D Tile.
144
+ description (str): The description of the 3D Tile.
145
+ settings (Dict): The settings of the 3D Tile.
146
+ thumbnail (str): The thumbnail of the 3D Tile.
147
+
148
+ Returns:
149
+ Dict: The updated 3D Tile data.
150
+
151
+ Raises:
152
+ ApiRequestError: If the API request fails.
153
+ ValidationError: If the 3D Tile data is invalid.
154
+
155
+ Example:
156
+ >>> from geobox.aio import AsyncGeoboxClient
157
+ >>> from geobox.aio.tile3d import Tile3d
158
+ >>> async with AsyncGeoboxClient() as client:
159
+ >>> tile = await Tile3d.get_3dtile(client, uuid="12345678-1234-5678-1234-567812345678")
160
+ >>> await tile.update_3dtile(display_name="New Display Name")
161
+ """
162
+ data = {
163
+ "name": kwargs.get('name'),
164
+ "display_name": kwargs.get('display_name'),
165
+ "description": kwargs.get('description'),
166
+ "settings": kwargs.get('settings'),
167
+ "thumbnail": kwargs.get('thumbnail'),
168
+ }
169
+ return await super()._update(self.endpoint, data)
170
+
171
+
172
+ async def delete(self) -> None:
173
+ """
174
+ [async] Delete the 3D Tile.
175
+
176
+ Returns:
177
+ None
178
+
179
+ Example:
180
+ >>> from geobox.aio import AsyncGeoboxClient
181
+ >>> from geobox.aio.tile3d import Tile3d
182
+ >>> async with AsyncGeoboxClient() as client:
183
+ >>> tile = await Map.get_3dtile(client, uuid="12345678-1234-5678-1234-567812345678")
184
+ >>> await tile.delete()
185
+ """
186
+ await super().delete(self.endpoint)
187
+
188
+
189
+ @property
190
+ def thumbnail(self) -> str:
191
+ """
192
+ Get the thumbnail URL of the 3D Tile.
193
+
194
+ Returns:
195
+ str: The thumbnail url of the 3D Tile.
196
+
197
+ Example:
198
+ >>> from geobox.aio import AsyncGeoboxClient
199
+ >>> from geobox.aio.tile3d import Tile3d
200
+ >>> async with AsyncGeoboxClient() as client:
201
+ >>> tile = await Tile3d.get_3dtile(client, uuid="12345678-1234-5678-1234-567812345678")
202
+ >>> tile.thumbnail
203
+ 'https://example.com/thumbnail.png'
204
+ """
205
+ return super().thumbnail()
206
+
207
+
208
+ async def get_item(self, path: str) -> Dict:
209
+ """
210
+ [async] Get an Item from 3D Tiles
211
+
212
+ Args:
213
+ path (str): the path of the item.
214
+
215
+ Returns:
216
+ Dict: the data of the item.
217
+
218
+ Example:
219
+ >>> from geobox.aio import AsyncGeoboxClient
220
+ >>> from geobox.aio.tile3d import Tile3d
221
+ >>> async with AsyncGeoboxClient() as client:
222
+ >>> tile = await Tile3d.get_3dtile(client, uuid="12345678-1234-5678-1234-567812345678")
223
+ or
224
+ >>> tile = await client.get_3dtile(uuid="12345678-1234-5678-1234-567812345678")
225
+ >>> item = await tile.get_item()
226
+ """
227
+ endpoint = f"{self.endpoint}{path}"
228
+ return await self.api.get(endpoint)
229
+
230
+
231
+ async def share(self, users: List['User']) -> None:
232
+ """
233
+ [async] Shares the 3D Tile with specified users.
234
+
235
+ Args:
236
+ users (List[User]): The list of user objects to share the 3D Tile with.
237
+
238
+ Returns:
239
+ None
240
+
241
+ Example:
242
+ >>> from geobox.aio import AsyncGeoboxClient
243
+ >>> from geobox.aio.tile3d import Tile3d
244
+ >>> async with AsyncGeoboxClient() as client:
245
+ >>> tile = await Tile3d.get_3dtile(client, uuid="12345678-1234-5678-1234-567812345678")
246
+ >>> users = await client.search_users(search='John')
247
+ >>> await tile.share(users=users)
248
+ """
249
+ await super()._share(self.endpoint, users)
250
+
251
+
252
+ async def unshare(self, users: List['User']) -> None:
253
+ """
254
+ [async] Unshares the 3D Tile with specified users.
255
+
256
+ Args:
257
+ users (List[User]): The list of user objects to unshare the 3D Tile with.
258
+
259
+ Returns:
260
+ None
261
+
262
+ Example:
263
+ >>> from geobox.aio import AsyncGeoboxClient
264
+ >>> from geobox.aio.tile3d import Tile3d
265
+ >>> async with AsyncGeoboxClient() as client:
266
+ >>> tile = await Tile3d.get_3dtile(client, uuid="12345678-1234-5678-1234-567812345678")
267
+ >>> users = await client.search_users(search='John')
268
+ >>> await tile.unshare(users=users)
269
+ """
270
+ await super()._unshare(self.endpoint, users)
271
+
272
+
273
+ async def get_shared_users(self, search: str = None, skip: int = 0, limit: int = 10) -> List['User']:
274
+ """
275
+ [async] Retrieves the list of users the 3D Tile is shared with.
276
+
277
+ Args:
278
+ search (str, optional): The search query.
279
+ skip (int, optional): The number of users to skip.
280
+ limit (int, optional): The maximum number of users to retrieve.
281
+
282
+ Returns:
283
+ List[User]: The list of shared users.
284
+
285
+ Example:
286
+ >>> from geobox.aio import AsyncGeoboxClient
287
+ >>> from geobox.aio.tile3d import Tile3d
288
+ >>> async with AsyncGeoboxClient() as client:
289
+ >>> tile = await Tile3d.get_3dtile(client, uuid="12345678-1234-5678-1234-567812345678")
290
+ >>> await tile.get_shared_users(search='John', skip=0, limit=10)
291
+ """
292
+ params = {
293
+ 'search': search,
294
+ 'skip': skip,
295
+ 'limit': limit
296
+ }
297
+ return await super()._get_shared_users(self.endpoint, params)
298
+
299
+
300
+ async def get_tileset_json(self) -> Dict:
301
+ """
302
+ [async] Get Tileset JSON of a 3D Tiles.
303
+
304
+ Returns:
305
+ Dict: The tileset JSON configuration.
306
+
307
+ Example:
308
+ >>> from geobox.aio import AsyncGeoboxClient
309
+ >>> from geobox.aio.tile3d import Tile3d
310
+ >>> async with AsyncGeoboxClient() as client:
311
+ >>> tile = await Tile3d.get_3dtile(api=client, uuid="12345678-1234-5678-1234-567812345678")
312
+ >>> tile_json = await tile.get_tileset_json()
313
+ """
314
+ endpoint = urljoin(self.endpoint, 'tileset.json')
315
+ return await self.api.get(endpoint)
316
+
317
+
318
+ def to_sync(self, sync_client: 'SyncGeoboxClient') -> 'SyncTile3d':
319
+ """
320
+ Switch to sync version of the 3d tile instance to have access to the sync methods
321
+
322
+ Args:
323
+ sync_client (SyncGeoboxClient): The sync version of the GeoboxClient instance for making requests.
324
+
325
+ Returns:
326
+ geobox.tile3d.Tile3d: the sync instance of the 3d tile.
327
+
328
+ Example:
329
+ >>> from geobox import Geoboxclient
330
+ >>> from geobox.aio import AsyncGeoboxClient
331
+ >>> from geobox.aio.tile3d import Tile3d
332
+ >>> client = GeoboxClient()
333
+ >>> async with AsyncGeoboxClient() as async_client:
334
+ >>> tile = await Tile3d.get_3dtile(api=async_client, uuid="12345678-1234-5678-1234-567812345678")
335
+ >>> sync_tile = tile.to_sync(client)
336
+ """
337
+ from ..tile3d import Tile3d as SyncTile3d
338
+
339
+ return SyncTile3d(api=sync_client, uuid=self.uuid, data=self.data)