File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -595,3 +595,24 @@ def test_constellations():
595595
596596def test_regex_glob ():
597597 ci .assert_val (convert_glob_to_regex ("**/*_rgb.png" ), r".*/.*_rgb\.png" , "ASF regex" )
598+
599+
600+ def test_filename_window ():
601+ prod_path = opt_path ().joinpath ("LT05_L1TP_200030_20111110_20200820_02_T1" )
602+ window_path = others_path ().joinpath (
603+ "20201220T104856_L8_200030_OLI_TIRS_window.geojson"
604+ )
605+ prod = READER .open (prod_path , remove_tmp = True )
606+ extent = prod .extent ()
607+ ci .assert_val (
608+ prod .get_band_file_name ("RED" , pixel_size = 20 , window = extent ),
609+ prod .get_band_file_name ("RED" , pixel_size = 20 ),
610+ "Extent window" ,
611+ )
612+
613+ with pytest .raises (AssertionError ):
614+ ci .assert_val (
615+ prod .get_band_file_name ("RED" , pixel_size = 20 , window = window_path ),
616+ prod .get_band_file_name ("RED" , pixel_size = 20 ),
617+ "Small window" ,
618+ )
Original file line number Diff line number Diff line change @@ -141,7 +141,7 @@ def __init__(
141141 ** kwargs ,
142142 ) -> None :
143143 self .needs_extraction = True
144- """Does this product needs to be extracted to be processed ? (:code:`True` by default)."""
144+ """Does this product needs to be extracted to be processed? (:code:`True` by default)."""
145145
146146 self .path = AnyPath (product_path )
147147 if (
@@ -833,9 +833,14 @@ def get_band_file_name(
833833
834834 # Window
835835 window = kwargs .get ("window" )
836- win_suffix = ""
836+ max_extent = None
837837 if window is not None :
838- win_suffix = f"_{ utils .get_window_suffix (window , max_extent = self .extent ())} "
838+ # This way we can avoid RecursionError when computing extents (which doesn't have a window)
839+ max_extent = self .extent ()
840+
841+ win_suffix = utils .get_window_suffix (window , max_extent = max_extent )
842+ if win_suffix :
843+ win_suffix = f"_{ win_suffix } "
839844
840845 # Specific if needed
841846 if dem_name :
You can’t perform that action at this time.
0 commit comments