@@ -86,6 +86,46 @@ def _get_native_ellipsoid(self, epsg, ref_type):
8686 return WGS84_EPSG # Default
8787
8888 def fetch_grid (self , module_name , ** kwargs ):
89+ """Generic fetcher wrapper using the new fetchez API."""
90+
91+ files = fetchez .get (
92+ module = module_name ,
93+ region = self .region .to_list (),
94+ outdir = self .cache_dir ,
95+ threads = 2 ,
96+ ** kwargs
97+ )
98+
99+ valid = []
100+
101+ for fn in files :
102+ if not os .path .exists (fn ):
103+ continue
104+
105+ if fn .endswith ('.zip' ):
106+ datatype = kwargs .get ('datatype' )
107+ fns_to_extract = [datatype ] if datatype else None
108+ extracted = fetchez .utils .p_f_unzip (fn , fns = fns_to_extract , outdir = self .cache_dir )
109+ valid .extend ([f for f in extracted if f .endswith (('.gtx' , '.tif' , '.grd' , '.nc' ))])
110+
111+ elif fn .endswith ('.gz' ):
112+ try :
113+ out_fn = os .path .splitext (fn )[0 ]
114+ if not os .path .exists (out_fn ):
115+ logger .info (f"Decompressing { fn } ..." )
116+ with gzip .open (fn , 'rb' ) as f_in :
117+ with open (out_fn , 'wb' ) as f_out :
118+ shutil .copyfileobj (f_in , f_out )
119+ valid .append (out_fn )
120+ except Exception as e :
121+ logger .error (f"Failed to decompress { fn } : { e } " )
122+
123+ elif fn .endswith (('.gtx' , '.tif' , '.grd' , '.nc' , '.mss' )):
124+ valid .append (fn )
125+
126+ return valid
127+
128+ def fetch_grid_ (self , module_name , ** kwargs ):
89129 """Generic fetcher wrapper."""
90130
91131 Mod = fetchez .registry .FetchezRegistry .load_module (module_name )
0 commit comments