[GRASS-SVN] r43466 - grass-addons/imagery/i.landsat.acca

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Sep 14 19:50:07 EDT 2010


Author: hamish
Date: 2010-09-14 23:50:07 +0000 (Tue, 14 Sep 2010)
New Revision: 43466

Modified:
   grass-addons/imagery/i.landsat.acca/algorithm.c
   grass-addons/imagery/i.landsat.acca/main.c
   grass-addons/imagery/i.landsat.acca/tools.c
Log:
standardized messages for i18n

Modified: grass-addons/imagery/i.landsat.acca/algorithm.c
===================================================================
--- grass-addons/imagery/i.landsat.acca/algorithm.c	2010-09-14 22:16:33 UTC (rev 43465)
+++ grass-addons/imagery/i.landsat.acca/algorithm.c	2010-09-14 23:50:07 UTC (rev 43466)
@@ -166,7 +166,7 @@
 	fprintf(stdout, "      Skewness:           %.2lf\n", value[SKEW]);
 	fprintf(stdout, "      97.50 percentile:   %.2lf K\n", value[KUPPER]);
 	fprintf(stdout, "      83.50 percentile:   %.2lf K\n", value[KLOWER]);
-	//         fprintf(stdout, "      50.00 percentile:   %.2lf K\n", quantile(0.5,hist_cold) + K_BASE);
+	/* fprintf(stdout, "      50.00 percentile:   %.2lf K\n", quantile(0.5,hist_cold) + K_BASE); */
     }
     else {
 	if (signa[KMEAN] < 295.) {
@@ -212,10 +212,10 @@
     /* Creation of output file */
     out->rast = G_allocate_raster_buf(CELL_TYPE);
     if ((out->fd = G_open_raster_new(out->name, CELL_TYPE)) < 0)
-	G_fatal_error(_("Could not open <%s>"), out->name);
+	G_fatal_error(_("Unable to create raster map <%s>"), out->name);
 
     /* ----- ----- */
-    fprintf(stdout, "Pass one processing ... \n");
+    G_message(_("Pass one processing ..."));
 
     stats[SUM_COLD] = 0.;
     stats[SUM_WARM] = 0.;
@@ -226,13 +226,11 @@
     ncols = G_window_cols();
 
     for (row = 0; row < nrows; row++) {
-	if (verbose) {
-	    G_percent(row, nrows, 2);
-	}
+
 	for (i = BAND2; i <= BAND6; i++) {
 	    if (G_get_d_raster_row(band[i].fd, band[i].rast, row) < 0)
-		G_fatal_error(_("Could not read row from <%s>"),
-			      band[i].name);
+		G_fatal_error(_("Unable to read raster map <%s> row %d"),
+			      band[i].name, row);
 	}
 	for (col = 0; col < ncols; col++) {
 	    code = NO_DEFINED;
@@ -328,9 +326,11 @@
 		((CELL *) out->rast)[col] = code;
 	    }
 	}
-	if (G_put_raster_row(out->fd, out->rast, CELL_TYPE) < 0) {
-	    G_fatal_error(_("Cannot write row to <%s>"), out->name);
-	}
+
+	if (G_put_raster_row(out->fd, out->rast, CELL_TYPE) < 0)
+	    G_fatal_error(_("Failed writing raster map <%s> row %d"), out->name, row);
+
+	G_percent(row, nrows, 2);
     }
     /* ----- ----- */
 
@@ -354,21 +354,21 @@
     /* Open to read */
     mapset = G_find_cell2(out->name, "");
     if (mapset == NULL)
-	G_fatal_error("cell file [%s] not found", out->name);
+	G_fatal_error(_("Raster map <%s> not found"), out->name);
     out->rast = G_allocate_raster_buf(CELL_TYPE);
     if ((out->fd = G_open_cell_old(out->name, mapset)) < 0)
-	G_fatal_error("Cannot open cell file [%s]", out->name);
+	G_fatal_error(_("Unable to open raster map <%s>"), out->name);
 
     /* Open to write */
     sprintf(tmp.name, "_%d.BBB", getpid());
     tmp.rast = G_allocate_raster_buf(CELL_TYPE);
     if ((tmp.fd = G_open_raster_new(tmp.name, CELL_TYPE)) < 0)
-	G_fatal_error(_("Could not open <%s>"), tmp.name);
+	G_fatal_error(_("Unable to create raster map <%s>"), tmp.name);
 
     if (upper == 0.)
-	fprintf(stdout, "Removing ambiguous pixels ... \n");
+	G_message(_("Removing ambiguous pixels ..."));
     else
-	fprintf(stdout, "Pass two processing ... \n");
+	G_message(_("Pass two processing ..."));
 
     nrows = G_window_rows();
     ncols = G_window_cols();
@@ -378,9 +378,9 @@
 	    G_percent(row, nrows, 2);
 	}
 	if (G_get_d_raster_row(band.fd, band.rast, row) < 0)
-	    G_fatal_error(_("Could not read from <%s>"), band.name);
+	    G_fatal_error(_("Unable to read raster map <%s> row %d"), band.name, row);
 	if (G_get_c_raster_row(out->fd, out->rast, row) < 0)
-	    G_fatal_error(_("Could not read from <%s>"), out->name);
+	    G_fatal_error(_("Unable to read raster map <%s> row %d"), out->name, row);
 
 	for (col = 0; col < ncols; col++) {
 	    if (G_is_c_null_value((void *)((CELL *) out->rast + col))) {

Modified: grass-addons/imagery/i.landsat.acca/main.c
===================================================================
--- grass-addons/imagery/i.landsat.acca/main.c	2010-09-14 22:16:33 UTC (rev 43465)
+++ grass-addons/imagery/i.landsat.acca/main.c	2010-09-14 23:50:07 UTC (rev 43466)
@@ -55,27 +55,27 @@
 
     mapset = G_find_cell2(raster_name, "");
     if (mapset == NULL) {
-	G_message("cell file [%s] not found", raster_name);
+	G_warning(_("Raster map <%s> not found"), raster_name);
 	return -1;
     }
     if (G_legal_filename(raster_name) < 0) {
-	G_message("[%s] is an illegal name", raster_name);
+	G_warning(_("<%s> is an illegal file name"), raster_name);
 	return -1;
     }
     if ((raster_fd = G_open_cell_old(raster_name, mapset)) < 0) {
-	G_message("Cannot open cell file [%s]", raster_name);
+	G_warning(_("Unable to open raster map <%s>"), raster_name);
 	return -1;
     }
     if (G_get_cellhd(raster_name, mapset, &cellhd) < 0) {
-	G_message("Cannot read file header of [%s]", raster_name);
+	G_warning(_("Unable to read header of raster map <%s>"), raster_name);
 	return -1;
     }
     if (G_set_window(&cellhd) < 0) {
-	G_message("Unable to set region");
+	G_warning(_("Cannot reset current region"));
 	return -1;
     }
     if ((map_type = G_raster_map_type(raster_name, mapset)) != DCELL_TYPE) {
-	G_message("Map is not of DCELL_TYPE");
+	G_warning(_("Map is not DCELL type (process DN to radiance first)"));
 	return -1;
     }
     return raster_fd;
@@ -160,7 +160,7 @@
 	snprintf(band[i].name, 127, "%s.%d%c", in_name, i + 2,
 		 (i == BAND6 && !sat5->answer ? '1' : '\0'));
 	if ((band[i].fd = check_raster(band[i].name)) < 0) {
-	    G_fatal_error(_("Error in filename [%s]!"), band[i].name);
+	    G_fatal_error(_("Error in map name <%s>!"), band[i].name);
 	}
 	band[i].rast = G_allocate_raster_buf(DCELL_TYPE);
     }
@@ -169,7 +169,7 @@
 
     snprintf(out.name, 127, "%s", out_name);
     if (G_legal_filename(out_name) < 0)
-	G_fatal_error(_("<%s> is an illegal map name"), out.name);
+	G_fatal_error(_("<%s> is an illegal file name"), out.name);
 
     /* --------------------------------------- */
 

Modified: grass-addons/imagery/i.landsat.acca/tools.c
===================================================================
--- grass-addons/imagery/i.landsat.acca/tools.c	2010-09-14 22:16:33 UTC (rev 43465)
+++ grass-addons/imagery/i.landsat.acca/tools.c	2010-09-14 23:50:07 UTC (rev 43466)
@@ -146,37 +146,38 @@
     /* Open to read */
     mapset = G_find_cell2(out->name, "");
     if (mapset == NULL)
-	G_fatal_error("cell file [%s] not found", out->name);
+	G_fatal_error(_("Raster map <%s> not found"), out->name);
+
     arast = G_allocate_raster_buf(CELL_TYPE);
     brast = G_allocate_raster_buf(CELL_TYPE);
     crast = G_allocate_raster_buf(CELL_TYPE);
+
     if ((out->fd = G_open_cell_old(out->name, mapset)) < 0)
-	G_fatal_error("Cannot open cell file [%s]", out->name);
+	G_fatal_error(_("Unable to open raster map <%s>"), out->name);
 
     /* Open to write */
     sprintf(tmp.name, "_%d.BBB", getpid());
     tmp.rast = G_allocate_raster_buf(CELL_TYPE);
+
     if ((tmp.fd = G_open_raster_new(tmp.name, CELL_TYPE)) < 0)
-	G_fatal_error(_("Could not open <%s>"), tmp.name);
+	G_fatal_error(_("Unable to create raster map <%s>"), tmp.name);
 
-    fprintf(stdout, "Filling cloud holes ... \n");
+    G_message(_("Filling small holes in clouds ..."));
 
 
     for (row = 0; row < nrows; row++) {
-	if (verbose) {
-	    G_percent(row, nrows, 2);
-	}
+
 	/* Read row values */
 	if (row != 0) {
 	    if (G_get_c_raster_row(out->fd, arast, row - 1) < 0)
-		G_fatal_error(_("Could not read from <%s>"), out->name);
+		G_fatal_error(_("Unable to read raster map <%s> row %d"), out->name, row - 1);
 	}
 	if (G_get_c_raster_row(out->fd, brast, row) < 0) {
-	    G_fatal_error(_("Could not read from <%s>"), out->name);
+	    G_fatal_error(_("Unable to read raster map <%s> row %d"), out->name, row);
 	}
 	if (row != (nrows - 1)) {
 	    if (G_get_c_raster_row(out->fd, crast, row + 1) < 0)
-		G_fatal_error(_("Could not read from <%s>"), out->name);
+		G_fatal_error(_("Unable to read raster map <%s> row %d"), out->name, row + 1);
 	}
 	/* Analysis of all pixels */
 	for (col = 0; col < ncols; col++) {
@@ -267,14 +268,16 @@
 		    }
 		}
 
-		//                 pixel[1] = (row == 0 || col == 0)                 ? -1 : pval(arast, col - 1);
-		//                 pixel[2] = (row == 0)                             ? -1 : pval(arast, col);
-		//                 pixel[3] = (row == 0 || col == (ncols-1))         ? -1 : pval(arast, col + 1);
-		//                 pixel[4] = (col == 0)                             ? -1 : pval(brast, col - 1);
-		//                 pixel[5] = (col == (ncols-1))                     ? -1 : pval(brast, col + 1);
-		//                 pixel[6] = (row == (nrows-1) || col == 0)         ? -1 : pval(crast, col - 1);
-		//                 pixel[7] = (row == (nrows-1))                     ? -1 : pval(crast, col);
-		//                 pixel[8] = (row == (nrows-1) || col == (ncols-1)) ? -1 : pval(crast, col + 1);
+		/*
+		pixel[1] = (row == 0 || col == 0)                 ? -1 : pval(arast, col - 1);
+		pixel[2] = (row == 0)                             ? -1 : pval(arast, col);
+		pixel[3] = (row == 0 || col == (ncols-1))	  ? -1 : pval(arast, col + 1);
+		pixel[4] = (col == 0)				  ? -1 : pval(brast, col - 1);
+		pixel[5] = (col == (ncols-1))			  ? -1 : pval(brast, col + 1);
+		pixel[6] = (row == (nrows-1) || col == 0)	  ? -1 : pval(crast, col - 1);
+		pixel[7] = (row == (nrows-1))			  ? -1 : pval(crast, col);
+		pixel[8] = (row == (nrows-1) || col == (ncols-1)) ? -1 : pval(crast, col + 1);
+		*/
 
 		cold = warm = shadow = nulo = 0;
 		for (i = 1; i < 9; i++) {
@@ -311,9 +314,11 @@
 		G_set_c_null_value((CELL *) tmp.rast + col, 1);
 	    }
 	}
-	if (G_put_raster_row(tmp.fd, tmp.rast, CELL_TYPE) < 0) {
-	    G_fatal_error(_("Cannot write to <%s>"), tmp.name);
-	}
+
+	if (G_put_raster_row(tmp.fd, tmp.rast, CELL_TYPE) < 0)
+	    G_fatal_error(_("Failed writing raster map <%s> row %d"), tmp.name, row);
+
+	G_percent(row, nrows, 2);
     }
 
     G_free(arast);



More information about the grass-commit mailing list