1616from shapely .geometry import shape
1717from 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+ )
2025from 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