Sfoglia il codice sorgente

r.resamp.rst: fix https://trac.osgeo.org/grass/ticket/1718

git-svn-id: https://svn.osgeo.org/grass/grass/branches/releasebranch_7_0@59740 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Metz 11 anni fa
parent
commit
897dae33b8
1 ha cambiato i file con 8 aggiunte e 4 eliminazioni
  1. 8 4
      raster/r.resamp.rst/main.c

+ 8 - 4
raster/r.resamp.rst/main.c

@@ -367,8 +367,6 @@ int main(int argc, char *argv[])
 
     if (smooth != NULL) {
 
-	fdsmooth = Rast_open_old(smooth, "");
-
 	Rast_get_cellhd(smooth, "", &smhd);
 
 	if ((winhd.ew_res != smhd.ew_res) || (winhd.ns_res != smhd.ns_res))
@@ -388,8 +386,6 @@ int main(int argc, char *argv[])
     if ((winhd.ew_res != inphd.ew_res) || (winhd.ns_res != inphd.ns_res))
 	G_fatal_error(_("Input map resolution differs from current region resolution!"));
 
-    fdinp = Rast_open_old(input, "");
-
     sdisk = 0;
     if (elev != NULL)
 	sdisk += disk;
@@ -439,12 +435,16 @@ int main(int argc, char *argv[])
 	Rast_get_fp_range_min_max(&range, &cellmin, &cellmax);
     }
     else {
+	fdinp = Rast_open_old(input, "");
+
 	cellrow = Rast_allocate_f_buf();
 	for (m1 = 0; m1 < inp_rows; m1++) {
 	    Rast_get_f_row(fdinp, cellrow, m1);
 	    Rast_row_update_fp_range(cellrow, m1, &range, FCELL_TYPE);
 	}
 	Rast_get_fp_range_min_max(&range, &cellmin, &cellmax);
+
+	Rast_close(fdinp);
     }
 
     fcellmin = (float)cellmin;
@@ -485,6 +485,10 @@ int main(int argc, char *argv[])
     G_message(_("Changing back to the original region ..."));
     Rast_set_window(&winhd);
 
+    fdinp = Rast_open_old(input, "");
+    if (smooth != NULL)
+	fdsmooth = Rast_open_old(smooth, "");
+
     ertot = 0.;
     cursegm = 0;
     G_message(_("Percent complete: "));