geobox 1.1.1__tar.gz → 1.2.1__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.1.1 → geobox-1.2.1}/PKG-INFO +1 -1
- {geobox-1.1.1 → geobox-1.2.1}/geobox/enums.py +18 -1
- {geobox-1.1.1 → geobox-1.2.1}/geobox/file.py +30 -5
- {geobox-1.1.1 → geobox-1.2.1}/geobox.egg-info/PKG-INFO +1 -1
- {geobox-1.1.1 → geobox-1.2.1}/pyproject.toml +1 -1
- {geobox-1.1.1 → geobox-1.2.1}/tests/test_file.py +8 -11
- {geobox-1.1.1 → geobox-1.2.1}/LICENSE +0 -0
- {geobox-1.1.1 → geobox-1.2.1}/README.md +0 -0
- {geobox-1.1.1 → geobox-1.2.1}/geobox/__init__.py +0 -0
- {geobox-1.1.1 → geobox-1.2.1}/geobox/api.py +0 -0
- {geobox-1.1.1 → geobox-1.2.1}/geobox/apikey.py +0 -0
- {geobox-1.1.1 → geobox-1.2.1}/geobox/attachment.py +0 -0
- {geobox-1.1.1 → geobox-1.2.1}/geobox/base.py +0 -0
- {geobox-1.1.1 → geobox-1.2.1}/geobox/basemap.py +0 -0
- {geobox-1.1.1 → geobox-1.2.1}/geobox/dashboard.py +0 -0
- {geobox-1.1.1 → geobox-1.2.1}/geobox/exception.py +0 -0
- {geobox-1.1.1 → geobox-1.2.1}/geobox/feature.py +0 -0
- {geobox-1.1.1 → geobox-1.2.1}/geobox/field.py +0 -0
- {geobox-1.1.1 → geobox-1.2.1}/geobox/log.py +0 -0
- {geobox-1.1.1 → geobox-1.2.1}/geobox/map.py +0 -0
- {geobox-1.1.1 → geobox-1.2.1}/geobox/model3d.py +0 -0
- {geobox-1.1.1 → geobox-1.2.1}/geobox/mosaic.py +0 -0
- {geobox-1.1.1 → geobox-1.2.1}/geobox/plan.py +0 -0
- {geobox-1.1.1 → geobox-1.2.1}/geobox/query.py +0 -0
- {geobox-1.1.1 → geobox-1.2.1}/geobox/raster.py +0 -0
- {geobox-1.1.1 → geobox-1.2.1}/geobox/route.py +0 -0
- {geobox-1.1.1 → geobox-1.2.1}/geobox/scene.py +0 -0
- {geobox-1.1.1 → geobox-1.2.1}/geobox/settings.py +0 -0
- {geobox-1.1.1 → geobox-1.2.1}/geobox/task.py +0 -0
- {geobox-1.1.1 → geobox-1.2.1}/geobox/tile3d.py +0 -0
- {geobox-1.1.1 → geobox-1.2.1}/geobox/tileset.py +0 -0
- {geobox-1.1.1 → geobox-1.2.1}/geobox/usage.py +0 -0
- {geobox-1.1.1 → geobox-1.2.1}/geobox/user.py +0 -0
- {geobox-1.1.1 → geobox-1.2.1}/geobox/utils.py +0 -0
- {geobox-1.1.1 → geobox-1.2.1}/geobox/vectorlayer.py +0 -0
- {geobox-1.1.1 → geobox-1.2.1}/geobox/version.py +0 -0
- {geobox-1.1.1 → geobox-1.2.1}/geobox/view.py +0 -0
- {geobox-1.1.1 → geobox-1.2.1}/geobox/workflow.py +0 -0
- {geobox-1.1.1 → geobox-1.2.1}/geobox.egg-info/SOURCES.txt +0 -0
- {geobox-1.1.1 → geobox-1.2.1}/geobox.egg-info/dependency_links.txt +0 -0
- {geobox-1.1.1 → geobox-1.2.1}/geobox.egg-info/requires.txt +0 -0
- {geobox-1.1.1 → geobox-1.2.1}/geobox.egg-info/top_level.txt +0 -0
- {geobox-1.1.1 → geobox-1.2.1}/setup.cfg +0 -0
- {geobox-1.1.1 → geobox-1.2.1}/tests/test_api.py +0 -0
- {geobox-1.1.1 → geobox-1.2.1}/tests/test_apikey.py +0 -0
- {geobox-1.1.1 → geobox-1.2.1}/tests/test_attachment.py +0 -0
- {geobox-1.1.1 → geobox-1.2.1}/tests/test_basemap.py +0 -0
- {geobox-1.1.1 → geobox-1.2.1}/tests/test_dashboard.py +0 -0
- {geobox-1.1.1 → geobox-1.2.1}/tests/test_feature.py +0 -0
- {geobox-1.1.1 → geobox-1.2.1}/tests/test_field.py +0 -0
- {geobox-1.1.1 → geobox-1.2.1}/tests/test_log.py +0 -0
- {geobox-1.1.1 → geobox-1.2.1}/tests/test_map.py +0 -0
- {geobox-1.1.1 → geobox-1.2.1}/tests/test_model3d.py +0 -0
- {geobox-1.1.1 → geobox-1.2.1}/tests/test_mosaic.py +0 -0
- {geobox-1.1.1 → geobox-1.2.1}/tests/test_plan.py +0 -0
- {geobox-1.1.1 → geobox-1.2.1}/tests/test_query.py +0 -0
- {geobox-1.1.1 → geobox-1.2.1}/tests/test_raster.py +0 -0
- {geobox-1.1.1 → geobox-1.2.1}/tests/test_route.py +0 -0
- {geobox-1.1.1 → geobox-1.2.1}/tests/test_scene.py +0 -0
- {geobox-1.1.1 → geobox-1.2.1}/tests/test_settings.py +0 -0
- {geobox-1.1.1 → geobox-1.2.1}/tests/test_task.py +0 -0
- {geobox-1.1.1 → geobox-1.2.1}/tests/test_tile3d.py +0 -0
- {geobox-1.1.1 → geobox-1.2.1}/tests/test_tileset.py +0 -0
- {geobox-1.1.1 → geobox-1.2.1}/tests/test_usage.py +0 -0
- {geobox-1.1.1 → geobox-1.2.1}/tests/test_user.py +0 -0
- {geobox-1.1.1 → geobox-1.2.1}/tests/test_vectorlayer.py +0 -0
- {geobox-1.1.1 → geobox-1.2.1}/tests/test_version.py +0 -0
- {geobox-1.1.1 → geobox-1.2.1}/tests/test_view.py +0 -0
- {geobox-1.1.1 → geobox-1.2.1}/tests/test_workflow.py +0 -0
|
@@ -21,6 +21,23 @@ class PublishFileType(Enum):
|
|
|
21
21
|
MODEL3D = 'model3d'
|
|
22
22
|
|
|
23
23
|
class FileType(Enum):
|
|
24
|
+
Compressed = 'Compressed'
|
|
25
|
+
Complex = 'Complex'
|
|
26
|
+
Image = 'Image'
|
|
27
|
+
Video = 'Video'
|
|
28
|
+
Document = 'Document'
|
|
29
|
+
GPKG = 'GPKG'
|
|
30
|
+
DXF = 'DXF'
|
|
31
|
+
GPX = 'GPX'
|
|
32
|
+
CSV = 'CSV'
|
|
33
|
+
Shapefile = 'Shapefile'
|
|
34
|
+
KML = 'KML'
|
|
35
|
+
GLB = 'GLB'
|
|
36
|
+
FileGDB = 'FileGDB'
|
|
37
|
+
GeoTIFF = 'GeoTIFF'
|
|
38
|
+
GeoJSON = 'GeoJSON'
|
|
39
|
+
|
|
40
|
+
class FileFormat(Enum):
|
|
24
41
|
# Spatial Data Formats
|
|
25
42
|
Shapefile = '.shp'
|
|
26
43
|
FileGDB = '.gdb'
|
|
@@ -30,7 +47,7 @@ class FileType(Enum):
|
|
|
30
47
|
GPX = '.gpx'
|
|
31
48
|
GPKG = '.gpkg'
|
|
32
49
|
GeoJSON = '.geojson'
|
|
33
|
-
GeoTIFF = '.tiff'
|
|
50
|
+
# GeoTIFF = '.tiff'
|
|
34
51
|
|
|
35
52
|
# Image Formats
|
|
36
53
|
JPG = '.jpg'
|
|
@@ -6,7 +6,7 @@ import requests
|
|
|
6
6
|
import sys
|
|
7
7
|
|
|
8
8
|
from .base import Base
|
|
9
|
-
from .enums import
|
|
9
|
+
from .enums import FileFormat, PublishFileType, InputGeomType, FileType
|
|
10
10
|
from .utils import clean_data
|
|
11
11
|
from .task import Task
|
|
12
12
|
|
|
@@ -46,7 +46,7 @@ class File(Base):
|
|
|
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})"
|
|
49
|
+
return f"File(uuid={self.uuid}, file_name={self.name}, file_type={self.file_type.value})"
|
|
50
50
|
|
|
51
51
|
|
|
52
52
|
@property
|
|
@@ -66,6 +66,23 @@ class File(Base):
|
|
|
66
66
|
return self.data.get('layers', {}).get('layers', [])
|
|
67
67
|
|
|
68
68
|
|
|
69
|
+
@property
|
|
70
|
+
def file_type(self) -> 'FileType':
|
|
71
|
+
"""
|
|
72
|
+
Get the file type
|
|
73
|
+
|
|
74
|
+
Returns:
|
|
75
|
+
FileType: the file type enumeration
|
|
76
|
+
|
|
77
|
+
Example:
|
|
78
|
+
>>> from geobox import GeoboxClient
|
|
79
|
+
>>> client = GeoboxClient()
|
|
80
|
+
>>> file = File.get_file(client, uuid="12345678-1234-5678-1234-567812345678")
|
|
81
|
+
>>> file.file_type
|
|
82
|
+
"""
|
|
83
|
+
return FileType(self.data.get('file_type'))
|
|
84
|
+
|
|
85
|
+
|
|
69
86
|
@classmethod
|
|
70
87
|
def upload_file(cls, api: 'GeoboxClient', path: str, user_id: int = None, scan_archive: bool = True) -> 'File':
|
|
71
88
|
"""
|
|
@@ -97,7 +114,7 @@ class File(Base):
|
|
|
97
114
|
raise FileNotFoundError(f"File not found: {path}")
|
|
98
115
|
|
|
99
116
|
# Check if the file type is valid
|
|
100
|
-
|
|
117
|
+
FileFormat(os.path.splitext(path)[1])
|
|
101
118
|
|
|
102
119
|
data = clean_data({
|
|
103
120
|
"user_id": user_id,
|
|
@@ -355,8 +372,8 @@ class File(Base):
|
|
|
355
372
|
|
|
356
373
|
|
|
357
374
|
def publish(self,
|
|
358
|
-
publish_as: 'PublishFileType',
|
|
359
375
|
name: str,
|
|
376
|
+
publish_as: 'PublishFileType' = None,
|
|
360
377
|
input_geom_type: 'InputGeomType' = None,
|
|
361
378
|
input_layer: str = None,
|
|
362
379
|
input_dataset: str = None,
|
|
@@ -370,8 +387,8 @@ class File(Base):
|
|
|
370
387
|
Publishes a file as a layer.
|
|
371
388
|
|
|
372
389
|
Args:
|
|
373
|
-
publish_as (PublishFileType): The type of layer to publish as.
|
|
374
390
|
name (str): The name of the layer.
|
|
391
|
+
publish_as (PublishFileType): The type of layer to publish as.
|
|
375
392
|
input_geom_type (InputGeomType, optional): The geometry type of the layer.
|
|
376
393
|
input_layer (str, optional): The name of the input layer.
|
|
377
394
|
input_dataset (str, optional): The name of the input dataset.
|
|
@@ -401,6 +418,14 @@ class File(Base):
|
|
|
401
418
|
... input_srid=4326,
|
|
402
419
|
... file_encoding='utf-8')
|
|
403
420
|
"""
|
|
421
|
+
if not publish_as:
|
|
422
|
+
if self.file_type.value in ['GeoJSON', 'GPKG', 'DXF', 'GPX', 'Shapefile', 'KML', 'CSV', 'FileGDB']:
|
|
423
|
+
publish_as = PublishFileType.VECTOR
|
|
424
|
+
elif self.file_type.value in ['GeoTIFF']:
|
|
425
|
+
publish_as = PublishFileType.RASTER
|
|
426
|
+
elif self.file_type.value in ['GLB']:
|
|
427
|
+
publish_as = PublishFileType.MODEL3D
|
|
428
|
+
|
|
404
429
|
data = clean_data({
|
|
405
430
|
"publish_as": publish_as.value if isinstance(publish_as, PublishFileType) else publish_as,
|
|
406
431
|
"layer_name": name,
|
|
@@ -24,7 +24,7 @@ def test_properties(api, mock_file_data):
|
|
|
24
24
|
"""Test File properties."""
|
|
25
25
|
file = File(api, uuid=mock_file_data['uuid'], data=mock_file_data)
|
|
26
26
|
assert file.name == 'world_boundaries.shp'
|
|
27
|
-
assert file.file_type == 'Shapefile'
|
|
27
|
+
assert file.file_type.value == 'Shapefile'
|
|
28
28
|
assert file.size == 7588516
|
|
29
29
|
assert file.feature_count == 394
|
|
30
30
|
assert file.layer_count == 1
|
|
@@ -77,7 +77,7 @@ def test_upload_file_invalid_type(api):
|
|
|
77
77
|
# Use the actual extension string
|
|
78
78
|
invalid_extension = os.path.splitext(temp_file_path)[1]
|
|
79
79
|
|
|
80
|
-
with pytest.raises(ValueError, match=f".invalid' is not a valid
|
|
80
|
+
with pytest.raises(ValueError, match=f".invalid' is not a valid FileFormat"):
|
|
81
81
|
File.upload_file(api, temp_file_path)
|
|
82
82
|
|
|
83
83
|
# Clean up
|
|
@@ -265,24 +265,21 @@ def test_delete(api, mock_file_data):
|
|
|
265
265
|
api.delete.assert_called_once_with(f'files/{mock_file_data["uuid"]}/')
|
|
266
266
|
|
|
267
267
|
|
|
268
|
-
@pytest.mark.parametrize("
|
|
269
|
-
(
|
|
270
|
-
for
|
|
271
|
-
for geom_type in InputGeomType
|
|
268
|
+
@pytest.mark.parametrize("file_type", [
|
|
269
|
+
(type)
|
|
270
|
+
for type in FileType
|
|
272
271
|
])
|
|
273
|
-
def test_publish(api, mock_file_data,
|
|
272
|
+
def test_publish(api, mock_file_data, mock_success_task_data, file_type):
|
|
274
273
|
"""Test file publishing with all combinations of publish types and geometry types."""
|
|
275
274
|
mock_response = {
|
|
276
275
|
'task_id': mock_success_task_data['id']
|
|
277
276
|
}
|
|
278
|
-
|
|
277
|
+
mock_file_data['file_type'] = file_type.value
|
|
279
278
|
with patch.object(api, 'post', return_value=mock_response) as mock_post:
|
|
280
279
|
with patch.object(api, 'get', return_value=mock_success_task_data) as mock_post:
|
|
281
280
|
file = File(api, uuid=mock_file_data['uuid'], data=mock_file_data)
|
|
282
281
|
result = file.publish(
|
|
283
|
-
|
|
284
|
-
name='test_layer',
|
|
285
|
-
input_geom_type=geom_type
|
|
282
|
+
name='test_layer'
|
|
286
283
|
)
|
|
287
284
|
|
|
288
285
|
# Verify the response
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|