geobox 1.2.1__tar.gz → 1.2.3__tar.gz
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-1.2.1 → geobox-1.2.3}/PKG-INFO +1 -1
- {geobox-1.2.1 → geobox-1.2.3}/geobox/api.py +6 -4
- {geobox-1.2.1 → geobox-1.2.3}/geobox/enums.py +8 -20
- {geobox-1.2.1 → geobox-1.2.3}/geobox/field.py +2 -2
- {geobox-1.2.1 → geobox-1.2.3}/geobox/file.py +50 -45
- {geobox-1.2.1 → geobox-1.2.3}/geobox/map.py +14 -13
- {geobox-1.2.1 → geobox-1.2.3}/geobox/raster.py +2 -5
- {geobox-1.2.1 → geobox-1.2.3}/geobox/task.py +14 -7
- {geobox-1.2.1 → geobox-1.2.3}/geobox/vectorlayer.py +95 -52
- {geobox-1.2.1 → geobox-1.2.3}/geobox/view.py +51 -20
- {geobox-1.2.1 → geobox-1.2.3}/geobox.egg-info/PKG-INFO +1 -1
- {geobox-1.2.1 → geobox-1.2.3}/pyproject.toml +1 -1
- {geobox-1.2.1 → geobox-1.2.3}/tests/test_feature.py +101 -102
- {geobox-1.2.1 → geobox-1.2.3}/tests/test_file.py +11 -3
- {geobox-1.2.1 → geobox-1.2.3}/tests/test_map.py +24 -92
- {geobox-1.2.1 → geobox-1.2.3}/tests/test_mosaic.py +49 -17
- {geobox-1.2.1 → geobox-1.2.3}/tests/test_raster.py +52 -16
- {geobox-1.2.1 → geobox-1.2.3}/tests/test_task.py +27 -18
- {geobox-1.2.1 → geobox-1.2.3}/tests/test_vectorlayer.py +156 -100
- {geobox-1.2.1 → geobox-1.2.3}/tests/test_view.py +99 -92
- {geobox-1.2.1 → geobox-1.2.3}/LICENSE +0 -0
- {geobox-1.2.1 → geobox-1.2.3}/README.md +0 -0
- {geobox-1.2.1 → geobox-1.2.3}/geobox/__init__.py +0 -0
- {geobox-1.2.1 → geobox-1.2.3}/geobox/apikey.py +0 -0
- {geobox-1.2.1 → geobox-1.2.3}/geobox/attachment.py +0 -0
- {geobox-1.2.1 → geobox-1.2.3}/geobox/base.py +0 -0
- {geobox-1.2.1 → geobox-1.2.3}/geobox/basemap.py +0 -0
- {geobox-1.2.1 → geobox-1.2.3}/geobox/dashboard.py +0 -0
- {geobox-1.2.1 → geobox-1.2.3}/geobox/exception.py +0 -0
- {geobox-1.2.1 → geobox-1.2.3}/geobox/feature.py +0 -0
- {geobox-1.2.1 → geobox-1.2.3}/geobox/log.py +0 -0
- {geobox-1.2.1 → geobox-1.2.3}/geobox/model3d.py +0 -0
- {geobox-1.2.1 → geobox-1.2.3}/geobox/mosaic.py +0 -0
- {geobox-1.2.1 → geobox-1.2.3}/geobox/plan.py +0 -0
- {geobox-1.2.1 → geobox-1.2.3}/geobox/query.py +0 -0
- {geobox-1.2.1 → geobox-1.2.3}/geobox/route.py +0 -0
- {geobox-1.2.1 → geobox-1.2.3}/geobox/scene.py +0 -0
- {geobox-1.2.1 → geobox-1.2.3}/geobox/settings.py +0 -0
- {geobox-1.2.1 → geobox-1.2.3}/geobox/tile3d.py +0 -0
- {geobox-1.2.1 → geobox-1.2.3}/geobox/tileset.py +0 -0
- {geobox-1.2.1 → geobox-1.2.3}/geobox/usage.py +0 -0
- {geobox-1.2.1 → geobox-1.2.3}/geobox/user.py +0 -0
- {geobox-1.2.1 → geobox-1.2.3}/geobox/utils.py +0 -0
- {geobox-1.2.1 → geobox-1.2.3}/geobox/version.py +0 -0
- {geobox-1.2.1 → geobox-1.2.3}/geobox/workflow.py +0 -0
- {geobox-1.2.1 → geobox-1.2.3}/geobox.egg-info/SOURCES.txt +0 -0
- {geobox-1.2.1 → geobox-1.2.3}/geobox.egg-info/dependency_links.txt +0 -0
- {geobox-1.2.1 → geobox-1.2.3}/geobox.egg-info/requires.txt +0 -0
- {geobox-1.2.1 → geobox-1.2.3}/geobox.egg-info/top_level.txt +0 -0
- {geobox-1.2.1 → geobox-1.2.3}/setup.cfg +0 -0
- {geobox-1.2.1 → geobox-1.2.3}/tests/test_api.py +0 -0
- {geobox-1.2.1 → geobox-1.2.3}/tests/test_apikey.py +0 -0
- {geobox-1.2.1 → geobox-1.2.3}/tests/test_attachment.py +0 -0
- {geobox-1.2.1 → geobox-1.2.3}/tests/test_basemap.py +0 -0
- {geobox-1.2.1 → geobox-1.2.3}/tests/test_dashboard.py +0 -0
- {geobox-1.2.1 → geobox-1.2.3}/tests/test_field.py +0 -0
- {geobox-1.2.1 → geobox-1.2.3}/tests/test_log.py +0 -0
- {geobox-1.2.1 → geobox-1.2.3}/tests/test_model3d.py +0 -0
- {geobox-1.2.1 → geobox-1.2.3}/tests/test_plan.py +0 -0
- {geobox-1.2.1 → geobox-1.2.3}/tests/test_query.py +0 -0
- {geobox-1.2.1 → geobox-1.2.3}/tests/test_route.py +0 -0
- {geobox-1.2.1 → geobox-1.2.3}/tests/test_scene.py +0 -0
- {geobox-1.2.1 → geobox-1.2.3}/tests/test_settings.py +0 -0
- {geobox-1.2.1 → geobox-1.2.3}/tests/test_tile3d.py +0 -0
- {geobox-1.2.1 → geobox-1.2.3}/tests/test_tileset.py +0 -0
- {geobox-1.2.1 → geobox-1.2.3}/tests/test_usage.py +0 -0
- {geobox-1.2.1 → geobox-1.2.3}/tests/test_user.py +0 -0
- {geobox-1.2.1 → geobox-1.2.3}/tests/test_version.py +0 -0
- {geobox-1.2.1 → geobox-1.2.3}/tests/test_workflow.py +0 -0
|
@@ -31,7 +31,7 @@ from .basemap import Basemap
|
|
|
31
31
|
from .attachment import Attachment, AttachmentResourceType
|
|
32
32
|
from .apikey import ApiKey
|
|
33
33
|
from .log import Log
|
|
34
|
-
from .usage import Usage
|
|
34
|
+
from .usage import Usage, UsageScale, UsageParam
|
|
35
35
|
|
|
36
36
|
logger = logging.getLogger(__name__)
|
|
37
37
|
|
|
@@ -500,6 +500,7 @@ class GeoboxClient:
|
|
|
500
500
|
display_name: str = None,
|
|
501
501
|
description: str = None,
|
|
502
502
|
has_z: bool = False,
|
|
503
|
+
temporary: bool = False,
|
|
503
504
|
fields: List = None) -> 'VectorLayer':
|
|
504
505
|
"""
|
|
505
506
|
Create a new vector layer.
|
|
@@ -510,6 +511,7 @@ class GeoboxClient:
|
|
|
510
511
|
display_name (str, optional): A human-readable name for the layer. default is None.
|
|
511
512
|
description (str, optional): A description of the layer. default is None.
|
|
512
513
|
has_z (bool, optional): Whether the layer includes Z coordinates. default is False.
|
|
514
|
+
temporary (bool, optional): Whether to create a temporary layer. temporary layers will be deleted after 24 hours. default is False.
|
|
513
515
|
fields (List, optional): List of field definitions for the layer. default is None.
|
|
514
516
|
|
|
515
517
|
Returns:
|
|
@@ -528,7 +530,7 @@ class GeoboxClient:
|
|
|
528
530
|
... has_z=False,
|
|
529
531
|
... fields=[{"name": "my_field", "datatype": "FieldTypeString"}])
|
|
530
532
|
"""
|
|
531
|
-
return VectorLayer.create_vector(self, name=name, layer_type=layer_type, display_name=display_name, description=description, has_z=has_z, fields=fields)
|
|
533
|
+
return VectorLayer.create_vector(self, name=name, layer_type=layer_type, display_name=display_name, description=description, has_z=has_z, temporary=temporary, fields=fields)
|
|
532
534
|
|
|
533
535
|
|
|
534
536
|
def get_vector_by_name(self, name: str, user_id: int = None) -> Union['VectorLayer', None]:
|
|
@@ -760,7 +762,7 @@ class GeoboxClient:
|
|
|
760
762
|
return VectorLayerView.get_view(self, uuid)
|
|
761
763
|
|
|
762
764
|
|
|
763
|
-
def get_view_by_name(self, name: str, user_id: int = None) -> Union['
|
|
765
|
+
def get_view_by_name(self, name: str, user_id: int = None) -> Union['VectorLayerView', None]:
|
|
764
766
|
"""
|
|
765
767
|
Get a view by name
|
|
766
768
|
|
|
@@ -769,7 +771,7 @@ class GeoboxClient:
|
|
|
769
771
|
user_id (int, optional): specific user. privileges required.
|
|
770
772
|
|
|
771
773
|
Returns:
|
|
772
|
-
|
|
774
|
+
VectorLayerView | None: returns the view if a view matches the given name, else None
|
|
773
775
|
|
|
774
776
|
Example:
|
|
775
777
|
>>> from geobox import GeoboxClient
|
|
@@ -134,20 +134,11 @@ class LayerType(Enum):
|
|
|
134
134
|
Point = "Point"
|
|
135
135
|
"""A single point in 2D space"""
|
|
136
136
|
|
|
137
|
-
LineString = "LineString"
|
|
138
|
-
"""A sequence of points forming a line"""
|
|
139
|
-
|
|
140
|
-
Polygon = "Polygon"
|
|
141
|
-
"""A closed shape defined by a sequence of points"""
|
|
142
|
-
|
|
143
137
|
MultiPoint = "MultiPoint"
|
|
144
138
|
"""A collection of points"""
|
|
145
139
|
|
|
146
|
-
|
|
147
|
-
"""A
|
|
148
|
-
|
|
149
|
-
MultiPolygon = "MultiPolygon"
|
|
150
|
-
"""A collection of polygons"""
|
|
140
|
+
Polygon = "Polygon"
|
|
141
|
+
"""A closed shape defined by a sequence of points"""
|
|
151
142
|
|
|
152
143
|
Polyline = "Polyline"
|
|
153
144
|
"""A polyline geometry"""
|
|
@@ -163,25 +154,22 @@ class FeatureType(Enum):
|
|
|
163
154
|
"""
|
|
164
155
|
Point = "Point"
|
|
165
156
|
"""A single point in 2D space"""
|
|
157
|
+
|
|
158
|
+
MultiPoint = "MultiPoint"
|
|
159
|
+
"""A collection of points"""
|
|
166
160
|
|
|
167
161
|
LineString = "LineString"
|
|
168
162
|
"""A sequence of points forming a line"""
|
|
163
|
+
|
|
164
|
+
MultiLineString = "MultiLineString"
|
|
165
|
+
"""A collection of lines"""
|
|
169
166
|
|
|
170
167
|
Polygon = "Polygon"
|
|
171
168
|
"""A closed shape defined by a sequence of points"""
|
|
172
169
|
|
|
173
|
-
MultiPoint = "MultiPoint"
|
|
174
|
-
"""A collection of points"""
|
|
175
|
-
|
|
176
|
-
MultiLineString = "MultiLineString"
|
|
177
|
-
"""A collection of lines"""
|
|
178
|
-
|
|
179
170
|
MultiPolygon = "MultiPolygon"
|
|
180
171
|
"""A collection of polygons"""
|
|
181
172
|
|
|
182
|
-
Polyline = "Polyline"
|
|
183
|
-
"""A polyline geometry"""
|
|
184
|
-
|
|
185
173
|
|
|
186
174
|
# Task Enums
|
|
187
175
|
class TaskStatus(Enum):
|
|
@@ -258,7 +258,7 @@ class Field(Base):
|
|
|
258
258
|
Get the statistic of the field.
|
|
259
259
|
|
|
260
260
|
Args:
|
|
261
|
-
func (str): The function to apply to the field.
|
|
261
|
+
func (str): The function to apply to the field. values are: min, max, avg
|
|
262
262
|
|
|
263
263
|
Returns:
|
|
264
264
|
Dict: The response data.
|
|
@@ -269,7 +269,7 @@ class Field(Base):
|
|
|
269
269
|
>>> client = GeoboxClient()
|
|
270
270
|
>>> layer = client.get_vector(uuid="12345678-1234-5678-1234-567812345678")
|
|
271
271
|
>>> field = layer.get_field(name='test')
|
|
272
|
-
>>> field.get_field_statistic()
|
|
272
|
+
>>> field.get_field_statistic(func='avg')
|
|
273
273
|
"""
|
|
274
274
|
endpoint = urljoin(self.endpoint, f'stats/?func_type={func}')
|
|
275
275
|
return self.layer.api.get(endpoint)
|
|
@@ -2,13 +2,16 @@ from urllib.parse import urljoin
|
|
|
2
2
|
from typing import Optional, Dict, List, Union, TYPE_CHECKING
|
|
3
3
|
import os
|
|
4
4
|
import mimetypes
|
|
5
|
+
from geobox.exception import ValidationError
|
|
5
6
|
import requests
|
|
6
7
|
import sys
|
|
8
|
+
from pathlib import Path
|
|
7
9
|
|
|
8
10
|
from .base import Base
|
|
9
11
|
from .enums import FileFormat, PublishFileType, InputGeomType, FileType
|
|
10
12
|
from .utils import clean_data
|
|
11
13
|
from .task import Task
|
|
14
|
+
from .feature import Feature
|
|
12
15
|
|
|
13
16
|
if TYPE_CHECKING:
|
|
14
17
|
from . import GeoboxClient
|
|
@@ -221,9 +224,9 @@ class File(Base):
|
|
|
221
224
|
>>> from geobox import GeoboxClient
|
|
222
225
|
>>> from geobox.file import File
|
|
223
226
|
>>> client = GeoboxClient()
|
|
224
|
-
>>> files = File.
|
|
227
|
+
>>> files = File.get_files_by_name(client, name='test')
|
|
225
228
|
or
|
|
226
|
-
>>> files = client.
|
|
229
|
+
>>> files = client.get_files_by_name(name='test')
|
|
227
230
|
"""
|
|
228
231
|
return cls.get_files(api, q=f"name = '{name}'", user_id=user_id)
|
|
229
232
|
|
|
@@ -248,44 +251,34 @@ class File(Base):
|
|
|
248
251
|
>>> client = GeoboxClient()
|
|
249
252
|
>>> file_path = File.get_file(client, uuid="12345678-1234-5678-1234-567812345678")
|
|
250
253
|
"""
|
|
251
|
-
# Get the original filename from data or use uuid
|
|
252
|
-
if self.name:
|
|
253
|
-
filename = f"{self.name.split('.')[0]}" if len(self.name.split('.')) > 1 else f'{self.name}'
|
|
254
|
-
else:
|
|
255
|
-
filename = f'{self.uuid}'
|
|
256
|
-
|
|
257
254
|
# If save_path is provided, check if it ends with a '/'
|
|
258
255
|
if save_path and save_path.endswith('/'):
|
|
259
|
-
return f'{save_path}
|
|
256
|
+
return f'{save_path}'
|
|
260
257
|
|
|
261
258
|
if save_path and not save_path.endswith('/'):
|
|
262
259
|
raise ValueError("save_path must end with a '/'")
|
|
263
260
|
|
|
264
|
-
return os.
|
|
261
|
+
return os.getcwd()
|
|
265
262
|
|
|
266
263
|
|
|
267
|
-
def
|
|
264
|
+
def _get_file_name(self, response: requests.Response) -> str:
|
|
268
265
|
"""
|
|
269
|
-
Get the file
|
|
266
|
+
Get the file name from the response.
|
|
270
267
|
|
|
271
268
|
Args:
|
|
272
269
|
response (requests.Response): The response of the request.
|
|
273
270
|
|
|
274
271
|
Returns:
|
|
275
|
-
str: The file
|
|
272
|
+
str: The file name
|
|
276
273
|
"""
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
content_disposition = response.headers['Content-Disposition']
|
|
280
|
-
if 'filename=' in content_disposition:
|
|
281
|
-
filename = content_disposition.split('filename=')[-1].strip().strip('"')
|
|
282
|
-
ext = f".{filename.split('.')[-1]}"
|
|
274
|
+
if 'Content-Disposition' in response.headers and 'filename=' in response.headers['Content-Disposition']:
|
|
275
|
+
file_name = response.headers['Content-Disposition'].split('filename=')[-1].strip().strip('"')
|
|
283
276
|
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
277
|
+
else:
|
|
278
|
+
content_type = response.headers.get("Content-Type", "")
|
|
279
|
+
file_name = f'{self.name}.{mimetypes.guess_extension(content_type.split(";")[0])}'
|
|
287
280
|
|
|
288
|
-
return
|
|
281
|
+
return file_name
|
|
289
282
|
|
|
290
283
|
|
|
291
284
|
def _create_progress_bar(self) -> 'tqdm':
|
|
@@ -338,20 +331,20 @@ class File(Base):
|
|
|
338
331
|
save_path = self._get_save_path(save_path)
|
|
339
332
|
os.makedirs(os.path.dirname(save_path), exist_ok=True)
|
|
340
333
|
|
|
341
|
-
with self.api.get(f"{self.endpoint}download/", stream=True) as response
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
334
|
+
with self.api.get(f"{self.endpoint}download/", stream=True) as response:
|
|
335
|
+
file_name = self._get_file_name(response)
|
|
336
|
+
full_path = f"{save_path}/{file_name}"
|
|
337
|
+
with open(full_path, 'wb') as f:
|
|
338
|
+
pbar = self._create_progress_bar() if progress_bar else None
|
|
339
|
+
for chunk in response.iter_content(chunk_size=8192):
|
|
340
|
+
f.write(chunk)
|
|
341
|
+
if pbar:
|
|
342
|
+
pbar.update(len(chunk))
|
|
343
|
+
pbar.refresh()
|
|
346
344
|
if pbar:
|
|
347
|
-
pbar.
|
|
348
|
-
pbar.refresh()
|
|
349
|
-
if pbar:
|
|
350
|
-
pbar.close()
|
|
345
|
+
pbar.close()
|
|
351
346
|
|
|
352
|
-
|
|
353
|
-
os.rename(os.path.abspath(save_path), os.path.abspath(final_path))
|
|
354
|
-
return os.path.abspath(final_path)
|
|
347
|
+
return os.path.abspath(full_path)
|
|
355
348
|
|
|
356
349
|
|
|
357
350
|
def delete(self) -> None:
|
|
@@ -378,8 +371,8 @@ class File(Base):
|
|
|
378
371
|
input_layer: str = None,
|
|
379
372
|
input_dataset: str = None,
|
|
380
373
|
user_id: int = None,
|
|
381
|
-
input_srid: int =
|
|
382
|
-
file_encoding: str = "
|
|
374
|
+
input_srid: int = Feature.BASE_SRID,
|
|
375
|
+
file_encoding: str = "UTF-8",
|
|
383
376
|
replace_domain_codes_by_values: bool = False,
|
|
384
377
|
report_errors: bool = True,
|
|
385
378
|
as_terrain: bool = False) -> 'Task':
|
|
@@ -393,7 +386,7 @@ class File(Base):
|
|
|
393
386
|
input_layer (str, optional): The name of the input layer.
|
|
394
387
|
input_dataset (str, optional): The name of the input dataset.
|
|
395
388
|
user_id (int, optional): Specific user. privileges required.
|
|
396
|
-
input_srid (int, optional): The SRID of the layer.
|
|
389
|
+
input_srid (int, optional): The SRID of the layer. default is: 3857
|
|
397
390
|
file_encoding (str, optional): The encoding of the file. default is "utf-8".
|
|
398
391
|
replace_domain_codes_by_values (bool, optional): Whether to replace domain codes by values. default is False.
|
|
399
392
|
report_errors (bool, optional): Whether to report errors. default is True.
|
|
@@ -404,6 +397,7 @@ class File(Base):
|
|
|
404
397
|
|
|
405
398
|
Raises:
|
|
406
399
|
ValueError: If the publish_as is not a valid PublishFileType.
|
|
400
|
+
ValidationError: if the zipped file doesn't have any layers to publish.
|
|
407
401
|
|
|
408
402
|
Example:
|
|
409
403
|
>>> from geobox import GeoboxClient
|
|
@@ -416,30 +410,41 @@ class File(Base):
|
|
|
416
410
|
... input_layer='layer1',
|
|
417
411
|
... input_dataset='dataset1',
|
|
418
412
|
... input_srid=4326,
|
|
419
|
-
... file_encoding='
|
|
413
|
+
... file_encoding='UTF-8')
|
|
420
414
|
"""
|
|
421
415
|
if not publish_as:
|
|
422
|
-
|
|
416
|
+
# checks the file format or file first layer format to dynamically set the publish_as
|
|
417
|
+
if self.file_type.value in ['GeoJSON', 'GPKG', 'DXF', 'GPX', 'Shapefile', 'KML', 'CSV', 'FileGDB'] or \
|
|
418
|
+
(self.file_type.value in ['Complex'] and self.layers and \
|
|
419
|
+
FileType(self.layers[0]['format']).value in ['GeoJSON', 'GPKG', 'DXF', 'GPX', 'Shapefile', 'KML', 'CSV', 'FileGDB']):
|
|
423
420
|
publish_as = PublishFileType.VECTOR
|
|
424
|
-
|
|
421
|
+
|
|
422
|
+
elif self.file_type.value in ['GeoTIFF'] or \
|
|
423
|
+
(self.file_type.value in ['Complex'] and self.layers and \
|
|
424
|
+
FileType(self.layers[0]['format']).value in ['GeoTIFF']):
|
|
425
425
|
publish_as = PublishFileType.RASTER
|
|
426
|
-
|
|
426
|
+
|
|
427
|
+
elif self.file_type.value in ['GLB'] or \
|
|
428
|
+
(self.file_type.value in ['Complex'] and self.layers and \
|
|
429
|
+
FileType(self.layers[0]['format']).value in ['GLB']):
|
|
427
430
|
publish_as = PublishFileType.MODEL3D
|
|
428
431
|
|
|
432
|
+
else:
|
|
433
|
+
raise ValidationError('Unknown format')
|
|
434
|
+
|
|
429
435
|
data = clean_data({
|
|
430
436
|
"publish_as": publish_as.value if isinstance(publish_as, PublishFileType) else publish_as,
|
|
431
437
|
"layer_name": name,
|
|
432
|
-
"input_layer": input_layer,
|
|
438
|
+
"input_layer": self.layers[0]['layer'] if not input_layer and self.layers else input_layer,
|
|
433
439
|
"input_geom_type": input_geom_type.value if isinstance(input_geom_type, InputGeomType) else input_geom_type,
|
|
434
440
|
"replace_domain_codes_by_values": replace_domain_codes_by_values,
|
|
435
|
-
"input_dataset": self.
|
|
441
|
+
"input_dataset": self.layers[0]['dataset'] if not input_layer and self.layers else input_dataset,
|
|
436
442
|
"user_id": user_id,
|
|
437
443
|
"input_srid": input_srid,
|
|
438
444
|
"file_encoding": file_encoding,
|
|
439
445
|
"report_errors": report_errors,
|
|
440
446
|
"as_terrain": as_terrain
|
|
441
447
|
})
|
|
442
|
-
|
|
443
448
|
endpoint = urljoin(self.endpoint, 'publish/')
|
|
444
449
|
response = self.api.post(endpoint, data, is_json=False)
|
|
445
450
|
task = Task.get_task(self.api, response.get('task_id'))
|
|
@@ -621,31 +621,32 @@ class Map(Base):
|
|
|
621
621
|
grid_settings = {'enable_grid', 'grid_unit', 'grid_width', 'grid_height', 'grid_minzoom', 'grid_maxzoom'}
|
|
622
622
|
view_settings = {'bearing', 'pitch', 'center', 'zoom'}
|
|
623
623
|
|
|
624
|
+
settings = self.settings
|
|
625
|
+
|
|
624
626
|
for key, value in kwargs.items():
|
|
625
627
|
if key in general_settings:
|
|
626
|
-
|
|
628
|
+
settings['general_settings'][key] = value
|
|
627
629
|
elif key in edit_settings:
|
|
628
|
-
|
|
630
|
+
settings['edit_settings'][key] = value
|
|
629
631
|
elif key in snap_settings:
|
|
630
|
-
|
|
632
|
+
settings['snap_settings'][key] = value
|
|
631
633
|
elif key == 'controls':
|
|
632
|
-
|
|
634
|
+
settings['controls'] = value
|
|
633
635
|
elif key in search_settings:
|
|
634
|
-
|
|
636
|
+
settings['search_settings'][key] = value
|
|
635
637
|
elif key in marker_settings:
|
|
636
|
-
|
|
638
|
+
settings['marker_settings'][key] = value
|
|
637
639
|
elif key in terrain_settings:
|
|
638
|
-
|
|
640
|
+
settings['terrain_settings'][key] = value
|
|
639
641
|
elif key in grid_settings:
|
|
640
|
-
|
|
642
|
+
settings['grid_settings'][key] = value
|
|
641
643
|
elif key in view_settings:
|
|
642
|
-
|
|
644
|
+
settings['view_settings'][key] = value
|
|
643
645
|
elif key == 'toc_settings':
|
|
644
|
-
|
|
646
|
+
settings['toc_settings'] = value
|
|
647
|
+
|
|
648
|
+
return super()._set_settings(self.endpoint, settings)
|
|
645
649
|
|
|
646
|
-
endpoint = urljoin(self.endpoint, 'settings/')
|
|
647
|
-
self.api.put(endpoint, self.settings)
|
|
648
|
-
|
|
649
650
|
|
|
650
651
|
def get_markers(self) -> Dict:
|
|
651
652
|
"""
|
|
@@ -608,10 +608,7 @@ class Raster(Base):
|
|
|
608
608
|
'min_zoom', 'max_zoom', 'use_cache', 'cache_until_zoom'
|
|
609
609
|
}
|
|
610
610
|
|
|
611
|
-
settings =
|
|
612
|
-
'visual_settings': {},
|
|
613
|
-
'tile_settings': {}
|
|
614
|
-
}
|
|
611
|
+
settings = self.settings
|
|
615
612
|
|
|
616
613
|
for key, value in kwargs.items():
|
|
617
614
|
if key in visual_settings:
|
|
@@ -620,7 +617,7 @@ class Raster(Base):
|
|
|
620
617
|
settings['tile_settings'][key] = value
|
|
621
618
|
|
|
622
619
|
|
|
623
|
-
super()._set_settings(self.endpoint, settings)
|
|
620
|
+
return super()._set_settings(self.endpoint, settings)
|
|
624
621
|
|
|
625
622
|
|
|
626
623
|
def share(self, users: List['User']) -> None:
|
|
@@ -10,6 +10,7 @@ if TYPE_CHECKING:
|
|
|
10
10
|
from .vectorlayer import VectorLayer
|
|
11
11
|
from .raster import Raster
|
|
12
12
|
from .model3d import Model
|
|
13
|
+
from .file import File
|
|
13
14
|
|
|
14
15
|
class Task(Base):
|
|
15
16
|
"""
|
|
@@ -45,9 +46,9 @@ class Task(Base):
|
|
|
45
46
|
|
|
46
47
|
|
|
47
48
|
@property
|
|
48
|
-
def
|
|
49
|
+
def output_asset(self) -> Union['VectorLayer', 'Raster', 'Model', 'File', None]:
|
|
49
50
|
"""
|
|
50
|
-
|
|
51
|
+
output asset property
|
|
51
52
|
|
|
52
53
|
Returns:
|
|
53
54
|
VectorLayer | Raster | Model | None: if task type is publish, it returns the published layer
|
|
@@ -57,14 +58,20 @@ class Task(Base):
|
|
|
57
58
|
>>> from geobox.task import Task
|
|
58
59
|
>>> client = GeoboxClient()
|
|
59
60
|
>>> task = Task.get_task(client, uuid="12345678-1234-5678-1234-567812345678")
|
|
60
|
-
>>> task.
|
|
61
|
+
>>> task.output_asset
|
|
61
62
|
"""
|
|
62
|
-
if self.
|
|
63
|
-
return self.api.get_raster(uuid=self.data['result']['raster_uuid'])
|
|
64
|
-
elif self.name == 'import:publish-file-to-vector-layer':
|
|
63
|
+
if self.data.get('result', {}).get('layer_uuid'):
|
|
65
64
|
return self.api.get_vector(uuid=self.data['result']['layer_uuid'])
|
|
66
|
-
|
|
65
|
+
|
|
66
|
+
elif self.data.get('result', {}).get('raster_uuid'):
|
|
67
|
+
return self.api.get_raster(uuid=self.data['result']['raster_uuid'])
|
|
68
|
+
|
|
69
|
+
elif self.data.get('result', {}).get('model_uuid'):
|
|
67
70
|
return self.api.get_model(uuid=self.data['result']['model_uuid'])
|
|
71
|
+
|
|
72
|
+
elif self.data.get('result', {}).get('file_uuid'):
|
|
73
|
+
return self.api.get_file(uuid=self.data['result']['file_uuid'])
|
|
74
|
+
|
|
68
75
|
else:
|
|
69
76
|
return None
|
|
70
77
|
|