[GRASS-SVN] r33218 - grass/branches/develbranch_6/imagery/i.atcorr

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Sep 2 07:15:30 EDT 2008


Author: martinl
Date: 2008-09-02 07:15:29 -0400 (Tue, 02 Sep 2008)
New Revision: 33218

Modified:
   grass/branches/develbranch_6/imagery/i.atcorr/6s.cpp
   grass/branches/develbranch_6/imagery/i.atcorr/AerosolModel.cpp
   grass/branches/develbranch_6/imagery/i.atcorr/AtmosModel.cpp
   grass/branches/develbranch_6/imagery/i.atcorr/GeomCond.cpp
   grass/branches/develbranch_6/imagery/i.atcorr/Iwave.cpp
   grass/branches/develbranch_6/imagery/i.atcorr/computations.cpp
   grass/branches/develbranch_6/imagery/i.atcorr/main.cpp
Log:
i.atcorr: use G_warning()/G_fatal_error() instead of fprintf(stderr, ...)
	message standardization
	more guisections


Modified: grass/branches/develbranch_6/imagery/i.atcorr/6s.cpp
===================================================================
--- grass/branches/develbranch_6/imagery/i.atcorr/6s.cpp	2008-09-02 10:28:01 UTC (rev 33217)
+++ grass/branches/develbranch_6/imagery/i.atcorr/6s.cpp	2008-09-02 11:15:29 UTC (rev 33218)
@@ -1,4 +1,10 @@
 #include <cstring>
+
+extern "C" {
+#include <grass/gis.h>
+#include <grass/glocale.h>
+}
+
 #include "6s.h"
 #include "common.h"
 #include "GeomCond.h"
@@ -42,7 +48,7 @@
     ifstream inText;
     inText.open(icnd_name);
     if(!inText.is_open()) {
-        fprintf(stderr, "Unable to open %s\n", icnd_name);
+	G_warning(_("Unable to open file <%s>"), icnd_name);
 	return -1;
     }
 

Modified: grass/branches/develbranch_6/imagery/i.atcorr/AerosolModel.cpp
===================================================================
--- grass/branches/develbranch_6/imagery/i.atcorr/AerosolModel.cpp	2008-09-02 10:28:01 UTC (rev 33217)
+++ grass/branches/develbranch_6/imagery/i.atcorr/AerosolModel.cpp	2008-09-02 11:15:29 UTC (rev 33218)
@@ -1,3 +1,8 @@
+extern "C" {
+#include <grass/gis.h>
+#include <grass/glocale.h>
+}
+
 #include "common.h"
 #include "AerosolModel.h"
 #include "AtmosModel.h"
@@ -857,8 +862,7 @@
 	cin.ignore(numeric_limits<int>::max(),'\n');
 
 	if(mie_in.icp >= 4) {
-	    fprintf(stderr, "mie_in.icp: %ld > 4, will cause internal buffer overflow.\n", mie_in.icp);
-	    exit(-1);
+	    G_fatal_error(_("mie_in.icp: %ld > 4, will cause internal buffer overflow"), mie_in.icp);
 	}
 
 	for(int i = 0; i < mie_in.icp; i++)
@@ -922,8 +926,7 @@
 	cin.ignore(numeric_limits<int>::max(),'\n');
 
 	if(mie_in.irsunph >= 50) {
-	    fprintf(stderr, "mie_in.irsunph: %ld > 50, will cause internal buffer overflow.\n", mie_in.irsunph);
-	    exit(-1);
+	    G_fatal_error(_("mie_in.irsunph: %ld > 50, will cause internal buffer overflow"), mie_in.irsunph);
 	}
 
 	int i;
@@ -953,7 +956,7 @@
 	filename = filename.substr(0, filename.find(" "));
 	break;
     }
-    default: fprintf(stderr, "Unknown aerosol model!\n");
+    default: G_warning(_("Unknown aerosol model!"));
     }
 
     if(iaer >= 8 && iaer <= 11) 

Modified: grass/branches/develbranch_6/imagery/i.atcorr/AtmosModel.cpp
===================================================================
--- grass/branches/develbranch_6/imagery/i.atcorr/AtmosModel.cpp	2008-09-02 10:28:01 UTC (rev 33217)
+++ grass/branches/develbranch_6/imagery/i.atcorr/AtmosModel.cpp	2008-09-02 11:15:29 UTC (rev 33218)
@@ -1,3 +1,8 @@
+extern "C" {
+#include <grass/gis.h>
+#include <grass/glocale.h>
+}
+
 #include "common.h"
 #include "AtmosModel.h"
 
@@ -361,7 +366,7 @@
 	us62();
 	break;
     }
-    default: fprintf(stderr, "Unknown atmospheric model!\n");
+    default: G_warning(_("Unknown atmospheric model!"));
     }
 }
 

Modified: grass/branches/develbranch_6/imagery/i.atcorr/GeomCond.cpp
===================================================================
--- grass/branches/develbranch_6/imagery/i.atcorr/GeomCond.cpp	2008-09-02 10:28:01 UTC (rev 33217)
+++ grass/branches/develbranch_6/imagery/i.atcorr/GeomCond.cpp	2008-09-02 11:15:29 UTC (rev 33218)
@@ -1,3 +1,8 @@
+extern "C" {
+#include <grass/gis.h>
+#include <grass/glocale.h>
+}
+
 #include "GeomCond.h"
 #include "common.h"
 
@@ -81,7 +86,8 @@
 /*     jday is the number of the day in the month */
     day_number(ia, nojour);
     pos_fft (nojour, tu);
-    if (asol > 90.f) fprintf(stderr, "The sun is not raised\n");
+    if (asol > 90.f)
+	G_warning(_("The sun is not raised"));
 }
 
 void GeomCond::day_number(long int ia, long int& j)
@@ -219,7 +225,7 @@
     double sn, zt, xt, yt, teta, ylat, ylon;
     if((1. / cosx2) > ((yk * yk) / (yk*yk - 1.)))
     {
-	fprintf(stderr, "no possibility to compute lat. and long.\n");
+	G_warning(_("No possibility to compute lat. and long."));
 	return;
     }
     else
@@ -366,7 +372,7 @@
 	landsat(tu);
 	break;
     }
-    default: fprintf(stderr, "Unsupported format.\n");
+    default: G_warning(_("Unsupported format"));
     }
 
 

Modified: grass/branches/develbranch_6/imagery/i.atcorr/Iwave.cpp
===================================================================
--- grass/branches/develbranch_6/imagery/i.atcorr/Iwave.cpp	2008-09-02 10:28:01 UTC (rev 33217)
+++ grass/branches/develbranch_6/imagery/i.atcorr/Iwave.cpp	2008-09-02 11:15:29 UTC (rev 33218)
@@ -1,3 +1,8 @@
+extern "C" {
+#include <grass/gis.h>
+#include <grass/glocale.h>
+}
+
 #include "common.h"
 #include "Iwave.h"
 
@@ -1749,7 +1754,7 @@
 	else if(iwave <= 52)	avhrr(iwave - 36);
 	else if(iwave <= 60)	polder(iwave - 52);
 	else if(iwave <= 67)	etmplus(iwave - 60);
-	else fprintf(stderr, "Unsupported iwave value: %d\n", iwave);
+	else G_warning(_("Unsupported iwave value: %d"), iwave);
     }
 
     iinf = (int)((ffu.wlinf - 0.25f) / 0.0025f + 1.5f) - 1;	/* remember indexing*/

Modified: grass/branches/develbranch_6/imagery/i.atcorr/computations.cpp
===================================================================
--- grass/branches/develbranch_6/imagery/i.atcorr/computations.cpp	2008-09-02 10:28:01 UTC (rev 33217)
+++ grass/branches/develbranch_6/imagery/i.atcorr/computations.cpp	2008-09-02 11:15:29 UTC (rev 33218)
@@ -1,4 +1,10 @@
 #include <cstring>
+
+extern "C" {
+#include <grass/gis.h>
+#include <grass/glocale.h>
+}
+
 #include "common.h"
 #include "GeomCond.h"
 #include "AtmosModel.h"
@@ -168,7 +174,7 @@
 {
     if( ha >= 7 ) 
     {
-	fprintf(stderr, "ERROR: check aerosol measurements or plane altitude\n");
+	G_warning(_("Check aerosol measurements or plane altitude"));
 	return 0;
     }
 
@@ -1097,7 +1103,7 @@
 
     do {
 	/* loop on successive order */
-	ig = ig++;
+	ig++;
 
 	/* successive orders
 	   multiple scattering source function at every level within the laye */

Modified: grass/branches/develbranch_6/imagery/i.atcorr/main.cpp
===================================================================
--- grass/branches/develbranch_6/imagery/i.atcorr/main.cpp	2008-09-02 10:28:01 UTC (rev 33217)
+++ grass/branches/develbranch_6/imagery/i.atcorr/main.cpp	2008-09-02 11:15:29 UTC (rev 33218)
@@ -24,8 +24,8 @@
     Testing would be welcomed. :)  
 ***************************************************************************/
 
-#include <stdlib.h>
-#include <math.h>
+#include <cstdlib>
+#include <cmath>
 #include <map>
 
 extern "C" {
@@ -77,7 +77,7 @@
 static void copy_colors (char *, char *, char *);
 static void define_module (void);
 static struct Options define_options (void);
-static void read_scale (Option *, ScaleRange *);
+static void read_scale (Option *, ScaleRange &);
 
 
 /* 
@@ -90,10 +90,11 @@
     struct Cell_head iimg_head;	/* the input image header file */
 
     if(G_get_cellhd(name, mapset, &iimg_head) < 0) 
-	G_fatal_error ("Unable to retreive header dat for input image");
+	G_fatal_error (_("Unable to read header of raster map <%s>"),
+		       G_fully_qualified_name(name, mapset));
 
     if(G_set_window(&iimg_head) < 0) 
-	G_fatal_error ("Invalid graphics region coordinates");
+	G_fatal_error (_("Invalid graphics region coordinates"));
 }
 
 
@@ -278,7 +279,7 @@
     if(ialt_fd >= 0) alt = (FCELL*)G_allocate_raster_buf(FCELL_TYPE);
     if(ivis_fd >= 0) vis = (FCELL*)G_allocate_raster_buf(FCELL_TYPE);
 
-    fprintf(stderr, "Percent complete: ");
+    G_verbose_message(_("Percent complete..."));
 
     for(row = 0; row < G_window_rows(); row++)
     {
@@ -286,17 +287,20 @@
 		
         /* read the next row */
 	if(G_get_raster_row(ifd, buf, row, FCELL_TYPE) < 0)
-	    G_fatal_error ("Unable to read from input file");
+	    G_fatal_error (_("Unable to read input raster map row %d"),
+			     row);
 
         /* read the next row of elevation values */
         if(ialt_fd >= 0)
 	    if(G_get_raster_row(ialt_fd, alt, row, FCELL_TYPE) < 0)
-		G_fatal_error ("Unable to read from elevation raster");
+		G_fatal_error (_("Unable to read elevation raster map row %d"),
+			       row);
 
         /* read the next row of elevation values */
         if(ivis_fd >= 0)
 	    if(G_get_raster_row(ivis_fd, vis, row, FCELL_TYPE) < 0)
-		G_fatal_error ("Unable to read from visibility raster");
+		G_fatal_error (_("Unable to read visibility raster map row %d"),
+			       row);
 
         /* loop over all the values in the row */
 	for(col = 0; col < G_window_cols(); col++)
@@ -372,7 +376,7 @@
             buf[col] = buf[col] * ((float)oscale.max - (float)oscale.min) + oscale.min;
 
             if(~oflt && (buf[col] > (float)oscale.max))
-		G_warning ("The output data will overflow. Reflectance > 100%%");
+		G_warning (_("The output data will overflow. Reflectance > 100%%"));
 	}
 
         /* write output */
@@ -407,6 +411,8 @@
     module->label = _("Performs atmospheric correction using the 6S algorithm.");
     module->description =
 	_("6S - Second Simulation of Satellite Signal in the Solar Spectrum.");
+    module->keywords = _("imagery, atmospheric correction");
+
     /* 
        " Incorporated into Grass by Christo A. Zietsman, January 2003.\n"
        " Converted from Fortran to C by Christo A. Zietsman, November 2002.\n\n"
@@ -433,73 +439,75 @@
 
     opts.iimg = G_define_standard_option (G_OPT_R_INPUT);
     opts.iimg->key		= "iimg";
-    opts.iimg->description	= "Input imagery map to be corrected";
-/*	opts.iimg->answer	= "ETM4_400x400.raw"; */
 
     opts.iscl = G_define_option();
     opts.iscl->key          = "iscl";
     opts.iscl->type         = TYPE_INTEGER;
-    opts.iscl->key_desc     = "Input scale range";
+    opts.iscl->key_desc     = "range";
     opts.iscl->required     = NO;
     opts.iscl->answer       = "0,255";
-    opts.iscl->description  = "Input imagery range [0,255]";
+    opts.iscl->description  = _("Input imagery range [0,255]");
+    opts.iscl->guisection = _("Input");
 
     opts.ialt = G_define_standard_option (G_OPT_R_INPUT);
     opts.ialt->key		= "ialt";
-    opts.ialt->required	= NO;
-    opts.ialt->answer	= "dem_float";
-    opts.ialt->description	= "Input altitude map in m (optional)";
+    opts.ialt->required	        = NO;
+    opts.ialt->answer	        = "dem_float";
+    opts.ialt->description	= _("Input altitude raster map in m (optional)");
+    opts.ialt->guisection       = _("Input");
 
     opts.ivis = G_define_standard_option (G_OPT_R_INPUT);
     opts.ivis->key		= "ivis";
-    opts.ivis->required	= NO;
-/*	opts.ivis->answer	= "visibility"; */
-    opts.ivis->description	= "Input visibility map in km (optional)";
+    opts.ivis->required	        = NO;
+    opts.ivis->description	= _("Input visibility raster map in km (optional)");
+    opts.ivis->guisection       = _("Input");
 
     opts.icnd = G_define_standard_option (G_OPT_F_INPUT);
     opts.icnd->key		= "icnd";
-    opts.icnd->required	= YES;
-/*	opts.icnd->answer	= "ETM4_atmospheric_input_GRASS.txt"; */
-    opts.icnd->description	= "6S input text file";
+    opts.icnd->required	        = YES;
+    opts.icnd->description	= _("Name of input text file");
 
     opts.oimg = G_define_standard_option (G_OPT_R_OUTPUT);
     opts.oimg->key		= "oimg";
-/*	opts.oimg->answer	= "6s_output_file"; */
-    opts.oimg->description	= "6S output imagery map";
 
     opts.oscl = G_define_option();
     opts.oscl->key          = "oscl";
     opts.oscl->type         = TYPE_INTEGER;
-    opts.oscl->key_desc     = "Output scale range";
-    opts.oscl->required     = YES;
+    opts.oscl->key_desc     = "range";
     opts.oscl->answer       = "0,255";
-    opts.oscl->description  = "Rescale output imagery map [0,255]";
+    opts.oscl->required     = NO;
+    opts.oscl->description  = _("Rescale output raster map [0,255]");
+    opts.oscl->guisection = _("Output");
 
     opts.oflt = G_define_flag();
     opts.oflt->key = 'f';
-    opts.oflt->description = "Output raster is floating point";
+    opts.oflt->description = _("Output raster is floating point");
+    opts.oflt->guisection = _("Output");
 
     opts.irad = G_define_flag();
     opts.irad->key = 'r';
-    opts.irad->description = "Input map converted to reflectance (default is radiance)";
+    opts.irad->description = _("Input map converted to reflectance (default is radiance)");
+    opts.irad->guisection = _("Input");
 
     opts.etmafter = G_define_flag();
     opts.etmafter->key = 'a';
-    opts.etmafter->description = "Input from ETM+ image taken after July 1, 2000";
+    opts.etmafter->description = _("Input from ETM+ image taken after July 1, 2000");
+    opts.etmafter->guisection = _("Input");
 
     opts.etmbefore = G_define_flag();
     opts.etmbefore->key = 'b';
-    opts.etmbefore->description = "Input from ETM+ image taken before July 1, 2000";
+    opts.etmbefore->description = _("Input from ETM+ image taken before July 1, 2000");
+    opts.etmbefore->guisection = _("Input");
 
     opts.optimize = G_define_flag();
     opts.optimize->key = 'o';
-    opts.optimize->description = "Try to increase computation speed when categorized altitude or/and visibility map is used.";
+    opts.optimize->description = _("Try to increase computation speed when categorized altitude or/and visibility map is used");
 
     return opts;
 }
 
 /* Read the min and max values from the iscl and oscl options */
-static void read_scale (Option *scl, ScaleRange &range)
+void read_scale (Option *scl, ScaleRange &range)
 {
     /* set default values */
     range.min = 0;
@@ -512,7 +520,7 @@
 
         if(range.min==range.max)
         {
-            G_warning ("Scale range length should be > 0; Using default values: [0,255]");
+            G_warning (_("Scale range length should be > 0; Using default values: [0,255]"));
 
             range.min = 0;
             range.max = 255;
@@ -556,7 +564,8 @@
     if ( (iimg_mapset = G_find_cell2 ( opts.iimg->answer, "") ) == NULL )
 	G_fatal_error ( _("Raster map <%s> not found"), opts.iimg->answer);
     if((iimg_fd = G_open_cell_old(opts.iimg->answer, iimg_mapset)) < 0)
-	G_fatal_error ("Unable to open input raster");
+	G_fatal_error (_("Unable to open raster map <%s>"),
+		       G_fully_qualified_name(opts.iimg->answer, iimg_mapset));
 
     adjust_region(opts.iimg->answer, iimg_mapset);
         
@@ -564,26 +573,30 @@
 	if ( (ialt_mapset = G_find_cell2 ( opts.ialt->answer, "") ) == NULL )
 	    G_fatal_error ( _("Raster map <%s> not found"), opts.ialt->answer);
 	if((ialt_fd = G_open_cell_old(opts.ialt->answer, ialt_mapset)) < 0)
-            G_warning ("Unable to open DEM raster");
+            G_fatal_error (_("Unable to open raster map <%s>"),
+			   G_fully_qualified_name(opts.ialt->answer, ialt_mapset));
     }
 
     if(opts.ivis->answer) {
 	if ( (iviz_mapset = G_find_cell2 ( opts.ivis->answer, "") ) == NULL )
 	    G_fatal_error ( _("Raster map <%s> not found"), opts.ivis->answer);
 	if((ivis_fd = G_open_cell_old(opts.ivis->answer, iviz_mapset)) < 0)
-            G_warning ("Unable to open visibility raster");
+            G_fatal_error (_("Unable to open raster map <%s>"),
+			   G_fully_qualified_name(opts.ivis->answer, iviz_mapset));
     }
                 
     /* open a floating point raster or not? */
     if(opts.oflt->answer)
     {
 	if((oimg_fd = G_open_fp_cell_new(opts.oimg->answer)) < 0)
-	    G_fatal_error ("Unable to create output raster");
+	    G_fatal_error (_("Unable to create raster map <%s>"),
+			   opts.oimg->answer);
     }
     else
     {
 	if((oimg_fd = G_open_raster_new(opts.oimg->answer, CELL_TYPE)) < 0)
-	    G_fatal_error ("Unable to create output raster");
+	    G_fatal_error (_("Unable to create raster map <%s>"),
+			   opts.oimg->answer);
     }
 
     /* read the scale parameters */



More information about the grass-commit mailing list