geobox 1.1.0__py3-none-any.whl → 1.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.
- geobox/api.py +5 -5
- geobox/enums.py +15 -1
- geobox/file.py +36 -15
- {geobox-1.1.0.dist-info → geobox-1.2.0.dist-info}/METADATA +1 -1
- {geobox-1.1.0.dist-info → geobox-1.2.0.dist-info}/RECORD +8 -8
- {geobox-1.1.0.dist-info → geobox-1.2.0.dist-info}/WHEEL +0 -0
- {geobox-1.1.0.dist-info → geobox-1.2.0.dist-info}/licenses/LICENSE +0 -0
- {geobox-1.1.0.dist-info → geobox-1.2.0.dist-info}/top_level.txt +0 -0
geobox/api.py
CHANGED
|
@@ -597,23 +597,23 @@ class GeoboxClient:
|
|
|
597
597
|
return File.get_file(self, uuid=uuid)
|
|
598
598
|
|
|
599
599
|
|
|
600
|
-
def
|
|
600
|
+
def get_files_by_name(self, name: str, user_id: int = None) -> List['File']:
|
|
601
601
|
"""
|
|
602
|
-
Get
|
|
602
|
+
Get files by name
|
|
603
603
|
|
|
604
604
|
Args:
|
|
605
605
|
name (str): the name of the file to get
|
|
606
606
|
user_id (int, optional): specific user. privileges required.
|
|
607
607
|
|
|
608
608
|
Returns:
|
|
609
|
-
File
|
|
609
|
+
List[File]: returns files that matches the given name
|
|
610
610
|
|
|
611
611
|
Example:
|
|
612
612
|
>>> from geobox import GeoboxClient
|
|
613
613
|
>>> client = GeoboxClient()
|
|
614
|
-
>>>
|
|
614
|
+
>>> files = client.get_files_by_name(name='test')
|
|
615
615
|
"""
|
|
616
|
-
return File.
|
|
616
|
+
return File.get_files_by_name(self, name, user_id)
|
|
617
617
|
|
|
618
618
|
|
|
619
619
|
def upload_file(self, path: str, user_id: int = None, scan_archive: bool = True) -> 'File':
|
geobox/enums.py
CHANGED
|
@@ -21,6 +21,20 @@ 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
|
+
Shapefile = 'Shapefile'
|
|
32
|
+
KML = 'KML'
|
|
33
|
+
GLB = 'GLB'
|
|
34
|
+
FileGDB = 'FileGDB'
|
|
35
|
+
GeoTIFF = 'GeoTIFF'
|
|
36
|
+
|
|
37
|
+
class FileFormat(Enum):
|
|
24
38
|
# Spatial Data Formats
|
|
25
39
|
Shapefile = '.shp'
|
|
26
40
|
FileGDB = '.gdb'
|
|
@@ -30,7 +44,7 @@ class FileType(Enum):
|
|
|
30
44
|
GPX = '.gpx'
|
|
31
45
|
GPKG = '.gpkg'
|
|
32
46
|
GeoJSON = '.geojson'
|
|
33
|
-
GeoTIFF = '.
|
|
47
|
+
# GeoTIFF = '.tiff'
|
|
34
48
|
|
|
35
49
|
# Image Formats
|
|
36
50
|
JPG = '.jpg'
|
geobox/file.py
CHANGED
|
@@ -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,
|
|
@@ -188,9 +205,9 @@ class File(Base):
|
|
|
188
205
|
|
|
189
206
|
|
|
190
207
|
@classmethod
|
|
191
|
-
def
|
|
208
|
+
def get_files_by_name(cls, api: 'GeoboxClient', name: str, user_id: int = None) -> List['File']:
|
|
192
209
|
"""
|
|
193
|
-
Get
|
|
210
|
+
Get files by name
|
|
194
211
|
|
|
195
212
|
Args:
|
|
196
213
|
api (GeoboxClient): The GeoboxClient instance for making requests.
|
|
@@ -198,21 +215,17 @@ class File(Base):
|
|
|
198
215
|
user_id (int, optional): specific user. privileges required.
|
|
199
216
|
|
|
200
217
|
Returns:
|
|
201
|
-
File
|
|
218
|
+
List[File]: returns files that matches the given name
|
|
202
219
|
|
|
203
220
|
Example:
|
|
204
221
|
>>> from geobox import GeoboxClient
|
|
205
222
|
>>> from geobox.file import File
|
|
206
223
|
>>> client = GeoboxClient()
|
|
207
|
-
>>>
|
|
224
|
+
>>> files = File.get_file_by_name(client, name='test')
|
|
208
225
|
or
|
|
209
|
-
>>>
|
|
226
|
+
>>> files = client.get_file_by_name(name='test')
|
|
210
227
|
"""
|
|
211
|
-
|
|
212
|
-
if files and files[0].name == name:
|
|
213
|
-
return files[0]
|
|
214
|
-
else:
|
|
215
|
-
return None
|
|
228
|
+
return cls.get_files(api, q=f"name = '{name}'", user_id=user_id)
|
|
216
229
|
|
|
217
230
|
|
|
218
231
|
def _get_save_path(self, save_path: str = None) -> str:
|
|
@@ -359,8 +372,8 @@ class File(Base):
|
|
|
359
372
|
|
|
360
373
|
|
|
361
374
|
def publish(self,
|
|
362
|
-
publish_as: 'PublishFileType',
|
|
363
375
|
name: str,
|
|
376
|
+
publish_as: 'PublishFileType' = None,
|
|
364
377
|
input_geom_type: 'InputGeomType' = None,
|
|
365
378
|
input_layer: str = None,
|
|
366
379
|
input_dataset: str = None,
|
|
@@ -374,8 +387,8 @@ class File(Base):
|
|
|
374
387
|
Publishes a file as a layer.
|
|
375
388
|
|
|
376
389
|
Args:
|
|
377
|
-
publish_as (PublishFileType): The type of layer to publish as.
|
|
378
390
|
name (str): The name of the layer.
|
|
391
|
+
publish_as (PublishFileType): The type of layer to publish as.
|
|
379
392
|
input_geom_type (InputGeomType, optional): The geometry type of the layer.
|
|
380
393
|
input_layer (str, optional): The name of the input layer.
|
|
381
394
|
input_dataset (str, optional): The name of the input dataset.
|
|
@@ -405,6 +418,14 @@ class File(Base):
|
|
|
405
418
|
... input_srid=4326,
|
|
406
419
|
... file_encoding='utf-8')
|
|
407
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
|
+
|
|
408
429
|
data = clean_data({
|
|
409
430
|
"publish_as": publish_as.value if isinstance(publish_as, PublishFileType) else publish_as,
|
|
410
431
|
"layer_name": name,
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
geobox/__init__.py,sha256=iRkJAFIjMXiAaLTVXvZcW5HM7ttyipGdxFZ15NCM8qU,1895
|
|
2
|
-
geobox/api.py,sha256=
|
|
2
|
+
geobox/api.py,sha256=Sq9iKYltgdR96cA4w5_5jMraNqAUpgSzMriO9PbZFNA,100538
|
|
3
3
|
geobox/apikey.py,sha256=FBio1PtGovAUaTE0HW9IJ55UuFdR_1ICk_FQhHu5dAE,7427
|
|
4
4
|
geobox/attachment.py,sha256=XbGwfWWuFAMimj4tsjKBvlSLP-rhpNACCtxgRmUvcdY,11631
|
|
5
5
|
geobox/base.py,sha256=p0UVZo9CINw0mW9o0nNR_VNCk7V1r-FrLQ_NH39WARE,12299
|
|
6
6
|
geobox/basemap.py,sha256=fDWwkMf-F2NTE1tVLijoxQku55825b6gj8nk69TMOII,4386
|
|
7
7
|
geobox/dashboard.py,sha256=MYyT3YJEGPCbTXHcYoZmn14rFOaut1J3idEA8bCdFgI,11762
|
|
8
|
-
geobox/enums.py,sha256=
|
|
8
|
+
geobox/enums.py,sha256=0p8gbyrnT-HCwYmSZw2MreB-_UhccXqpVY-iOI97Llc,6557
|
|
9
9
|
geobox/exception.py,sha256=jvpnv0M2Ck1FpxHTL_aKYWxGvLnCQ3d9vOrMIktjw1U,1507
|
|
10
10
|
geobox/feature.py,sha256=3Kbc1LjIkBt1YqRAry84BrR7qxx9BexvBB3YQ8D9mGk,18504
|
|
11
11
|
geobox/field.py,sha256=2VxjeYgRwnDxHYpAsK0ASOCz8V0JmfTA3GqHDv3rfgQ,10526
|
|
12
|
-
geobox/file.py,sha256=
|
|
12
|
+
geobox/file.py,sha256=NqN9EoSGMiTev5vo_1QKciofcyoXonLoZz7B8hH_igk,19352
|
|
13
13
|
geobox/log.py,sha256=ZTmVErhyAszf7M5YFxT5mqXNNDGPnRwXPeGLDS1G6PE,3582
|
|
14
14
|
geobox/map.py,sha256=98P1gbB5U_eu71Hu6EQ0kL_ponbPAnoOCitjEa35q4I,31307
|
|
15
15
|
geobox/model3d.py,sha256=qRYCx-q9LpGhdu5oz3av0uUoiDimuk4BvXXwMW5bo9Q,12061
|
|
@@ -30,8 +30,8 @@ geobox/vectorlayer.py,sha256=xnYsJei-bpKgM_EJlRbZ-bAIHdmvfU-VZ2t-NEEJCfc,49420
|
|
|
30
30
|
geobox/version.py,sha256=0GLPhxCeEb2bAkdpPJWtXPXc1KP6kQ_TOMwLAL0ldo0,9374
|
|
31
31
|
geobox/view.py,sha256=fRYlzNu4eGl6Zx9gPom47BkVE8DfWLj0bNlW2-u4TOU,37390
|
|
32
32
|
geobox/workflow.py,sha256=6hKnSw4G0_ZlgmUb0g3fxT-UVsFbiYpF2FbEO5fpQv0,11606
|
|
33
|
-
geobox-1.
|
|
34
|
-
geobox-1.
|
|
35
|
-
geobox-1.
|
|
36
|
-
geobox-1.
|
|
37
|
-
geobox-1.
|
|
33
|
+
geobox-1.2.0.dist-info/licenses/LICENSE,sha256=AvFB7W94sJYKLDhBxLRshL3upexCOG8HQY_1JibB96w,1063
|
|
34
|
+
geobox-1.2.0.dist-info/METADATA,sha256=F2b-L6jZYKlOsWSZnwf-zZu5lFTLbI1XeNKwVUse41M,2556
|
|
35
|
+
geobox-1.2.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
36
|
+
geobox-1.2.0.dist-info/top_level.txt,sha256=ppXH8Bu2mlB-pLQ6lsoWEm2Gr6wZx1uzkhetsYA5ins,7
|
|
37
|
+
geobox-1.2.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|