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.
Files changed (69) hide show
  1. {geobox-1.1.1 → geobox-1.2.1}/PKG-INFO +1 -1
  2. {geobox-1.1.1 → geobox-1.2.1}/geobox/enums.py +18 -1
  3. {geobox-1.1.1 → geobox-1.2.1}/geobox/file.py +30 -5
  4. {geobox-1.1.1 → geobox-1.2.1}/geobox.egg-info/PKG-INFO +1 -1
  5. {geobox-1.1.1 → geobox-1.2.1}/pyproject.toml +1 -1
  6. {geobox-1.1.1 → geobox-1.2.1}/tests/test_file.py +8 -11
  7. {geobox-1.1.1 → geobox-1.2.1}/LICENSE +0 -0
  8. {geobox-1.1.1 → geobox-1.2.1}/README.md +0 -0
  9. {geobox-1.1.1 → geobox-1.2.1}/geobox/__init__.py +0 -0
  10. {geobox-1.1.1 → geobox-1.2.1}/geobox/api.py +0 -0
  11. {geobox-1.1.1 → geobox-1.2.1}/geobox/apikey.py +0 -0
  12. {geobox-1.1.1 → geobox-1.2.1}/geobox/attachment.py +0 -0
  13. {geobox-1.1.1 → geobox-1.2.1}/geobox/base.py +0 -0
  14. {geobox-1.1.1 → geobox-1.2.1}/geobox/basemap.py +0 -0
  15. {geobox-1.1.1 → geobox-1.2.1}/geobox/dashboard.py +0 -0
  16. {geobox-1.1.1 → geobox-1.2.1}/geobox/exception.py +0 -0
  17. {geobox-1.1.1 → geobox-1.2.1}/geobox/feature.py +0 -0
  18. {geobox-1.1.1 → geobox-1.2.1}/geobox/field.py +0 -0
  19. {geobox-1.1.1 → geobox-1.2.1}/geobox/log.py +0 -0
  20. {geobox-1.1.1 → geobox-1.2.1}/geobox/map.py +0 -0
  21. {geobox-1.1.1 → geobox-1.2.1}/geobox/model3d.py +0 -0
  22. {geobox-1.1.1 → geobox-1.2.1}/geobox/mosaic.py +0 -0
  23. {geobox-1.1.1 → geobox-1.2.1}/geobox/plan.py +0 -0
  24. {geobox-1.1.1 → geobox-1.2.1}/geobox/query.py +0 -0
  25. {geobox-1.1.1 → geobox-1.2.1}/geobox/raster.py +0 -0
  26. {geobox-1.1.1 → geobox-1.2.1}/geobox/route.py +0 -0
  27. {geobox-1.1.1 → geobox-1.2.1}/geobox/scene.py +0 -0
  28. {geobox-1.1.1 → geobox-1.2.1}/geobox/settings.py +0 -0
  29. {geobox-1.1.1 → geobox-1.2.1}/geobox/task.py +0 -0
  30. {geobox-1.1.1 → geobox-1.2.1}/geobox/tile3d.py +0 -0
  31. {geobox-1.1.1 → geobox-1.2.1}/geobox/tileset.py +0 -0
  32. {geobox-1.1.1 → geobox-1.2.1}/geobox/usage.py +0 -0
  33. {geobox-1.1.1 → geobox-1.2.1}/geobox/user.py +0 -0
  34. {geobox-1.1.1 → geobox-1.2.1}/geobox/utils.py +0 -0
  35. {geobox-1.1.1 → geobox-1.2.1}/geobox/vectorlayer.py +0 -0
  36. {geobox-1.1.1 → geobox-1.2.1}/geobox/version.py +0 -0
  37. {geobox-1.1.1 → geobox-1.2.1}/geobox/view.py +0 -0
  38. {geobox-1.1.1 → geobox-1.2.1}/geobox/workflow.py +0 -0
  39. {geobox-1.1.1 → geobox-1.2.1}/geobox.egg-info/SOURCES.txt +0 -0
  40. {geobox-1.1.1 → geobox-1.2.1}/geobox.egg-info/dependency_links.txt +0 -0
  41. {geobox-1.1.1 → geobox-1.2.1}/geobox.egg-info/requires.txt +0 -0
  42. {geobox-1.1.1 → geobox-1.2.1}/geobox.egg-info/top_level.txt +0 -0
  43. {geobox-1.1.1 → geobox-1.2.1}/setup.cfg +0 -0
  44. {geobox-1.1.1 → geobox-1.2.1}/tests/test_api.py +0 -0
  45. {geobox-1.1.1 → geobox-1.2.1}/tests/test_apikey.py +0 -0
  46. {geobox-1.1.1 → geobox-1.2.1}/tests/test_attachment.py +0 -0
  47. {geobox-1.1.1 → geobox-1.2.1}/tests/test_basemap.py +0 -0
  48. {geobox-1.1.1 → geobox-1.2.1}/tests/test_dashboard.py +0 -0
  49. {geobox-1.1.1 → geobox-1.2.1}/tests/test_feature.py +0 -0
  50. {geobox-1.1.1 → geobox-1.2.1}/tests/test_field.py +0 -0
  51. {geobox-1.1.1 → geobox-1.2.1}/tests/test_log.py +0 -0
  52. {geobox-1.1.1 → geobox-1.2.1}/tests/test_map.py +0 -0
  53. {geobox-1.1.1 → geobox-1.2.1}/tests/test_model3d.py +0 -0
  54. {geobox-1.1.1 → geobox-1.2.1}/tests/test_mosaic.py +0 -0
  55. {geobox-1.1.1 → geobox-1.2.1}/tests/test_plan.py +0 -0
  56. {geobox-1.1.1 → geobox-1.2.1}/tests/test_query.py +0 -0
  57. {geobox-1.1.1 → geobox-1.2.1}/tests/test_raster.py +0 -0
  58. {geobox-1.1.1 → geobox-1.2.1}/tests/test_route.py +0 -0
  59. {geobox-1.1.1 → geobox-1.2.1}/tests/test_scene.py +0 -0
  60. {geobox-1.1.1 → geobox-1.2.1}/tests/test_settings.py +0 -0
  61. {geobox-1.1.1 → geobox-1.2.1}/tests/test_task.py +0 -0
  62. {geobox-1.1.1 → geobox-1.2.1}/tests/test_tile3d.py +0 -0
  63. {geobox-1.1.1 → geobox-1.2.1}/tests/test_tileset.py +0 -0
  64. {geobox-1.1.1 → geobox-1.2.1}/tests/test_usage.py +0 -0
  65. {geobox-1.1.1 → geobox-1.2.1}/tests/test_user.py +0 -0
  66. {geobox-1.1.1 → geobox-1.2.1}/tests/test_vectorlayer.py +0 -0
  67. {geobox-1.1.1 → geobox-1.2.1}/tests/test_version.py +0 -0
  68. {geobox-1.1.1 → geobox-1.2.1}/tests/test_view.py +0 -0
  69. {geobox-1.1.1 → geobox-1.2.1}/tests/test_workflow.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: geobox
3
- Version: 1.1.1
3
+ Version: 1.2.1
4
4
  Summary: SDK for Geobox's APIs
5
5
  Author-email: Hamid Heydari <heydari.h62@gmail.com>
6
6
  License: MIT
@@ -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 FileType, PublishFileType, InputGeomType
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
- FileType(os.path.splitext(path)[1])
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,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: geobox
3
- Version: 1.1.1
3
+ Version: 1.2.1
4
4
  Summary: SDK for Geobox's APIs
5
5
  Author-email: Hamid Heydari <heydari.h62@gmail.com>
6
6
  License: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "geobox"
7
- version = "1.1.1"
7
+ version = "1.2.1"
8
8
  description = "SDK for Geobox's APIs"
9
9
  authors = [
10
10
  {name = "Hamid Heydari", email = "heydari.h62@gmail.com"}
@@ -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 FileType"):
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("publish_type,geom_type", [
269
- (publish_type, geom_type)
270
- for publish_type in PublishFileType
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, publish_type, mock_success_task_data, geom_type):
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
- publish_as=publish_type,
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