@@ -79,13 +79,17 @@ def fetch(
79
79
self ,
80
80
bbox : List ,
81
81
zoom : int = None ,
82
- progress_bar = False ,
83
82
timeout = 10 ,
84
83
cache_path = "./cache" ,
85
84
keep_cache = True ,
86
85
coord = "xy" ,
87
86
multiproc = 4 ,
87
+ quiet = False ,
88
88
) -> tuple :
89
+ if quiet :
90
+ progress_bar = False
91
+ else :
92
+ progress_bar = True
89
93
90
94
left , upper , right , lower = bbox
91
95
if zoom is None :
@@ -149,18 +153,20 @@ def fetch(
149
153
if not os .path .exists (tmpfp ):
150
154
task_args .append ([url , tmpfp , timeout ])
151
155
152
- with Pool (multiproc ) as p :
153
- result = list (
154
- tqdm (
155
- p .imap_unordered (single_download , task_args ),
156
- total = len (task_args ),
157
- desc = "downloading" ,
158
- ),
159
- )
160
- try :
161
- assert all (result )
162
- except AssertionError :
163
- raise Exception ("Not download completely, please retry" )
156
+ if task_args :
157
+ with Pool (multiproc ) as p :
158
+ result = list (
159
+ tqdm (
160
+ p .imap_unordered (single_download , task_args ),
161
+ total = len (task_args ),
162
+ desc = "downloading" ,
163
+ ),
164
+ )
165
+
166
+ try :
167
+ assert all (result )
168
+ except AssertionError :
169
+ raise Exception ("Not download completely, please retry" )
164
170
165
171
for (nx , ny ), (x , y ), url in tqdm (
166
172
urls , disable = not progress_bar , desc = "mosaicing"
@@ -176,11 +182,12 @@ def fetch(
176
182
blue = canvas [..., 2 ]
177
183
elevation = ((red * 256 + green + blue / 256 ) - 32768 ).astype (int )[idx ]
178
184
179
- print (f"bbox: { bbox } " )
180
- print (f"zoom: { zoom } " )
181
- print (f"mean of elevation: { int (elevation .mean ())} " )
182
- print (f"max of elevation: { elevation .max ()} " )
183
- print (f"min of elevation: { elevation .min ()} " )
185
+ if not quiet :
186
+ print (f"bbox: { bbox } " )
187
+ print (f"zoom: { zoom } " )
188
+ print (f"mean of elevation: { int (elevation .mean ())} " )
189
+ print (f"max of elevation: { elevation .max ()} " )
190
+ print (f"min of elevation: { elevation .min ()} " )
184
191
185
192
if not keep_cache :
186
193
shutil .rmtree (cache_path )
0 commit comments