[GRASS-SVN] r34250 - in grass/branches/develbranch_6: gui/wxpython/gui_modules imagery/i.rectify

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Nov 11 15:48:05 EST 2008


Author: martinl
Date: 2008-11-11 15:48:05 -0500 (Tue, 11 Nov 2008)
New Revision: 34250

Modified:
   grass/branches/develbranch_6/gui/wxpython/gui_modules/georect.py
   grass/branches/develbranch_6/imagery/i.rectify/cp.c
   grass/branches/develbranch_6/imagery/i.rectify/exec.c
   grass/branches/develbranch_6/imagery/i.rectify/get_wind.c
   grass/branches/develbranch_6/imagery/i.rectify/main.c
   grass/branches/develbranch_6/imagery/i.rectify/rectify.c
   grass/branches/develbranch_6/imagery/i.rectify/report.c
   grass/branches/develbranch_6/imagery/i.rectify/target.c
   grass/branches/develbranch_6/imagery/i.rectify/write.c
Log:
wxGUI: fix georectify tool (i.rectify)
       i.rectify message cosmetics + i18n


Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/georect.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/georect.py	2008-11-11 18:32:44 UTC (rev 34249)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/georect.py	2008-11-11 20:48:05 UTC (rev 34250)
@@ -24,12 +24,14 @@
 import sys
 import tempfile
 import shutil
+import time
 
 import wx
 from wx.lib.mixins.listctrl import CheckListCtrlMixin, ListCtrlAutoWidthMixin, TextEditMixin
 import wx.lib.colourselect as  csel
 import wx.wizard as wiz
 
+import grass
 import globalvar
 import mapdisp
 import render
@@ -996,8 +998,10 @@
             if self.clip_to_region:
                 cmdlist.append('-c')
             
-            self.parent.goutput.RunCmd(cmdlist)
+            self.parent.goutput.RunCmd(cmdlist, compReg=False,
+                                       switchPage=True)
 
+            time.sleep(.1)
             self.grwiz.SwitchEnv('original')
 
         elif maptype == 'vector':

Modified: grass/branches/develbranch_6/imagery/i.rectify/cp.c
===================================================================
--- grass/branches/develbranch_6/imagery/i.rectify/cp.c	2008-11-11 18:32:44 UTC (rev 34249)
+++ grass/branches/develbranch_6/imagery/i.rectify/cp.c	2008-11-11 20:48:05 UTC (rev 34250)
@@ -1,5 +1,6 @@
 #include <stdlib.h>
 #include <string.h>
+#include <grass/glocale.h>
 #include "global.h"
 #include "crs.h"		/* CRS HEADER FILE */
 int get_control_points(char *group, int order	/* THIS HAS BEEN ADDED WITH THE CRS MODIFICATIONS */
@@ -11,24 +12,24 @@
     if (!I_get_control_points(group, &cp))
 	exit(0);
 
-    sprintf(msg, "Control Point file for group [%s] in [%s] - ",
+    sprintf(msg, _("Control Point file for group <%s@%s> - "),
 	    group, G_mapset());
 
     switch (CRS_compute_georef_equations(&cp, E12, N12, E21, N21, order)) {
     case 0:
 	sprintf(&msg[strlen(msg)],
-		"Not enough active control points for current order, %d are required.",
+		_("Not enough active control points for current order, %d are required."),
 		(order + 1) * (order + 2) / 2);
 	break;
     case -1:
-	strcat(msg, "Poorly placed control points.");
-	strcat(msg, " Can not generate the transformation equation.");
+	strcat(msg, _("Poorly placed control points."));
+	strcat(msg, _(" Can not generate the transformation equation."));
 	break;
     case -2:
-	strcat(msg, "Not enough memory to solve for transformation equation");
+	strcat(msg, _("Not enough memory to solve for transformation equation"));
 	break;
     case -3:
-	strcat(msg, "Invalid order");
+	strcat(msg, _("Invalid order"));
 	break;
     default:
 	/* COMMENTED OUT WHEN SUPPORT FOR 3rd ORDER WAS ADDED BY 'CRS'
@@ -40,5 +41,6 @@
 	return 1;
     }
     G_fatal_error(msg);
-    exit(1);
+
+    return 0; /* G_fatal_error() calls exit() */
 }

Modified: grass/branches/develbranch_6/imagery/i.rectify/exec.c
===================================================================
--- grass/branches/develbranch_6/imagery/i.rectify/exec.c	2008-11-11 18:32:44 UTC (rev 34249)
+++ grass/branches/develbranch_6/imagery/i.rectify/exec.c	2008-11-11 20:48:05 UTC (rev 34250)
@@ -13,6 +13,7 @@
 #include <fcntl.h>
 #include <time.h>
 #include <unistd.h>
+#include <grass/glocale.h>
 #include "global.h"
 
 int exec_rectify(int order, char *extension)
@@ -50,8 +51,8 @@
 		G_malloc(strlen(ref.file[n].name) + strlen(extension) + 1);
 	    strcpy(result, ref.file[n].name);
 	    strcat(result, extension);
-	    fprintf(stderr, "Rectified input file %s will be saved as %s\n",
-		    name, result);
+	    G_message(_("Rectified input raster map <%s> will be saved as <%s>"),
+		      name, result);
 
 	    select_current_env();
 

Modified: grass/branches/develbranch_6/imagery/i.rectify/get_wind.c
===================================================================
--- grass/branches/develbranch_6/imagery/i.rectify/get_wind.c	2008-11-11 18:32:44 UTC (rev 34249)
+++ grass/branches/develbranch_6/imagery/i.rectify/get_wind.c	2008-11-11 20:48:05 UTC (rev 34250)
@@ -1,3 +1,4 @@
+#include <grass/glocale.h>
 #include "global.h"
 #include "crs.h"		/* CRS HEADER FILE */
 
@@ -42,9 +43,9 @@
     w2->ns_res = (w2->north - w2->south) / w1->rows;
     w2->ew_res = (w2->east - w2->west) / w1->cols;
 
-    fprintf(stderr, "Region N=%f S=%f E=%f W=%f\n", w2->north, w2->south,
+    G_message(_("Region N=%f S=%f E=%f W=%f"), w2->north, w2->south,
 	    w2->east, w2->west);
-    fprintf(stderr, "Resolution EW=%f NS=%f\n", w2->ew_res, w2->ns_res);
+    G_message(_("Resolution EW=%f NS=%f"), w2->ew_res, w2->ns_res);
 
     return 0;
 }

Modified: grass/branches/develbranch_6/imagery/i.rectify/main.c
===================================================================
--- grass/branches/develbranch_6/imagery/i.rectify/main.c	2008-11-11 18:32:44 UTC (rev 34249)
+++ grass/branches/develbranch_6/imagery/i.rectify/main.c	2008-11-11 20:48:05 UTC (rev 34250)
@@ -24,10 +24,11 @@
 
 #include <stdlib.h>
 #include <string.h>
+#include <grass/glocale.h>
 #include "global.h"
 #include "crs.h"
-#include <grass/glocale.h>
 
+
 ROWCOL row_map[NROWS][NCOLS];
 ROWCOL col_map[NROWS][NCOLS];
 ROWCOL row_min[NROWS];
@@ -80,11 +81,11 @@
     G_gisinit(argv[0]);
 
     module = G_define_module();
-    module->keywords = _("imagery");
+    module->keywords = _("imagery, rectify");
     module->description =
 	_("Rectifies an image by computing a coordinate "
 	  "transformation for each pixel in the image based on the "
-	  "control points");
+	  "control points.");
 
     grp = G_define_standard_option(G_OPT_I_GROUP);
 
@@ -107,7 +108,7 @@
     c = G_define_flag();
     c->key = 'c';
     c->description =
-	_("Use curr. region settings in target location (def.=calculate smallest area)");
+	_("Use current region settings in target location (def.=calculate smallest area)");
 
     a = G_define_flag();
     a->key = 'a';
@@ -201,7 +202,7 @@
 	georef_window(&cellhd, &target_window, order);
     }
 
-    G_message(_("Using Region: N=%f S=%f, E=%f W=%f"), target_window.north,
+    G_verbose_message(_("Using region: N=%f S=%f, E=%f W=%f"), target_window.north,
 	      target_window.south, target_window.east, target_window.west);
 
     exec_rectify(order, extension);
@@ -215,11 +216,11 @@
     int n;
 
     fprintf(stderr,
-	    "Input raster map <%s> does not exist in group <%s>.\n Try:\n",
+	    _("Input raster map <%s> does not exist in group <%s>.\n Try:\n"),
 	    file, grp);
 
     for (n = 0; n < ref.nfiles; n++)
 	fprintf(stderr, "%s\n", ref.file[n].name);
 
-    G_fatal_error("Exit!");
+    G_fatal_error(_("Exit!"));
 }

Modified: grass/branches/develbranch_6/imagery/i.rectify/rectify.c
===================================================================
--- grass/branches/develbranch_6/imagery/i.rectify/rectify.c	2008-11-11 18:32:44 UTC (rev 34249)
+++ grass/branches/develbranch_6/imagery/i.rectify/rectify.c	2008-11-11 20:48:05 UTC (rev 34250)
@@ -1,4 +1,5 @@
 #include <unistd.h>
+#include <grass/glocale.h>
 #include "global.h"
 
 /* Modified to support Grass 5.0 fp format 11 april 2000
@@ -90,17 +91,14 @@
 
     if (target_window.proj != cellhd.proj) {
 	cellhd.proj = target_window.proj;
-	sprintf(buf,
-		"WARNING %s@%s: projection don't match current settings.\n",
-		name, mapset);
-	G_warning(buf);
+	G_warning(_("Raster map <%s@%s>: projection don't match current settings"),
+		  name, mapset);
     }
 
     if (target_window.zone != cellhd.zone) {
 	cellhd.zone = target_window.zone;
-	sprintf(buf, "WARNING %s@%s: zone don't match current settings .\n",
-		name, mapset);
-	G_warning(buf);
+	G_warning(_("Raster map <%s@%s>: zone don't match current settings"),
+		  name, mapset);
     }
 
     target_window.compressed = cellhd.compressed;

Modified: grass/branches/develbranch_6/imagery/i.rectify/report.c
===================================================================
--- grass/branches/develbranch_6/imagery/i.rectify/report.c	2008-11-11 18:32:44 UTC (rev 34249)
+++ grass/branches/develbranch_6/imagery/i.rectify/report.c	2008-11-11 20:48:05 UTC (rev 34250)
@@ -1,3 +1,4 @@
+#include <grass/glocale.h>
 #include "global.h"
 
 int report(char *name, char *mapset, char *result,
@@ -8,14 +9,11 @@
     long ncells;
 
     select_current_env();
-    fprintf(stderr, "***********************************************\n");
-    fprintf(stderr, "Rectify [%s@%s] (LOCATION %s)\n",
-	    name, mapset, G_location());
-    fprintf(stderr, " into  [%s in ", result);
+    G_message(_("Rectify <%s@%s> (location <%s>)"),
+	      name, mapset, G_location());
     select_target_env();
-    fprintf(stderr, "%s] (LOCATION %s)\n", G_mapset(), G_location());
-    fprintf(stderr, "%s\n", ok ? "complete" : "failed");
-    fprintf(stderr, "-----------------------------------------------\n");
+    G_message(_("into  <%s@%s> (location <%s>) ... %s"),
+	      result, G_mapset(), G_location(), ok ? _("complete") : _("failed"));
     select_current_env();
 
     if (!ok)
@@ -26,30 +24,33 @@
     hours = minutes / 60;
     minutes -= hours * 60;
     ncells = target_window.rows * target_window.cols;
-    fprintf(stderr, " %d rows, %d cols (%ld cells) completed in ",
-	    target_window.rows, target_window.cols, ncells);
+    G_verbose_message(_("%d rows, %d cols (%ld cells) completed in"),
+			target_window.rows, target_window.cols, ncells);
     if (hours)
-	fprintf(stderr, "%d:%02d:%02ld\n", hours, minutes, seconds % 60);
+	G_verbose_message("%d:%02d:%02ld", hours, minutes, seconds % 60);
     else
-	fprintf(stderr, "%d:%02ld\n", minutes, seconds % 60);
+	G_verbose_message("%d:%02ld", minutes, seconds % 60);
     if (seconds)
-	fprintf(stderr, " %.1f cells per minute\n",
-		(60.0 * ncells) / ((double)seconds));
-
-    fprintf(stderr, "\n");
+	G_verbose_message(_("%.1f cells per minute"),
+			  (60.0 * ncells) / ((double)seconds));
+		      
     seconds = compress;
 
-    if (seconds <= 0)
+    if (seconds <= 0) {
+	G_message("-----------------------------------------------");
 	return 1;
+    }
 
     minutes = seconds / 60;
     hours = minutes / 60;
     minutes -= hours * 60;
-    fprintf(stderr, " data compression required an additional ");
+    G_verbose_message(_("data compression required an additional"));
     if (hours)
-	fprintf(stderr, "%d:%02d:%02ld\n", hours, minutes, seconds % 60);
+	G_verbose_message("%d:%02d:%02ld", hours, minutes, seconds % 60);
     else
-	fprintf(stderr, "%d:%02ld\n", minutes, seconds % 60);
+	G_verbose_message("%d:%02ld\n", minutes, seconds % 60);
 
+    G_message("-----------------------------------------------");
+
     return 0;
 }

Modified: grass/branches/develbranch_6/imagery/i.rectify/target.c
===================================================================
--- grass/branches/develbranch_6/imagery/i.rectify/target.c	2008-11-11 18:32:44 UTC (rev 34249)
+++ grass/branches/develbranch_6/imagery/i.rectify/target.c	2008-11-11 20:48:05 UTC (rev 34250)
@@ -1,5 +1,6 @@
 #include <string.h>
 #include <unistd.h>
+#include <grass/glocale.h>
 #include "global.h"
 
 int get_target(char *group)
@@ -10,13 +11,13 @@
     int stat;
 
     if (!I_get_target(group, location, mapset)) {
-	sprintf(buf, "Target information for group [%s] missing\n", group);
+	sprintf(buf, _("Target information for group <%s> missing"), group);
 	goto error;
     }
 
     sprintf(buf, "%s/%s", G_gisdbase(), location);
     if (access(buf, 0) != 0) {
-	sprintf(buf, "Target location [%s] not found\n", location);
+	sprintf(buf, _("Target location <%s> not found"), location);
 	goto error;
     }
     select_target_env();
@@ -28,10 +29,10 @@
 	select_current_env();
 	return 1;
     }
-    sprintf(buf, "Mapset [%s] in target location [%s] - ", mapset, location);
-    strcat(buf, stat == 0 ? "permission denied\n" : "not found\n");
+    sprintf(buf, _("Mapset <%s> in target location <%s> - "), mapset, location);
+    strcat(buf, stat == 0 ? _("permission denied") : _("not found"));
   error:
-    strcat(buf, "Please run i.target for group ");
+    strcat(buf, _("Please run i.target for group."));
     strcat(buf, group);
     G_fatal_error(buf);
     return 1;			/* never reached */

Modified: grass/branches/develbranch_6/imagery/i.rectify/write.c
===================================================================
--- grass/branches/develbranch_6/imagery/i.rectify/write.c	2008-11-11 18:32:44 UTC (rev 34249)
+++ grass/branches/develbranch_6/imagery/i.rectify/write.c	2008-11-11 20:48:05 UTC (rev 34250)
@@ -2,6 +2,7 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <unistd.h>
+#include <grass/glocale.h>
 #include "global.h"
 
 int write_matrix(int row, int col)
@@ -23,7 +24,7 @@
 	if (write(temp_fd, cell_buf[n], G_raster_size(map_type) * matrix_cols)
 	    != G_raster_size(map_type) * matrix_cols) {
 	    unlink(temp_name);
-	    G_fatal_error("error while writing to temp file");
+	    G_fatal_error(_("Error while writing to temp file"));
 	}
 	/*G_put_map_row_random (outfd, cell_buf[n], row++, col, matrix_cols); */
     }
@@ -45,14 +46,15 @@
     fd = G_open_raster_new(name, map_type);
 
     if (fd <= 0)
-	G_fatal_error("Can't open map %s", name);
+	G_fatal_error(_("Unable to create raster map <%s>"), name);
 
     for (row = 0; row < target_window.rows; row++) {
 	if (read(temp_fd, rast, target_window.cols * G_raster_size(map_type))
 	    != target_window.cols * G_raster_size(map_type))
-	    G_fatal_error("error writing row %d", row);
+	    G_fatal_error(_("Error writing row %d"), row);
 	if (G_put_raster_row(fd, rast, map_type) < 0) {
-	    G_fatal_error("error while writing to raster map");
+	    G_fatal_error(_("Failed writing raster map <%s> row %d"),
+			  name, row);
 	    unlink(temp_name);
 	}
     }



More information about the grass-commit mailing list