Skip to content

Commit c3dca08

Browse files
committed
fix(street): get_image_metadata() error handling
1 parent 508edf8 commit c3dca08

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

mapswipe_workers/mapswipe_workers/utils/process_mapillary.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,12 @@
1616
from shapely.geometry import shape
1717
from vt2geojson import tools as vt2geojson_tools
1818

19-
from mapswipe_workers.definitions import MAPILLARY_API_KEY, MAPILLARY_API_LINK, logger
19+
from mapswipe_workers.definitions import (
20+
MAPILLARY_API_KEY,
21+
MAPILLARY_API_LINK,
22+
CustomError,
23+
logger,
24+
)
2025
from mapswipe_workers.utils.spatial_sampling import spatial_sampling
2126

2227

@@ -239,7 +244,7 @@ def get_image_metadata(
239244
downloaded_metadata = coordinate_download(aoi_polygon, level, attempt_limit)
240245

241246
if downloaded_metadata.empty or downloaded_metadata.isna().all().all():
242-
raise ValueError("No Mapillary Features in the AoI.")
247+
raise CustomError("No Mapillary Features in the AoI.")
243248

244249
downloaded_metadata = downloaded_metadata[
245250
downloaded_metadata["geometry"].apply(lambda geom: isinstance(geom, Point))
@@ -254,14 +259,14 @@ def get_image_metadata(
254259
or filtered_metadata.empty
255260
or filtered_metadata.isna().all().all()
256261
):
257-
raise ValueError("No Mapillary Features in the AoI match the filter criteria.")
262+
raise CustomError("No Mapillary Features in the AoI match the filter criteria.")
258263

259264
if sampling_threshold is not None:
260265
filtered_metadata = spatial_sampling(filtered_metadata, sampling_threshold)
261266

262267
total_images = len(filtered_metadata)
263268
if total_images > 100000:
264-
raise ValueError(
269+
raise CustomError(
265270
f"Too many Images with selected filter options for the AoI: {total_images}"
266271
)
267272

0 commit comments

Comments
 (0)