@@ -237,31 +237,35 @@ def get_image_metadata(
237237):
238238 aoi_polygon = geojson_to_polygon (aoi_geojson )
239239 downloaded_metadata = coordinate_download (aoi_polygon , level , attempt_limit )
240- if downloaded_metadata .isna ().all ().all () or downloaded_metadata .empty :
240+
241+ if downloaded_metadata .empty or downloaded_metadata .isna ().all ().all ():
241242 raise ValueError ("No Mapillary Features in the AoI." )
243+
242244 downloaded_metadata = downloaded_metadata [
243245 downloaded_metadata ["geometry" ].apply (lambda geom : isinstance (geom , Point ))
244246 ]
245247
246- downloaded_metadata = filter_results (
248+ filtered_metadata = filter_results (
247249 downloaded_metadata , creator_id , is_pano , organization_id , start_time , end_time
248250 )
249- if sampling_threshold is not None :
250- downloaded_metadata = spatial_sampling (downloaded_metadata , sampling_threshold )
251+
251252 if (
252- downloaded_metadata .isna ().all ().all () is False
253- or downloaded_metadata .empty is False
253+ filtered_metadata is None
254+ or filtered_metadata .empty
255+ or filtered_metadata .isna ().all ().all ()
254256 ):
255- if len (downloaded_metadata ) > 100000 :
256- err = (
257- f"Too many Images with selected filter "
258- f"options for the AoI: { len (downloaded_metadata )} "
259- )
260- raise ValueError (err )
261- else :
262- return {
263- "ids" : downloaded_metadata ["id" ].tolist (),
264- "geometries" : downloaded_metadata ["geometry" ].tolist (),
265- }
266- else :
267257 raise ValueError ("No Mapillary Features in the AoI match the filter criteria." )
258+
259+ if sampling_threshold is not None :
260+ filtered_metadata = spatial_sampling (filtered_metadata , sampling_threshold )
261+
262+ total_images = len (filtered_metadata )
263+ if total_images > 100000 :
264+ raise ValueError (
265+ f"Too many Images with selected filter options for the AoI: { total_images } "
266+ )
267+
268+ return {
269+ "ids" : filtered_metadata ["id" ].tolist (),
270+ "geometries" : filtered_metadata ["geometry" ].tolist (),
271+ }
0 commit comments