voxcity 0.6.15__py3-none-any.whl → 0.7.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.
Files changed (78) hide show
  1. voxcity/__init__.py +14 -8
  2. voxcity/downloader/__init__.py +2 -1
  3. voxcity/downloader/citygml.py +32 -18
  4. voxcity/downloader/gba.py +210 -0
  5. voxcity/downloader/gee.py +5 -1
  6. voxcity/downloader/mbfp.py +1 -1
  7. voxcity/downloader/oemj.py +80 -8
  8. voxcity/downloader/osm.py +23 -7
  9. voxcity/downloader/overture.py +26 -1
  10. voxcity/downloader/utils.py +73 -73
  11. voxcity/errors.py +30 -0
  12. voxcity/exporter/__init__.py +13 -4
  13. voxcity/exporter/cityles.py +633 -535
  14. voxcity/exporter/envimet.py +728 -708
  15. voxcity/exporter/magicavoxel.py +334 -297
  16. voxcity/exporter/netcdf.py +238 -0
  17. voxcity/exporter/obj.py +1481 -655
  18. voxcity/generator/__init__.py +44 -0
  19. voxcity/generator/api.py +675 -0
  20. voxcity/generator/grids.py +379 -0
  21. voxcity/generator/io.py +94 -0
  22. voxcity/generator/pipeline.py +282 -0
  23. voxcity/generator/voxelizer.py +380 -0
  24. voxcity/geoprocessor/__init__.py +75 -6
  25. voxcity/geoprocessor/conversion.py +153 -0
  26. voxcity/geoprocessor/draw.py +62 -12
  27. voxcity/geoprocessor/heights.py +199 -0
  28. voxcity/geoprocessor/io.py +101 -0
  29. voxcity/geoprocessor/merge_utils.py +91 -0
  30. voxcity/geoprocessor/mesh.py +806 -790
  31. voxcity/geoprocessor/network.py +708 -679
  32. voxcity/geoprocessor/overlap.py +84 -0
  33. voxcity/geoprocessor/raster/__init__.py +82 -0
  34. voxcity/geoprocessor/raster/buildings.py +428 -0
  35. voxcity/geoprocessor/raster/canopy.py +258 -0
  36. voxcity/geoprocessor/raster/core.py +150 -0
  37. voxcity/geoprocessor/raster/export.py +93 -0
  38. voxcity/geoprocessor/raster/landcover.py +156 -0
  39. voxcity/geoprocessor/raster/raster.py +110 -0
  40. voxcity/geoprocessor/selection.py +85 -0
  41. voxcity/geoprocessor/utils.py +18 -14
  42. voxcity/models.py +113 -0
  43. voxcity/simulator/common/__init__.py +22 -0
  44. voxcity/simulator/common/geometry.py +98 -0
  45. voxcity/simulator/common/raytracing.py +450 -0
  46. voxcity/simulator/solar/__init__.py +43 -0
  47. voxcity/simulator/solar/integration.py +336 -0
  48. voxcity/simulator/solar/kernels.py +62 -0
  49. voxcity/simulator/solar/radiation.py +648 -0
  50. voxcity/simulator/solar/temporal.py +434 -0
  51. voxcity/simulator/view.py +36 -2286
  52. voxcity/simulator/visibility/__init__.py +29 -0
  53. voxcity/simulator/visibility/landmark.py +392 -0
  54. voxcity/simulator/visibility/view.py +508 -0
  55. voxcity/utils/logging.py +61 -0
  56. voxcity/utils/orientation.py +51 -0
  57. voxcity/utils/weather/__init__.py +26 -0
  58. voxcity/utils/weather/epw.py +146 -0
  59. voxcity/utils/weather/files.py +36 -0
  60. voxcity/utils/weather/onebuilding.py +486 -0
  61. voxcity/visualizer/__init__.py +24 -0
  62. voxcity/visualizer/builder.py +43 -0
  63. voxcity/visualizer/grids.py +141 -0
  64. voxcity/visualizer/maps.py +187 -0
  65. voxcity/visualizer/palette.py +228 -0
  66. voxcity/visualizer/renderer.py +928 -0
  67. {voxcity-0.6.15.dist-info → voxcity-0.7.0.dist-info}/METADATA +113 -36
  68. voxcity-0.7.0.dist-info/RECORD +77 -0
  69. {voxcity-0.6.15.dist-info → voxcity-0.7.0.dist-info}/WHEEL +1 -1
  70. voxcity/generator.py +0 -1137
  71. voxcity/geoprocessor/grid.py +0 -1568
  72. voxcity/geoprocessor/polygon.py +0 -1344
  73. voxcity/simulator/solar.py +0 -2329
  74. voxcity/utils/visualization.py +0 -2660
  75. voxcity/utils/weather.py +0 -817
  76. voxcity-0.6.15.dist-info/RECORD +0 -37
  77. {voxcity-0.6.15.dist-info → voxcity-0.7.0.dist-info/licenses}/AUTHORS.rst +0 -0
  78. {voxcity-0.6.15.dist-info → voxcity-0.7.0.dist-info/licenses}/LICENSE +0 -0
@@ -1,74 +1,74 @@
1
- # Utility functions for downloading files from various sources
2
- import requests
3
- import gdown
4
-
5
- def download_file(url, filename):
6
- """Download a file from a URL and save it locally.
7
-
8
- This function uses the requests library to download a file from any publicly
9
- accessible URL and save it to the local filesystem. It handles the download
10
- process and provides feedback on the operation's success or failure.
11
-
12
- Args:
13
- url (str): URL of the file to download. Must be a valid, accessible URL.
14
- filename (str): Local path where the downloaded file will be saved.
15
- Include the full path and filename with extension.
16
-
17
- Returns:
18
- None
19
-
20
- Prints:
21
- - Success message with filename if download is successful (status code 200)
22
- - Error message with status code if download fails
23
-
24
- Example:
25
- >>> download_file('https://example.com/file.pdf', 'local_file.pdf')
26
- File downloaded successfully and saved as local_file.pdf
27
- """
28
- # Attempt to download the file from the provided URL
29
- response = requests.get(url)
30
-
31
- # Check if the download was successful (HTTP status code 200)
32
- if response.status_code == 200:
33
- # Open the local file in binary write mode and save the content
34
- with open(filename, 'wb') as file:
35
- file.write(response.content)
36
- print(f"File downloaded successfully and saved as {filename}")
37
- else:
38
- print(f"Failed to download file. Status code: {response.status_code}")
39
-
40
- def download_file_google_drive(file_id, output_path):
41
- """Download a file from Google Drive using its file ID.
42
-
43
- This function specifically handles downloads from Google Drive using the gdown
44
- library, which is designed to bypass Google Drive's download restrictions.
45
- It's useful for downloading large files or files that require authentication.
46
-
47
- Args:
48
- file_id (str): Google Drive file ID. This is the unique identifier in the
49
- sharing URL after '/d/' or 'id='.
50
- output_path (str): Local path where the downloaded file will be saved.
51
- Include the full path and filename with extension.
52
-
53
- Returns:
54
- bool: True if download was successful, False if any error occurred
55
-
56
- Prints:
57
- Error message with exception details if download fails
58
-
59
- Example:
60
- >>> success = download_file_google_drive('1234abcd...', 'downloaded_file.zip')
61
- >>> if success:
62
- >>> print("Download completed successfully")
63
- """
64
- # Construct the direct download URL using the file ID
65
- url = f"https://drive.google.com/uc?id={file_id}"
66
-
67
- try:
68
- # Use gdown to handle the Google Drive download
69
- # quiet=False enables download progress display
70
- gdown.download(url, output_path, quiet=False)
71
- return True
72
- except Exception as e:
73
- print(f"Error downloading file {file_id}: {str(e)}")
1
+ # Utility functions for downloading files from various sources
2
+ import requests
3
+ import gdown
4
+
5
+ def download_file(url, filename):
6
+ """Download a file from a URL and save it locally.
7
+
8
+ This function uses the requests library to download a file from any publicly
9
+ accessible URL and save it to the local filesystem. It handles the download
10
+ process and provides feedback on the operation's success or failure.
11
+
12
+ Args:
13
+ url (str): URL of the file to download. Must be a valid, accessible URL.
14
+ filename (str): Local path where the downloaded file will be saved.
15
+ Include the full path and filename with extension.
16
+
17
+ Returns:
18
+ None
19
+
20
+ Prints:
21
+ - Success message with filename if download is successful (status code 200)
22
+ - Error message with status code if download fails
23
+
24
+ Example:
25
+ >>> download_file('https://example.com/file.pdf', 'local_file.pdf')
26
+ File downloaded successfully and saved as local_file.pdf
27
+ """
28
+ # Attempt to download the file from the provided URL
29
+ response = requests.get(url)
30
+
31
+ # Check if the download was successful (HTTP status code 200)
32
+ if response.status_code == 200:
33
+ # Open the local file in binary write mode and save the content
34
+ with open(filename, 'wb') as file:
35
+ file.write(response.content)
36
+ print(f"File downloaded successfully and saved as {filename}")
37
+ else:
38
+ print(f"Failed to download file. Status code: {response.status_code}")
39
+
40
+ def download_file_google_drive(file_id, output_path):
41
+ """Download a file from Google Drive using its file ID.
42
+
43
+ This function specifically handles downloads from Google Drive using the gdown
44
+ library, which is designed to bypass Google Drive's download restrictions.
45
+ It's useful for downloading large files or files that require authentication.
46
+
47
+ Args:
48
+ file_id (str): Google Drive file ID. This is the unique identifier in the
49
+ sharing URL after '/d/' or 'id='.
50
+ output_path (str): Local path where the downloaded file will be saved.
51
+ Include the full path and filename with extension.
52
+
53
+ Returns:
54
+ bool: True if download was successful, False if any error occurred
55
+
56
+ Prints:
57
+ Error message with exception details if download fails
58
+
59
+ Example:
60
+ >>> success = download_file_google_drive('1234abcd...', 'downloaded_file.zip')
61
+ >>> if success:
62
+ >>> print("Download completed successfully")
63
+ """
64
+ # Construct the direct download URL using the file ID
65
+ url = f"https://drive.google.com/uc?id={file_id}"
66
+
67
+ try:
68
+ # Use gdown to handle the Google Drive download
69
+ # quiet=False enables download progress display
70
+ gdown.download(url, output_path, quiet=False)
71
+ return True
72
+ except Exception as e:
73
+ print(f"Error downloading file {file_id}: {str(e)}")
74
74
  return False
voxcity/errors.py ADDED
@@ -0,0 +1,30 @@
1
+ """
2
+ Package-specific error hierarchy for voxcity.
3
+
4
+ This enables precise exception handling without leaking low-level
5
+ implementation details across boundaries.
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+
11
+ class VoxCityError(Exception):
12
+ """Base exception for all voxcity errors."""
13
+
14
+
15
+ class ConfigurationError(VoxCityError):
16
+ """Raised when configuration values are missing or invalid."""
17
+
18
+
19
+ class DownloaderError(VoxCityError):
20
+ """Raised by downloader modules when remote data retrieval fails."""
21
+
22
+
23
+ class ProcessingError(VoxCityError):
24
+ """Raised for failures during grid/voxel processing or geoprocessing."""
25
+
26
+
27
+ class VisualizationError(VoxCityError):
28
+ """Raised for visualization/rendering failures."""
29
+
30
+
@@ -1,4 +1,13 @@
1
- from .envimet import *
2
- from .magicavoxel import *
3
- from .obj import *
4
- from .cityles import *
1
+ from typing import Protocol, runtime_checkable
2
+
3
+ from .envimet import *
4
+ from .magicavoxel import *
5
+ from .obj import *
6
+ from .cityles import *
7
+ from .netcdf import *
8
+
9
+
10
+ @runtime_checkable
11
+ class Exporter(Protocol):
12
+ def export(self, obj, output_directory: str, base_filename: str): # pragma: no cover - protocol
13
+ ...