voxcity 0.6.19__py3-none-any.whl → 0.6.21__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.

Potentially problematic release.


This version of voxcity might be problematic. Click here for more details.

@@ -156,13 +156,16 @@ def get_tile_polygon_from_filename(filename):
156
156
  # Original script logic
157
157
  # --------------------------------------------------------------------
158
158
 
159
- def download_and_extract_zip(url, extract_to='.'):
159
+ def download_and_extract_zip(url, extract_to='.', ssl_verify=True, ca_bundle=None, timeout=60):
160
160
  """
161
161
  Download and extract a zip file from a URL to specified directory.
162
162
 
163
163
  Args:
164
164
  url (str): URL of the zip file to download.
165
165
  extract_to (str): Directory to extract files to (default: current directory).
166
+ ssl_verify (bool): Whether to verify SSL certificates (default: True).
167
+ ca_bundle (str|None): Path to a CA bundle file. Overrides verify when provided.
168
+ timeout (int|float): Request timeout in seconds (default: 60).
166
169
 
167
170
  Returns:
168
171
  tuple: (extraction_path, folder_name) where files were extracted.
@@ -171,21 +174,27 @@ def download_and_extract_zip(url, extract_to='.'):
171
174
  - Creates a subdirectory named after the zip file (without .zip)
172
175
  - Prints status messages for success/failure
173
176
  """
174
- response = requests.get(url)
175
- if response.status_code == 200:
176
- parsed_url = urlparse(url)
177
- zip_filename = os.path.basename(parsed_url.path)
178
- folder_name = os.path.splitext(zip_filename)[0] # Remove the .zip extension
179
-
180
- extraction_path = os.path.join(extract_to, folder_name)
181
- os.makedirs(extraction_path, exist_ok=True)
182
-
183
- zip_file = io.BytesIO(response.content)
184
- with zipfile.ZipFile(zip_file) as z:
185
- z.extractall(extraction_path)
186
- print(f"Extracted to {extraction_path}")
187
- else:
188
- print(f"Failed to download the file. Status code: {response.status_code}")
177
+ verify_arg = ca_bundle if ca_bundle else ssl_verify
178
+ try:
179
+ response = requests.get(url, verify=verify_arg, timeout=timeout)
180
+ if response.status_code == 200:
181
+ parsed_url = urlparse(url)
182
+ zip_filename = os.path.basename(parsed_url.path)
183
+ folder_name = os.path.splitext(zip_filename)[0] # Remove the .zip extension
184
+
185
+ extraction_path = os.path.join(extract_to, folder_name)
186
+ os.makedirs(extraction_path, exist_ok=True)
187
+
188
+ zip_file = io.BytesIO(response.content)
189
+ with zipfile.ZipFile(zip_file) as z:
190
+ z.extractall(extraction_path)
191
+ print(f"Extracted to {extraction_path}")
192
+ else:
193
+ print(f"Failed to download the file. Status code: {response.status_code}")
194
+ except requests.exceptions.SSLError as e:
195
+ print("SSL error when downloading CityGML zip. You can pass 'ssl_verify=False' to skip verification, "
196
+ "or provide a CA bundle path via 'ca_bundle'. Error:", e)
197
+ raise
189
198
 
190
199
  return extraction_path, folder_name
191
200
 
@@ -848,7 +857,10 @@ def swap_coordinates_if_needed(gdf, geometry_col='geometry'):
848
857
  def load_buid_dem_veg_from_citygml(url=None,
849
858
  base_dir='.',
850
859
  citygml_path=None,
851
- rectangle_vertices=None):
860
+ rectangle_vertices=None,
861
+ ssl_verify=True,
862
+ ca_bundle=None,
863
+ timeout=60):
852
864
  """
853
865
  Load and process PLATEAU data from URL or local files.
854
866
 
@@ -879,7 +891,9 @@ def load_buid_dem_veg_from_citygml(url=None,
879
891
  rectangle_polygon = Polygon(rectangle_vertices)
880
892
 
881
893
  if url:
882
- citygml_path, foldername = download_and_extract_zip(url, extract_to=base_dir)
894
+ citygml_path, foldername = download_and_extract_zip(
895
+ url, extract_to=base_dir, ssl_verify=ssl_verify, ca_bundle=ca_bundle, timeout=timeout
896
+ )
883
897
  elif citygml_path:
884
898
  foldername = os.path.basename(citygml_path)
885
899
  else: