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.
- 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 +693 -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 -15
- 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 +34 -2
- geobox/model3d.py +31 -37
- geobox/mosaic.py +28 -7
- geobox/plan.py +29 -3
- geobox/query.py +39 -14
- geobox/raster.py +26 -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 +40 -4
- geobox/version.py +25 -1
- geobox/view.py +37 -17
- geobox/workflow.py +27 -1
- {geobox-1.4.2.dist-info → geobox-2.0.1.dist-info}/METADATA +4 -1
- geobox-2.0.1.dist-info/RECORD +68 -0
- geobox-1.4.2.dist-info/RECORD +0 -38
- {geobox-1.4.2.dist-info → geobox-2.0.1.dist-info}/WHEEL +0 -0
- {geobox-1.4.2.dist-info → geobox-2.0.1.dist-info}/licenses/LICENSE +0 -0
- {geobox-1.4.2.dist-info → geobox-2.0.1.dist-info}/top_level.txt +0 -0
geobox/feature.py
CHANGED
|
@@ -6,15 +6,12 @@ from .enums import FeatureType
|
|
|
6
6
|
|
|
7
7
|
if TYPE_CHECKING:
|
|
8
8
|
from .vectorlayer import VectorLayer
|
|
9
|
+
from .aio import AsyncGeoboxClient
|
|
10
|
+
from .aio.feature import Feature as AsyncFeature
|
|
11
|
+
|
|
9
12
|
|
|
10
13
|
class Feature(Base):
|
|
11
|
-
"""
|
|
12
|
-
A class representing a feature in a vector layer in Geobox.
|
|
13
14
|
|
|
14
|
-
This class provides functionality to create, manage, and manipulate features in a vector layer.
|
|
15
|
-
It supports various operations including CRUD operations on features, as well as advanced operations like transforming geometries.
|
|
16
|
-
It also provides properties to access the feature geometry and properties, and a method to transform the feature geometry.
|
|
17
|
-
"""
|
|
18
15
|
BASE_SRID = 3857
|
|
19
16
|
|
|
20
17
|
def __init__(self,
|
|
@@ -163,10 +160,10 @@ class Feature(Base):
|
|
|
163
160
|
@property
|
|
164
161
|
def length(self) -> float:
|
|
165
162
|
"""
|
|
166
|
-
Returns the length of
|
|
163
|
+
Returns the length of the feature geometry (geometry package extra is required!)
|
|
167
164
|
|
|
168
165
|
Returns:
|
|
169
|
-
float: the length of
|
|
166
|
+
float: the length of the feature geometry
|
|
170
167
|
|
|
171
168
|
Example:
|
|
172
169
|
>>> from geobox import GeoboxClient
|
|
@@ -266,11 +263,11 @@ class Feature(Base):
|
|
|
266
263
|
>>> layer = client.get_vector(uuid="12345678-1234-5678-1234-567812345678")
|
|
267
264
|
>>> feature = layer.get_feature(id=1)
|
|
268
265
|
>>> geojson = {
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
}
|
|
266
|
+
... "geometry": {
|
|
267
|
+
... "type": "Point",
|
|
268
|
+
... "coordinates": [10, 20]
|
|
269
|
+
... }
|
|
270
|
+
... }
|
|
274
271
|
>>> feature.update(geojson)
|
|
275
272
|
"""
|
|
276
273
|
return super()._update(self.endpoint, geojson, clean=False)
|
|
@@ -506,3 +503,26 @@ class Feature(Base):
|
|
|
506
503
|
return self
|
|
507
504
|
|
|
508
505
|
|
|
506
|
+
def to_async(self, async_client: 'AsyncGeoboxClient') -> 'AsyncFeature':
|
|
507
|
+
"""
|
|
508
|
+
Switch to async version of the feature instance to have access to the async methods
|
|
509
|
+
|
|
510
|
+
Args:
|
|
511
|
+
async_client (AsyncGeoboxClient): The async version of the GeoboxClient instance for making requests.
|
|
512
|
+
|
|
513
|
+
Returns:
|
|
514
|
+
geobox.aio.feature.Feature: the async instance of the feature.
|
|
515
|
+
|
|
516
|
+
Example:
|
|
517
|
+
>>> from geobox import Geoboxclient
|
|
518
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
519
|
+
>>> client = GeoboxClient()
|
|
520
|
+
>>> layer = client.get_vector(uuid="12345678-1234-5678-1234-567812345678")
|
|
521
|
+
>>> feature = layer.get_feature(id=1, srid=3857)
|
|
522
|
+
>>> async with AsyncGeoboxClient() as async_client:
|
|
523
|
+
>>> async_feature = feature.to_async(async_client)
|
|
524
|
+
"""
|
|
525
|
+
from .aio.feature import Feature as AsyncFeature
|
|
526
|
+
|
|
527
|
+
async_layer = self.layer.to_async(async_client=async_client)
|
|
528
|
+
return AsyncFeature(layer=async_layer, srid=self.srid, data=self.data)
|
geobox/field.py
CHANGED
|
@@ -8,15 +8,12 @@ from .enums import FieldType
|
|
|
8
8
|
if TYPE_CHECKING:
|
|
9
9
|
from .api import GeoboxClient
|
|
10
10
|
from .vectorlayer import VectorLayer
|
|
11
|
+
from .aio import AsyncGeoboxClient
|
|
12
|
+
from .aio.field import Field as AsyncField
|
|
13
|
+
|
|
11
14
|
|
|
12
15
|
class Field(Base):
|
|
13
|
-
"""
|
|
14
|
-
A class representing a field in a vector layer in Geobox.
|
|
15
16
|
|
|
16
|
-
This class provides functionality to create, manage, and manipulate fields in a vector layer.
|
|
17
|
-
It supports various operations including CRUD operations on fields, as well as advanced operations like getting unique values, statistics, and updating fields.
|
|
18
|
-
It also provides properties to access the field data, and a method to update the field.
|
|
19
|
-
"""
|
|
20
17
|
def __init__(self,
|
|
21
18
|
layer: 'VectorLayer',
|
|
22
19
|
data_type: 'FieldType',
|
|
@@ -30,17 +27,6 @@ class Field(Base):
|
|
|
30
27
|
data_type (FieldType): type of the field
|
|
31
28
|
field_id (int): the id of the field
|
|
32
29
|
data (Dict, optional): The data of the field.
|
|
33
|
-
|
|
34
|
-
Example:
|
|
35
|
-
>>> from geobox import GeoboxClient
|
|
36
|
-
>>> from geobox.field import Field
|
|
37
|
-
>>> client = GeoboxClient()
|
|
38
|
-
>>> layer = client.get_vector(uuid="12345678-1234-5678-1234-567812345678")
|
|
39
|
-
>>> field_data = {
|
|
40
|
-
... "name": "test"
|
|
41
|
-
... }
|
|
42
|
-
>>> field = Field(layer=layer, data_type=FieldType.Integere, data=field_data)
|
|
43
|
-
>>> field.save()
|
|
44
30
|
"""
|
|
45
31
|
super().__init__(api=layer.api, data=data)
|
|
46
32
|
self.layer = layer
|
|
@@ -202,7 +188,7 @@ class Field(Base):
|
|
|
202
188
|
>>> from geobox.field import Field
|
|
203
189
|
>>> client = GeoboxClient()
|
|
204
190
|
>>> layer = client.get_vector(uuid="12345678-1234-5678-1234-567812345678")
|
|
205
|
-
>>> field =
|
|
191
|
+
>>> field = layer.get_field(name='test')
|
|
206
192
|
>>> field.update(name="my_field", display_name="My Field", description="My Field Description")
|
|
207
193
|
"""
|
|
208
194
|
data = {
|
|
@@ -234,12 +220,12 @@ class Field(Base):
|
|
|
234
220
|
return self.layer.api.get(endpoint)
|
|
235
221
|
|
|
236
222
|
|
|
237
|
-
def get_field_unique_values_numbers(self) ->
|
|
223
|
+
def get_field_unique_values_numbers(self) -> int:
|
|
238
224
|
"""
|
|
239
|
-
Get the unique values of the field.
|
|
225
|
+
Get the count of unique values of the field.
|
|
240
226
|
|
|
241
227
|
Returns:
|
|
242
|
-
|
|
228
|
+
int: The count of the field unique values.
|
|
243
229
|
|
|
244
230
|
Example:
|
|
245
231
|
>>> from geobox import GeoboxClient
|
|
@@ -307,3 +293,29 @@ class Field(Base):
|
|
|
307
293
|
|
|
308
294
|
self.save()
|
|
309
295
|
return self.domain
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
def to_async(self, async_client: 'AsyncGeoboxClient') -> 'AsyncField':
|
|
299
|
+
"""
|
|
300
|
+
Switch to async version of the field instance to have access to the async methods
|
|
301
|
+
|
|
302
|
+
Args:
|
|
303
|
+
async_client (AsyncGeoboxClient): The async version of the GeoboxClient instance for making requests.
|
|
304
|
+
|
|
305
|
+
Returns:
|
|
306
|
+
geobox.aio.field.Field: the async instance of the field.
|
|
307
|
+
|
|
308
|
+
Example:
|
|
309
|
+
>>> from geobox import Geoboxclient
|
|
310
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
311
|
+
>>> from geobox.field import Field
|
|
312
|
+
>>> client = GeoboxClient()
|
|
313
|
+
>>> layer = client.get_vector(uuid="12345678-1234-5678-1234-567812345678")
|
|
314
|
+
>>> field = layer.get_field(name='test')
|
|
315
|
+
>>> async with AsyncGeoboxClient() as async_client:
|
|
316
|
+
>>> async_field = field.to_async(async_client)
|
|
317
|
+
"""
|
|
318
|
+
from .aio.field import Field as AsyncField
|
|
319
|
+
|
|
320
|
+
async_layer = self.layer.to_async(async_client=async_client)
|
|
321
|
+
return AsyncField(layer=async_layer, data_type=self.data_type, field_id=self.field_id, data=self.data)
|
geobox/file.py
CHANGED
|
@@ -5,26 +5,22 @@ import mimetypes
|
|
|
5
5
|
from geobox.exception import ValidationError
|
|
6
6
|
import requests
|
|
7
7
|
import sys
|
|
8
|
-
from pathlib import Path
|
|
9
8
|
|
|
10
9
|
from .base import Base
|
|
11
10
|
from .enums import FileFormat, PublishFileType, InputGeomType, FileType
|
|
12
|
-
from .utils import clean_data
|
|
11
|
+
from .utils import clean_data, get_unique_filename, get_save_path
|
|
13
12
|
from .task import Task
|
|
14
13
|
from .feature import Feature
|
|
15
14
|
|
|
16
15
|
if TYPE_CHECKING:
|
|
17
16
|
from . import GeoboxClient
|
|
18
17
|
from .user import User
|
|
18
|
+
from .aio import AsyncGeoboxClient
|
|
19
|
+
from .aio.file import File as AsyncFile
|
|
20
|
+
|
|
19
21
|
|
|
20
22
|
class File(Base):
|
|
21
|
-
"""
|
|
22
|
-
A class to interact with files in Geobox.
|
|
23
23
|
|
|
24
|
-
This class provides functionality to interact with files in Geobox.
|
|
25
|
-
It supports various operations including CRUD operations on files, as well as advanced operations like publishing, and sharing files.
|
|
26
|
-
It also provides properties to access the file data, and a method to download the file.
|
|
27
|
-
"""
|
|
28
24
|
BASE_ENDPOINT: str = 'files/'
|
|
29
25
|
|
|
30
26
|
def __init__(self,
|
|
@@ -35,7 +31,7 @@ class File(Base):
|
|
|
35
31
|
Constructs all the necessary attributes for the File object.
|
|
36
32
|
|
|
37
33
|
Args:
|
|
38
|
-
api (
|
|
34
|
+
api (GeoboxClient): The GeoboxClient instance.
|
|
39
35
|
uuid (str): The UUID of the file.
|
|
40
36
|
data (Dict, optional): The data of the file.
|
|
41
37
|
"""
|
|
@@ -92,7 +88,7 @@ class File(Base):
|
|
|
92
88
|
Upload a file to the GeoBox API.
|
|
93
89
|
|
|
94
90
|
Args:
|
|
95
|
-
api (GeoboxClient): The
|
|
91
|
+
api (GeoboxClient): The GeoboxClient instance.
|
|
96
92
|
path (str): The path to the file to upload.
|
|
97
93
|
user_id (int, optional): specific user. privileges required.
|
|
98
94
|
scan_archive (bool, optional): Whether to scan the archive for layers. default: True
|
|
@@ -143,7 +139,7 @@ class File(Base):
|
|
|
143
139
|
q (str): query filter based on OGC CQL standard. e.g. "field1 LIKE '%GIS%' AND created_at > '2021-01-01'"
|
|
144
140
|
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.
|
|
145
141
|
search_fields (str): comma separated list of fields for searching
|
|
146
|
-
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.
|
|
142
|
+
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.
|
|
147
143
|
return_count (bool): if true, the total number of results will be returned. default is False.
|
|
148
144
|
skip (int): number of results to skip. default is 0.
|
|
149
145
|
limit (int): number of results to return. default is 10.
|
|
@@ -182,7 +178,7 @@ class File(Base):
|
|
|
182
178
|
Retrieves a file by its UUID.
|
|
183
179
|
|
|
184
180
|
Args:
|
|
185
|
-
api (Api): The
|
|
181
|
+
api (Api): The GeoboxClient instance.
|
|
186
182
|
uuid (str): The UUID of the file.
|
|
187
183
|
user_id (int, optional): specific user. privileges required.
|
|
188
184
|
|
|
@@ -229,37 +225,7 @@ class File(Base):
|
|
|
229
225
|
>>> files = client.get_files_by_name(name='test')
|
|
230
226
|
"""
|
|
231
227
|
return cls.get_files(api, q=f"name = '{name}'", user_id=user_id)
|
|
232
|
-
|
|
233
228
|
|
|
234
|
-
def _get_save_path(self, save_path: str = None) -> str:
|
|
235
|
-
"""
|
|
236
|
-
Get the path where the file should be saved.
|
|
237
|
-
|
|
238
|
-
Args:
|
|
239
|
-
save_path (str, optional): The path to save the file.
|
|
240
|
-
|
|
241
|
-
Returns:
|
|
242
|
-
str: The path where the file is saved.
|
|
243
|
-
|
|
244
|
-
Raises:
|
|
245
|
-
ValueError: If save_path does not end with a '/'.
|
|
246
|
-
|
|
247
|
-
Example:
|
|
248
|
-
>>> from geobox import GeoboxClient
|
|
249
|
-
>>> from geobox.file import File
|
|
250
|
-
>>> from geobox import GeoboxClient
|
|
251
|
-
>>> client = GeoboxClient()
|
|
252
|
-
>>> file_path = File.get_file(client, uuid="12345678-1234-5678-1234-567812345678")
|
|
253
|
-
"""
|
|
254
|
-
# If save_path is provided, check if it ends with a '/'
|
|
255
|
-
if save_path and save_path.endswith('/'):
|
|
256
|
-
return f'{save_path}'
|
|
257
|
-
|
|
258
|
-
if save_path and not save_path.endswith('/'):
|
|
259
|
-
raise ValueError("save_path must end with a '/'")
|
|
260
|
-
|
|
261
|
-
return os.getcwd()
|
|
262
|
-
|
|
263
229
|
|
|
264
230
|
def _get_file_name(self, response: requests.Response) -> str:
|
|
265
231
|
"""
|
|
@@ -301,7 +267,7 @@ class File(Base):
|
|
|
301
267
|
)
|
|
302
268
|
|
|
303
269
|
|
|
304
|
-
def download(self, save_path: str = None, progress_bar: bool = True) -> str:
|
|
270
|
+
def download(self, save_path: str = None, progress_bar: bool = True, file_name: str = None, overwrite: bool = False) -> str:
|
|
305
271
|
"""
|
|
306
272
|
Download a file and save it to the specified path.
|
|
307
273
|
|
|
@@ -310,6 +276,8 @@ class File(Base):
|
|
|
310
276
|
If not provided, it saves to the current working directory
|
|
311
277
|
using the original filename and appropriate extension.
|
|
312
278
|
progress_bar (bool, optional): Whether to show a progress bar. default: True
|
|
279
|
+
file_name (str, optional): the downloaded file name.
|
|
280
|
+
overwrite (bool, optional): whether to overwrite the downloaded file if it exists on the save path. default is False.
|
|
313
281
|
|
|
314
282
|
Returns:
|
|
315
283
|
str: Path where the file was saved
|
|
@@ -328,12 +296,14 @@ class File(Base):
|
|
|
328
296
|
if not self.uuid:
|
|
329
297
|
raise ValueError("File UUID is required to download the file")
|
|
330
298
|
|
|
331
|
-
save_path =
|
|
299
|
+
save_path = get_save_path(save_path)
|
|
332
300
|
os.makedirs(os.path.dirname(save_path), exist_ok=True)
|
|
333
301
|
|
|
334
302
|
with self.api.get(f"{self.endpoint}download/", stream=True) as response:
|
|
335
|
-
file_name = self._get_file_name(response)
|
|
303
|
+
file_name = self._get_file_name(response) if not file_name else file_name
|
|
336
304
|
full_path = f"{save_path}/{file_name}"
|
|
305
|
+
if os.path.exists(full_path) and not overwrite:
|
|
306
|
+
full_path = get_unique_filename(save_path, file_name)
|
|
337
307
|
with open(full_path, 'wb') as f:
|
|
338
308
|
pbar = self._create_progress_bar() if progress_bar else None
|
|
339
309
|
for chunk in response.iter_content(chunk_size=8192):
|
|
@@ -381,7 +351,7 @@ class File(Base):
|
|
|
381
351
|
|
|
382
352
|
Args:
|
|
383
353
|
name (str): The name of the layer.
|
|
384
|
-
publish_as (PublishFileType): The type of layer to publish as.
|
|
354
|
+
publish_as (PublishFileType, optional): The type of layer to publish as.
|
|
385
355
|
input_geom_type (InputGeomType, optional): The geometry type of the layer.
|
|
386
356
|
input_layer (str, optional): The name of the input layer.
|
|
387
357
|
input_dataset (str, optional): The name of the input dataset.
|
|
@@ -521,3 +491,27 @@ class File(Base):
|
|
|
521
491
|
'limit': limit
|
|
522
492
|
}
|
|
523
493
|
return super()._get_shared_users(self.endpoint, params)
|
|
494
|
+
|
|
495
|
+
|
|
496
|
+
def to_async(self, async_client: 'AsyncGeoboxClient') -> 'AsyncFile':
|
|
497
|
+
"""
|
|
498
|
+
Switch to async version of the file instance to have access to the async methods
|
|
499
|
+
|
|
500
|
+
Args:
|
|
501
|
+
async_client (AsyncGeoboxClient): The async version of the GeoboxClient instance for making requests.
|
|
502
|
+
|
|
503
|
+
Returns:
|
|
504
|
+
geobox.aio.file.File: the async instance of the file.
|
|
505
|
+
|
|
506
|
+
Example:
|
|
507
|
+
>>> from geobox import Geoboxclient
|
|
508
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
509
|
+
>>> from geobox.file import File
|
|
510
|
+
>>> client = GeoboxClient()
|
|
511
|
+
>>> file = File.get_file(client, uuid="12345678-1234-5678-1234-567812345678")
|
|
512
|
+
>>> async with AsyncGeoboxClient() as async_client:
|
|
513
|
+
>>> async_file = file.to_async(async_client)
|
|
514
|
+
"""
|
|
515
|
+
from .aio.file import File as AsyncFile
|
|
516
|
+
|
|
517
|
+
return AsyncFile(api=async_client, uuid=self.uuid, data=self.data)
|
geobox/layout.py
CHANGED
|
@@ -5,6 +5,9 @@ from .base import Base
|
|
|
5
5
|
if TYPE_CHECKING:
|
|
6
6
|
from . import GeoboxClient
|
|
7
7
|
from .user import User
|
|
8
|
+
from .aio import AsyncGeoboxClient
|
|
9
|
+
from .aio.layout import Layout as AsyncLayout
|
|
10
|
+
|
|
8
11
|
|
|
9
12
|
class Layout(Base):
|
|
10
13
|
|
|
@@ -197,7 +200,7 @@ class Layout(Base):
|
|
|
197
200
|
>>> from geobox.layout import Layout
|
|
198
201
|
>>> client = GeoboxClient()
|
|
199
202
|
>>> layout = Layout.get_layout(client, uuid="12345678-1234-5678-1234-567812345678")
|
|
200
|
-
>>> layout.
|
|
203
|
+
>>> layout.update(display_name="New Display Name")
|
|
201
204
|
"""
|
|
202
205
|
data = {
|
|
203
206
|
"name": kwargs.get('name'),
|
|
@@ -312,3 +315,27 @@ class Layout(Base):
|
|
|
312
315
|
'limit': limit
|
|
313
316
|
}
|
|
314
317
|
return super()._get_shared_users(self.endpoint, params)
|
|
318
|
+
|
|
319
|
+
|
|
320
|
+
def to_async(self, async_client: 'AsyncGeoboxClient') -> 'AsyncLayout':
|
|
321
|
+
"""
|
|
322
|
+
Switch to async version of the layout instance to have access to the async methods
|
|
323
|
+
|
|
324
|
+
Args:
|
|
325
|
+
async_client (AsyncGeoboxClient): The async version of the GeoboxClient instance for making requests.
|
|
326
|
+
|
|
327
|
+
Returns:
|
|
328
|
+
geobox.aio.layout.Layout: the async instance of the layout.
|
|
329
|
+
|
|
330
|
+
Example:
|
|
331
|
+
>>> from geobox import Geoboxclient
|
|
332
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
333
|
+
>>> from geobox.layout import Layout
|
|
334
|
+
>>> client = GeoboxClient()
|
|
335
|
+
>>> layout = Layout.get_layout(client, uuid="12345678-1234-5678-1234-567812345678")
|
|
336
|
+
>>> async with AsyncGeoboxClient() as async_client:
|
|
337
|
+
>>> async_layout = layout.to_async(async_client)
|
|
338
|
+
"""
|
|
339
|
+
from .aio.layout import Layout as AsyncLayout
|
|
340
|
+
|
|
341
|
+
return AsyncLayout(api=async_client, uuid=self.uuid, data=self.data)
|
geobox/log.py
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
from urllib.parse import urljoin
|
|
2
1
|
from typing import Optional, Dict, List, Union, TYPE_CHECKING
|
|
3
|
-
from datetime import datetime
|
|
4
2
|
|
|
5
3
|
from .base import Base
|
|
6
4
|
|
|
7
5
|
if TYPE_CHECKING:
|
|
8
6
|
from . import GeoboxClient
|
|
9
7
|
from .user import User
|
|
8
|
+
from .aio import AsyncGeoboxClient
|
|
9
|
+
from .aio.log import Log as AsyncLog
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
class Log(Base):
|
|
@@ -21,7 +21,7 @@ class Log(Base):
|
|
|
21
21
|
Constructs all the necessary attributes for the Log object.
|
|
22
22
|
|
|
23
23
|
Args:
|
|
24
|
-
api (
|
|
24
|
+
api (GeoboxClient): The GeoboxClient instance for making requests.
|
|
25
25
|
log_id (int): The id of the log.
|
|
26
26
|
data (Dict, optional): The data of the log.
|
|
27
27
|
"""
|
|
@@ -63,7 +63,7 @@ class Log(Base):
|
|
|
63
63
|
List[Log]: a list of logs
|
|
64
64
|
|
|
65
65
|
Example:
|
|
66
|
-
>>> from geobox import
|
|
66
|
+
>>> from geobox import GeoboxClient
|
|
67
67
|
>>> from geopox.log import Log
|
|
68
68
|
>>> client = GeoboxClient()
|
|
69
69
|
>>> logs = Log.get_logs(client)
|
|
@@ -92,7 +92,7 @@ class Log(Base):
|
|
|
92
92
|
None
|
|
93
93
|
|
|
94
94
|
Example:
|
|
95
|
-
>>> from geobox import
|
|
95
|
+
>>> from geobox import GeoboxClient
|
|
96
96
|
>>> from geopox.log import Log
|
|
97
97
|
>>> client = GeoboxClient()
|
|
98
98
|
>>> log = Log.get_logs(client)[0]
|
|
@@ -111,10 +111,34 @@ class Log(Base):
|
|
|
111
111
|
User | None: if the log has owner user
|
|
112
112
|
|
|
113
113
|
Example:
|
|
114
|
-
>>> from geobox import
|
|
114
|
+
>>> from geobox import GeoboxClient
|
|
115
115
|
>>> from geopox.log import Log
|
|
116
116
|
>>> client = GeoboxClient()
|
|
117
117
|
>>> log = Log.get_logs(client)[0]
|
|
118
118
|
>>> log.user
|
|
119
119
|
"""
|
|
120
|
-
return self.api.get_user(self.owner_id)
|
|
120
|
+
return self.api.get_user(self.owner_id)
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
def to_async(self, async_client: 'AsyncGeoboxClient') -> 'AsyncLog':
|
|
124
|
+
"""
|
|
125
|
+
Switch to async version of the log instance to have access to the async methods
|
|
126
|
+
|
|
127
|
+
Args:
|
|
128
|
+
async_client (AsyncGeoboxClient): The async version of the GeoboxClient instance for making requests.
|
|
129
|
+
|
|
130
|
+
Returns:
|
|
131
|
+
geobox.aio.log.Log: the async instance of the log.
|
|
132
|
+
|
|
133
|
+
Example:
|
|
134
|
+
>>> from geobox import Geoboxclient
|
|
135
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
136
|
+
>>> from geopox.log import Log
|
|
137
|
+
>>> client = GeoboxClient()
|
|
138
|
+
>>> log = Log.get_logs(client)[0]
|
|
139
|
+
>>> async with AsyncGeoboxClient() as async_client:
|
|
140
|
+
>>> async_log = log.to_async(async_client)
|
|
141
|
+
"""
|
|
142
|
+
from .aio.log import Log as AsyncLog
|
|
143
|
+
|
|
144
|
+
return AsyncLog(api=async_client, log_id=self.log_id, data=self.data)
|
geobox/map.py
CHANGED
|
@@ -12,7 +12,8 @@ if TYPE_CHECKING:
|
|
|
12
12
|
from .user import User
|
|
13
13
|
from .task import Task
|
|
14
14
|
from .attachment import Attachment
|
|
15
|
-
|
|
15
|
+
from .aio import AsyncGeoboxClient
|
|
16
|
+
from .aio.map import Map as AsyncMap
|
|
16
17
|
|
|
17
18
|
|
|
18
19
|
class Map(Base):
|
|
@@ -636,6 +637,13 @@ class Map(Base):
|
|
|
636
637
|
|
|
637
638
|
Returns:
|
|
638
639
|
Dict: The response of the API.
|
|
640
|
+
|
|
641
|
+
Example:
|
|
642
|
+
>>> from geobox import GeoboxClient
|
|
643
|
+
>>> from geobox.map import Map
|
|
644
|
+
>>> client = GeoboxClient()
|
|
645
|
+
>>> map = Map.get_map(uuid="12345678-1234-5678-1234-567812345678")
|
|
646
|
+
>>> map.set_settings(zoom=10)
|
|
639
647
|
"""
|
|
640
648
|
general_settings = {'map_unit', 'base_map', 'flash_color', 'highlight_color',
|
|
641
649
|
'selection_color', 'selectable_layers', 'calendar_type', 'custom_basemaps', 'show_maptip_on'}
|
|
@@ -998,4 +1006,28 @@ class Map(Base):
|
|
|
998
1006
|
file=file,
|
|
999
1007
|
feature=feature,
|
|
1000
1008
|
display_name=display_name,
|
|
1001
|
-
description=description)
|
|
1009
|
+
description=description)
|
|
1010
|
+
|
|
1011
|
+
|
|
1012
|
+
def to_async(self, async_client: 'AsyncGeoboxClient') -> 'AsyncMap':
|
|
1013
|
+
"""
|
|
1014
|
+
Switch to async version of the map instance to have access to the async methods
|
|
1015
|
+
|
|
1016
|
+
Args:
|
|
1017
|
+
async_client (AsyncGeoboxClient): The async version of the GeoboxClient instance for making requests.
|
|
1018
|
+
|
|
1019
|
+
Returns:
|
|
1020
|
+
geobox.aio.map.Map: the async instance of the map.
|
|
1021
|
+
|
|
1022
|
+
Example:
|
|
1023
|
+
>>> from geobox import Geoboxclient
|
|
1024
|
+
>>> from geobox.aio import AsyncGeoboxClient
|
|
1025
|
+
>>> from geobox.map import Map
|
|
1026
|
+
>>> client = GeoboxClient()
|
|
1027
|
+
>>> map = Map.get_map(client, uuid="12345678-1234-5678-1234-567812345678")
|
|
1028
|
+
>>> async with AsyncGeoboxClient() as async_client:
|
|
1029
|
+
>>> async_map = map.to_async(async_client)
|
|
1030
|
+
"""
|
|
1031
|
+
from .aio.map import Map as AsyncMap
|
|
1032
|
+
|
|
1033
|
+
return AsyncMap(api=async_client, uuid=self.uuid, data=self.data)
|
geobox/model3d.py
CHANGED
|
@@ -3,20 +3,20 @@ from urllib.parse import urljoin, urlencode
|
|
|
3
3
|
import os
|
|
4
4
|
import zipfile
|
|
5
5
|
import sys
|
|
6
|
-
import requests
|
|
7
|
-
import mimetypes
|
|
8
6
|
|
|
9
7
|
from .base import Base
|
|
10
8
|
from .exception import ApiRequestError
|
|
9
|
+
from .utils import get_save_path
|
|
11
10
|
|
|
12
11
|
if TYPE_CHECKING:
|
|
13
12
|
from . import GeoboxClient
|
|
14
13
|
from .user import User
|
|
14
|
+
from .aio import AsyncGeoboxClient
|
|
15
|
+
from .aio.model3d import Model as AsyncModel
|
|
16
|
+
|
|
15
17
|
|
|
16
18
|
class Model(Base):
|
|
17
|
-
|
|
18
|
-
A class representing a 3D model in Geobox.
|
|
19
|
-
"""
|
|
19
|
+
|
|
20
20
|
BASE_ENDPOINT = '3dmodels/'
|
|
21
21
|
|
|
22
22
|
def __init__(self,
|
|
@@ -221,36 +221,6 @@ class Model(Base):
|
|
|
221
221
|
super().delete(self.endpoint)
|
|
222
222
|
|
|
223
223
|
|
|
224
|
-
def _get_save_path(self, save_path: str = None) -> str:
|
|
225
|
-
"""
|
|
226
|
-
Get the path where the file should be saved.
|
|
227
|
-
|
|
228
|
-
Args:
|
|
229
|
-
save_path (str, optional): The path to save the file.
|
|
230
|
-
|
|
231
|
-
Returns:
|
|
232
|
-
str: The path where the file is saved.
|
|
233
|
-
|
|
234
|
-
Raises:
|
|
235
|
-
ValueError: If save_path does not end with a '/'.
|
|
236
|
-
|
|
237
|
-
Example:
|
|
238
|
-
>>> from geobox import GeoboxClient
|
|
239
|
-
>>> from geobox.file import File
|
|
240
|
-
>>> from geobox import GeoboxClient
|
|
241
|
-
>>> client = GeoboxClient()
|
|
242
|
-
>>> file_path = File.get_file(client, uuid="12345678-1234-5678-1234-567812345678")
|
|
243
|
-
"""
|
|
244
|
-
# If save_path is provided, check if it ends with a '/'
|
|
245
|
-
if save_path and save_path.endswith('/'):
|
|
246
|
-
return f'{save_path}'
|
|
247
|
-
|
|
248
|
-
if save_path and not save_path.endswith('/'):
|
|
249
|
-
raise ValueError("save_path must end with a '/'")
|
|
250
|
-
|
|
251
|
-
return os.getcwd()
|
|
252
|
-
|
|
253
|
-
|
|
254
224
|
def _create_progress_bar(self) -> 'tqdm':
|
|
255
225
|
"""Creates a progress bar for the task."""
|
|
256
226
|
try:
|
|
@@ -289,7 +259,7 @@ class Model(Base):
|
|
|
289
259
|
>>> from geobox import GeoboxClient
|
|
290
260
|
>>> client = GeoboxClient()
|
|
291
261
|
>>> model = client.get_models()[0]
|
|
292
|
-
>>> model.
|
|
262
|
+
>>> model.download()
|
|
293
263
|
"""
|
|
294
264
|
if not self.uuid:
|
|
295
265
|
raise ValueError("Model UUID is required to download content")
|
|
@@ -299,7 +269,7 @@ class Model(Base):
|
|
|
299
269
|
else:
|
|
300
270
|
model = self
|
|
301
271
|
|
|
302
|
-
save_path =
|
|
272
|
+
save_path = get_save_path(save_path)
|
|
303
273
|
os.makedirs(save_path, exist_ok=True)
|
|
304
274
|
|
|
305
275
|
endpoint = urljoin(model.api.base_url, f"{model.endpoint}/content/")
|
|
@@ -415,3 +385,27 @@ class Model(Base):
|
|
|
415
385
|
'limit': limit
|
|
416
386
|
}
|
|
417
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'),
|
|
@@ -673,3 +670,27 @@ class Mosaic(Raster):
|
|
|
673
670
|
>>> mosaic.cache_size
|
|
674
671
|
"""
|
|
675
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)
|