[GRASS-SVN] r33918 - grass/branches/develbranch_6/imagery/i.ortho.photo/photo.rectify

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Oct 16 10:17:05 EDT 2008


Author: hamish
Date: 2008-10-16 10:17:05 -0400 (Thu, 16 Oct 2008)
New Revision: 33918

Modified:
   grass/branches/develbranch_6/imagery/i.ortho.photo/photo.rectify/aver_z.c
   grass/branches/develbranch_6/imagery/i.ortho.photo/photo.rectify/exec.c
   grass/branches/develbranch_6/imagery/i.ortho.photo/photo.rectify/get_wind.c
   grass/branches/develbranch_6/imagery/i.ortho.photo/photo.rectify/main.c
   grass/branches/develbranch_6/imagery/i.ortho.photo/photo.rectify/matrix.c
   grass/branches/develbranch_6/imagery/i.ortho.photo/photo.rectify/perform.c
   grass/branches/develbranch_6/imagery/i.ortho.photo/photo.rectify/ps_cp.c
   grass/branches/develbranch_6/imagery/i.ortho.photo/photo.rectify/rectify.c
Log:
use G_debug

Modified: grass/branches/develbranch_6/imagery/i.ortho.photo/photo.rectify/aver_z.c
===================================================================
--- grass/branches/develbranch_6/imagery/i.ortho.photo/photo.rectify/aver_z.c	2008-10-16 13:43:39 UTC (rev 33917)
+++ grass/branches/develbranch_6/imagery/i.ortho.photo/photo.rectify/aver_z.c	2008-10-16 14:17:05 UTC (rev 33918)
@@ -19,17 +19,12 @@
 
 	n++;
 	meanz += *((cpz->z2)++);
-#ifdef DEBUG3
-	fprintf(Bugsr, "In ortho meanz = %f \n", meanz);
-#endif
-
+	G_debug(3, "In ortho meanz = %f", meanz);
     }
 
     *aver_z = meanz / n;
 
-#ifdef DEBUG3
-    fprintf(Bugsr, "In ortho aver_z = %f \n", *aver_z);
-#endif
+    G_debug(1, "In ortho aver_z = %f", *aver_z);
 
     /* reset pointers */
     for (i = 0; i < cpz->count; i++) {

Modified: grass/branches/develbranch_6/imagery/i.ortho.photo/photo.rectify/exec.c
===================================================================
--- grass/branches/develbranch_6/imagery/i.ortho.photo/photo.rectify/exec.c	2008-10-16 13:43:39 UTC (rev 33917)
+++ grass/branches/develbranch_6/imagery/i.ortho.photo/photo.rectify/exec.c	2008-10-16 14:17:05 UTC (rev 33918)
@@ -35,41 +35,33 @@
 
     /* rectify each file */
     for (n = 0; n < group.group_ref.nfiles; n++) {
-#ifdef DEBUG3
-	fprintf(Bugsr, "I look for files to ortho rectify \n");
-#endif
+	G_debug(2, "I look for files to ortho rectify");
+
 	if ((i = ref_list[n]) < 0)
 	    continue;
 	name = group.group_ref.file[i].name;
 	mapset = group.group_ref.file[i].mapset;
 	result = new_name[n];
 
-#ifdef DEBUG3
-	fprintf(Bugsr, "ORTHO RECTIFYING: \n");
-	fprintf(Bugsr, "NAME %s \n", name);
-	fprintf(Bugsr, "MAPSET %s \n", mapset);
-	fprintf(Bugsr, "RESULT %s \n", result);
-#endif
+	G_debug(2, "ORTHO RECTIFYING:");
+	G_debug(2, "NAME %s", name);
+	G_debug(2, "MAPSET %s", mapset);
+	G_debug(2, "RESULT %s", result);
+	G_debug(2, "select_current_env...");
 
-#ifdef DEBUG3
-	fprintf(Bugsr, "select_current_env...\n");
-#endif
 	select_current_env();
 
 	cats_ok = G_read_cats(name, mapset, &cats) >= 0;
 	colr_ok = G_read_colors(name, mapset, &colr) > 0;
 	hist_ok = G_read_history(name, mapset, &hist) >= 0;
-#ifdef DEBUG3
-	fprintf(Bugsr, "reading was fine...\n");
-#endif
+	G_debug(2, "reading was fine...");
+
 	time(&start_time);
-#ifdef DEBUG3
-	fprintf(Bugsr, "Starting the rectification...\n");
-#endif
+
+	G_debug(2, "Starting the rectification...");
+
 	if (rectify(name, mapset, result)) {
-#ifdef DEBUG3
-	    fprintf(Bugsr, "Done. Writing results...\n");
-#endif
+	    G_debug(2, "Done. Writing results...");
 	    select_target_env();
 	    if (cats_ok) {
 		G_write_cats(result, &cats);
@@ -91,13 +83,11 @@
 		   compress_time - rectify_time, 1);
 	}
 	else {
-#ifdef DEBUG3
-	    fprintf(Bugsr, "Could not rectify. Mhhh.\n");
-#endif
+	    G_debug(2, "Could not rectify. Mhhh.");
 	    report(name, mapset, result, (long)0, (long)0, 0);
 	}
     }
 
-    G_done_msg("");
+    G_done_msg(" ");
     return 0;
 }

Modified: grass/branches/develbranch_6/imagery/i.ortho.photo/photo.rectify/get_wind.c
===================================================================
--- grass/branches/develbranch_6/imagery/i.ortho.photo/photo.rectify/get_wind.c	2008-10-16 13:43:39 UTC (rev 33917)
+++ grass/branches/develbranch_6/imagery/i.ortho.photo/photo.rectify/get_wind.c	2008-10-16 14:17:05 UTC (rev 33918)
@@ -1,7 +1,6 @@
 #include <stdlib.h>
 #include <string.h>
 #include "global.h"
-/* FILE *Bugsr; */
 
 int get_target_window(void)
 {
@@ -32,20 +31,16 @@
     }
     ask_file_from_list(name, mapset);
 
-#ifdef DEBUG3
-    fprintf(Bugsr, "ask_file: %s in %s \n", name, mapset);
-#endif
+    G_debug(1, "ask_file: %s in %s", name, mapset);
 
     if (G_get_cellhd(name, mapset, &cellhd) < 0)
 	exit(EXIT_FAILURE);
 
-#ifdef DEBUG3
-    fprintf(Bugsr, "current window: n s = %f %f, \n", cellhd.north,
+
+    G_debug(1, "current window: n s = %f %f,", cellhd.north,
 	    cellhd.south);
-    fprintf(Bugsr, "current window: w e = %f %f, \n", cellhd.west,
+    G_debug(1, "current window: w e = %f %f,", cellhd.west,
 	    cellhd.east);
-    fflush(Bugsr);
-#endif
 
     georef_window(&cellhd, &target_window);
     ask_window(&target_window);
@@ -70,9 +65,7 @@
 
     /* get an average elevation from the active control points */
     get_aver_elev(&group.control_points, &aver_z);
-#ifdef DEBUG3
-    fprintf(Bugsr, "Aver elev = %f \n", aver_z);
-#endif
+    G_debug(1, "Aver elev = %f", aver_z);
 
     /* compute ortho ref of all corners */
 
@@ -81,17 +74,14 @@
 			group.XC, group.YC, group.ZC, group.omega, group.phi,
 			group.kappa);
 
-#ifdef DEBUG3
-    fprintf(Bugsr, "NORTH WEST CORNER\n");
-    fprintf(Bugsr, "group.E12 = %f %f %f, \n", group.E12[0], group.E12[1],
+    G_debug(1, "NORTH WEST CORNER");
+    G_debug(1, "group.E12 = %f %f %f,", group.E12[0], group.E12[1],
 	    group.E12[2]);
-    fprintf(Bugsr, "group.N12 = %f %f %f, \n", group.N12[0], group.N12[1],
+    G_debug(1, "group.N12 = %f %f %f,", group.N12[0], group.N12[1],
 	    group.N12[2]);
-    fprintf(Bugsr, "image  x = %f y = %f, photo x = %f y = %f \n", w1->west,
+    G_debug(1, "image  x = %f y = %f, photo x = %f y = %f", w1->west,
 	    w1->north, e0, n0);
-    fprintf(Bugsr, "target x = %f y = %f \n", e, n);
-    fflush(Bugsr);
-#endif
+    G_debug(1, "target x = %f y = %f", e, n);
 
     w2->north = w2->south = n;
     w2->west = w2->east = e;
@@ -101,14 +91,12 @@
 			group.XC, group.YC, group.ZC, group.omega, group.phi,
 			group.kappa);
 
-#ifdef DEBUG3
-    fprintf(Bugsr, "NORTH EAST CORNER\n");
-    fprintf(Bugsr, "image  x = %f y = %f, photo x = %f y = %f \n", w1->east,
+    G_debug(1, "NORTH EAST CORNER");
+    G_debug(1, "image  x = %f y = %f, photo x = %f y = %f", w1->east,
 	    w1->north, e0, n0);
-    fprintf(Bugsr, "target x = %f y = %f \n", e, n);
-    fflush(Bugsr);
-#endif
+    G_debug(1, "target x = %f y = %f", e, n);
 
+
     if (n > w2->north)
 	w2->north = n;
     if (n < w2->south)
@@ -123,13 +111,10 @@
 			group.XC, group.YC, group.ZC, group.omega, group.phi,
 			group.kappa);
 
-#ifdef DEBUG3
-    fprintf(Bugsr, "SOUTH WEST CORNER\n");
-    fprintf(Bugsr, "image  x = %f y = %f, photo x = %f y = %f \n", w1->west,
+    G_debug(1, "SOUTH WEST CORNER");
+    G_debug(1, "image  x = %f y = %f, photo x = %f y = %f", w1->west,
 	    w1->south, e0, n0);
-    fprintf(Bugsr, "target x = %f y = %f \n", e, n);
-    fflush(Bugsr);
-#endif
+    G_debug(1, "target x = %f y = %f", e, n);
 
     if (n > w2->north)
 	w2->north = n;
@@ -145,13 +130,10 @@
 			group.XC, group.YC, group.ZC, group.omega, group.phi,
 			group.kappa);
 
-#ifdef DEBUG3
-    fprintf(Bugsr, "SOUTH EAST CORNER\n");
-    fprintf(Bugsr, "image  x = %f y = %f, photo x = %f y = %f \n", w1->east,
+    G_debug(1, "SOUTH EAST CORNER");
+    G_debug(1, "image  x = %f y = %f, photo x = %f y = %f", w1->east,
 	    w1->south, e0, n0);
-    fprintf(Bugsr, "target x = %f y = %f \n", e, n);
-    fflush(Bugsr);
-#endif
+    G_debug(1, "target x = %f y = %f", e, n);
 
     if (n > w2->north)
 	w2->north = n;
@@ -176,16 +158,12 @@
     w2->south = w2->south - 0.15 * diffns;
     w2->north = w2->north + 0.15 * diffns;
 
-#ifdef DEBUG3
-    fprintf(Bugsr, "FINAL\n");
-    fprintf(Bugsr, "east = %f \n west = %f \n north = %f \n south = %f \n",
+    G_debug(1, "FINAL");
+    G_debug(1, "east = %f \n west = %f \n north = %f \n south = %f",
 	    w2->east, w2->west, w2->north, w2->south);
+    G_debug(1, "RESOLUTION");
+    G_debug(1, "EW = %f", w2->ew_res);
+    G_debug(1, "NS = %f", w2->ns_res);
 
-    fprintf(Bugsr, "RESOLUTION\n");
-    fprintf(Bugsr, "EW = %f\n", w2->ew_res);
-    fprintf(Bugsr, "NS = %f\n", w2->ns_res);
-    fflush(Bugsr);
-#endif
-
     return 0;
 }

Modified: grass/branches/develbranch_6/imagery/i.ortho.photo/photo.rectify/main.c
===================================================================
--- grass/branches/develbranch_6/imagery/i.ortho.photo/photo.rectify/main.c	2008-10-16 13:43:39 UTC (rev 33917)
+++ grass/branches/develbranch_6/imagery/i.ortho.photo/photo.rectify/main.c	2008-10-16 14:17:05 UTC (rev 33918)
@@ -58,14 +58,6 @@
 	exit(EXIT_FAILURE);
 
 
-#ifdef DEBUG3
-/* slowly convert these to G_debug() */
-    Bugsr = fopen("ortho_rectify.rst", "w");
-    if (Bugsr == NULL)
-	G_fatal_error("Can't open debug file \"ortho_rectify.rst\"");
-#endif
-
-
     G_suppress_masking();	/* need to do this for target location */
 
     strcpy(name, group_opt->answer);

Modified: grass/branches/develbranch_6/imagery/i.ortho.photo/photo.rectify/matrix.c
===================================================================
--- grass/branches/develbranch_6/imagery/i.ortho.photo/photo.rectify/matrix.c	2008-10-16 13:43:39 UTC (rev 33917)
+++ grass/branches/develbranch_6/imagery/i.ortho.photo/photo.rectify/matrix.c	2008-10-16 14:17:05 UTC (rev 33918)
@@ -48,11 +48,7 @@
 	cmap = col_map[row];
 	min = max = -1;
 
-/**** 
-#ifdef DEBUG3
-fprintf (Bugsr,"\n\t got row = \t%d\n",row);
-#endif
-****/
+/*	G_debug(3, "\n\t got row = \t%d", row); */
 
 	/* compute common code */
 	EX = E21a + E21c * row;
@@ -79,12 +75,9 @@
 		cc = -1;
 	    *cmap++ = cc;
 
-/*****
-#ifdef DEBUG3
-fprintf (Bugsr,"\n\tnx = \t%f \tex = \t%f \n\trr = \t%d \tcc = \t%d\n", nx, ex,rr, cc);
-#endif
-*****/
+/*	    G_debug(4, "\n\tnx = \t%f \tex = \t%f \n\trr = \t%d \tcc = \t%d", nx, ex,rr, cc); */
 	}
+
 	row_min[row] = min;
 	row_max[row] = max;
 	row_left[row] = 0;

Modified: grass/branches/develbranch_6/imagery/i.ortho.photo/photo.rectify/perform.c
===================================================================
--- grass/branches/develbranch_6/imagery/i.ortho.photo/photo.rectify/perform.c	2008-10-16 13:43:39 UTC (rev 33917)
+++ grass/branches/develbranch_6/imagery/i.ortho.photo/photo.rectify/perform.c	2008-10-16 14:17:05 UTC (rev 33918)
@@ -35,15 +35,14 @@
 		break;
 	    curidx++;
 	}
-	/*
-	   fprintf (Bugsr, " curidx %d\n", curidx);
-	 */
+
+	/* G_debug(3, " curidx %d", curidx); */
+
 	if (curidx >= matrix_rows)
 	    break;
-	/*
-	   fprintf (Bugsr, "read row %d\n", row);
-	 */
 
+	/* G_debug(3, "read row %d", row); */
+
 	if (G_get_raster_row_nomask
 	    (infd, G_incr_void_ptr(rast, rast_size), row, map_type) < 0)
 	    return 0;
@@ -52,9 +51,9 @@
 	    idx = row_idx[i];
 	    if (row != row_min[idx])
 		break;
-	    /*
-	       fprintf (Bugsr, "  process matrix row %d\n", idx);
-	     */
+
+	    /* G_debug(4, "  process matrix row %d", idx); */
+
 	    rmap = row_map[idx];
 	    cmap = col_map[idx];
 	    left = row_left[idx];

Modified: grass/branches/develbranch_6/imagery/i.ortho.photo/photo.rectify/ps_cp.c
===================================================================
--- grass/branches/develbranch_6/imagery/i.ortho.photo/photo.rectify/ps_cp.c	2008-10-16 13:43:39 UTC (rev 33917)
+++ grass/branches/develbranch_6/imagery/i.ortho.photo/photo.rectify/ps_cp.c	2008-10-16 14:17:05 UTC (rev 33918)
@@ -1,5 +1,6 @@
 #include <stdlib.h>
 #include <string.h>
+#include <grass/glocale.h>
 #include "global.h"
 
 int get_psuedo_control_pt(int tie_row, int tie_col)
@@ -8,10 +9,7 @@
     struct Ortho_Photo_Points ps_cp;
     int i, j, k;
 
-#ifdef DEBUG3
-    fprintf(Bugsr, "In ps_cp \n");
-    fflush(Bugsr);
-#endif
+    G_debug(1, "In ps_cp");
 
     /*  allocate psuedo struct, max points are four */
     ps_cp.count = 4;
@@ -20,13 +18,8 @@
     ps_cp.e2 = (double *)G_malloc(4 * sizeof(double));
     ps_cp.n2 = (double *)G_malloc(4 * sizeof(double));
     ps_cp.status = (int *)G_malloc(4 * sizeof(int));
+    G_debug(1, "ps_cp allocated");
 
-#ifdef DEBUG3
-    fprintf(Bugsr, "ps_cp allocated \n");
-    fflush(Bugsr);
-#endif
-
-
     /*  pseudo points are four corners taken from T_Points */
     k = 0;
     for (i = 0; i < 2; i++) {
@@ -42,46 +35,31 @@
 		   T_Point[tie_row + 1][tie_col].YT) / target_window.ns_res));
 	    ps_cp.status[k] = 1;
 
-#ifdef DEBUG3
-	    fprintf(Bugsr, "\t k = %d\t i = %d\t j = %d \n", k, i, j);
-	    fprintf(Bugsr, "\t\t e1[k] = %f \n", ps_cp.e1[k]);
-	    fprintf(Bugsr, "\t\t n1[k] = %f \n", ps_cp.n1[k]);
-	    fprintf(Bugsr, "\t\t e2[k] = %f \n", ps_cp.e2[k]);
-	    fprintf(Bugsr, "\t\t n2[k] = %f \n", ps_cp.n2[k]);
-	    fflush(Bugsr);
-#endif
+	    G_debug(2, "\t k = %d\t i = %d\t j = %d", k, i, j);
+	    G_debug(2, "\t\t e1[k] = %f", ps_cp.e1[k]);
+	    G_debug(2, "\t\t n1[k] = %f", ps_cp.n1[k]);
+	    G_debug(2, "\t\t e2[k] = %f", ps_cp.e2[k]);
+	    G_debug(2, "\t\t n2[k] = %f", ps_cp.n2[k]);
 
 	    k++;
 	}
     }
 
-#ifdef DEBUG3
-    fprintf(Bugsr, "ps_cp initialized \n");
-    fflush(Bugsr);
-#endif
+    G_debug(1, "ps_cp initialized");
 
-
     switch (I_compute_ref_equations(&ps_cp, E12, N12, E21, N21)) {
     case -1:
-#ifdef DEBUG3
-	fprintf(Bugsr, "\tref_equ: case -1\n");
-	fflush(Bugsr);
-#endif
-	strcat(msg, "Poorly placed psuedo control points.\n");
-	strcat(msg, "Can not generate the transformation equation.\n");
+	G_debug(1, "\tref_equ: case -1");
+	strcat(msg, _("Poorly placed psuedo control points. "));
+	strcat(msg, _("Cannot generate the transformation equation."));
 	break;
     case 0:
-#ifdef DEBUG3
-	fprintf(Bugsr, "\tref_equ: case 0 \n");
-	fflush(Bugsr);
-#endif
-	strcat(msg, "No active psuedo control points\n");
+	G_debug(1, "\tref_equ: case 0");
+	strcat(msg, _("No active psuedo control points"));
 	break;
     default:
-#ifdef DEBUG3
-	fprintf(Bugsr, "\tref equ: case good\n");
-	fflush(Bugsr);
-#endif
+	G_debug(1, "\tref equ: case good");
+
 	E12a = E12[0];
 	E12b = E12[1];
 	E12c = E12[2];
@@ -94,13 +72,11 @@
 	N21a = N21[0];
 	N21b = N21[1];
 	N21c = N21[2];
-#ifdef DEBUG3
-	fprintf(Bugsr, "\t\tE21 = %f\t %f\t %f \n", E21a, E21b, E21c);
-	fprintf(Bugsr, "\t\tN21 = %f\t %f\t %f \n", N21a, N21b, N21c);
-	fflush(Bugsr);
-#endif
+
+	G_debug(1, "\t\tE21 = %f\t %f\t %f", E21a, E21b, E21c);
+	G_debug(1, "\t\tN21 = %f\t %f\t %f", N21a, N21b, N21c);
+
 	return 1;
     }
     G_fatal_error(msg);
-    exit(1);
 }

Modified: grass/branches/develbranch_6/imagery/i.ortho.photo/photo.rectify/rectify.c
===================================================================
--- grass/branches/develbranch_6/imagery/i.ortho.photo/photo.rectify/rectify.c	2008-10-16 13:43:39 UTC (rev 33917)
+++ grass/branches/develbranch_6/imagery/i.ortho.photo/photo.rectify/rectify.c	2008-10-16 14:17:05 UTC (rev 33918)
@@ -7,6 +7,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
+#include <grass/glocale.h>
 #include "global.h"
 #include "local_proto.h"
 
@@ -25,22 +26,17 @@
     int r2, c2;
     double row2, col2;
     double aver_z;
-    char buf[64] = "";
 
+    G_debug(1, "Open temp elevation file: ");
 
-#ifdef DEBUG3
-    fprintf(Bugsr, "Open temp elevation file: \n");
-#endif
-
     /*  open temporary elevation cell layer */
     select_target_env();
 
     /**G_set_window (&elevhd);**/
-#ifdef DEBUG3
-    fprintf(Bugsr, "target window: rs=%d cs=%d n=%f s=%f w=%f e=%f\n",
+    G_debug(1, "target window: rs=%d cs=%d n=%f s=%f w=%f e=%f\n",
 	    target_window.rows, target_window.cols, target_window.north,
 	    target_window.south, target_window.west, target_window.east);
-#endif
+
     G_set_window(&target_window);
     elevfd = G_open_cell_old(elev_layer, mapset_elev);
 
@@ -53,29 +49,21 @@
 
 
     if (elevfd < 0) {
-#ifdef DEBUG3
-	fprintf(Bugsr, "CANT OPEN ELEV\n");
-	fprintf(Bugsr, "elev layer = %s  mapset elev = %s elevfd = %d \n",
+	G_debug(1, "CANT OPEN ELEV");
+	G_debug(1, "elev layer = %s  mapset elev = %s elevfd = %d",
 		elev_layer, mapset_elev, elevfd);
-	fflush(Bugsr);
-#endif
 	return 0;
     }
 
-#ifdef DEBUG3
-    fprintf(Bugsr, "elev layer = %s  mapset elev = %s elevfd = %d \n",
+    G_debug(1, "elev layer = %s  mapset elev = %s elevfd = %d",
 	    elev_layer, mapset_elev, elevfd);
-    fflush(Bugsr);
-#endif
 
     /* alloc Tie_Points  */
     y_ties = (int)(target_window.rows / TIE_ROW_DIST) + 2;
     x_ties = (int)(target_window.cols / TIE_COL_DIST) + 2;
 
-#ifdef DEBUG3
-    fprintf(Bugsr, "Number Tie_Points: y_ties %d \tx_ties %d \n", y_ties,
+    G_debug(1, "Number Tie_Points: y_ties %d \tx_ties %d", y_ties,
 	    x_ties);
-#endif
 
     T_Point = (Tie_Point **) G_malloc(y_ties * sizeof(Tie_Point *));
     for (i = 0; i < y_ties; i++)
@@ -92,11 +80,8 @@
 	r2 = (int)row2;
 
 	if ((G_get_d_raster_row(elevfd, elevbuf, r2)) < 0) {
-#ifdef DEBUG3
-	    fprintf(Bugsr,
-		    "ERROR reading elevation layer %s fd = %d : row %d \n",
+	    G_debug(1, "ERROR reading elevation layer %s fd = %d : row %d",
 		    elev_layer, elevfd, r2);
-#endif
 	    exit(0);
 	}
 	ncols = 0;
@@ -105,56 +90,42 @@
 		(tie_col * TIE_COL_DIST * target_window.ew_res) + 1;
 	    if (e2 >= target_window.east)
 		e2 = target_window.east - 1;
-#ifdef DEBUG3
-	    fprintf(Bugsr, "Tie_Point \t row %d \tcol %d \n", tie_row,
-		    tie_col);
-	    fprintf(Bugsr, "\t east %f\t north %f \n", e2, n2);
-#endif
 
+	    G_debug(5, "Tie_Point \t row %d \tcol %d", tie_row, tie_col);
+	    G_debug(5, "\t east %f\t north %f", e2, n2);
+
 	    col2 = easting_to_col(&target_window, e2);
 	    c2 = (int)col2;
 
-#ifdef DEBUG3
-	    fprintf(Bugsr, "\t\t row2 = %f \t col2 =  %f \n", row2, col2);
-	    fprintf(Bugsr, "\t\t   r2 = %d \t   c2 =  %d \n", r2, c2);
-	    fprintf(Bugsr, "\t\t elevbuf[c2] = %f        \n",
-		    (DCELL) elevbuf[c2]);
-#endif
+	    G_debug(5, "\t\t row2 = %f \t col2 =  %f", row2, col2);
+	    G_debug(5, "\t\t   r2 = %d \t   c2 =  %d", r2, c2);
+	    G_debug(5, "\t\t elevbuf[c2] = %f", (DCELL) elevbuf[c2]);
+
 	    /* if target TIE point has no elevation, set to aver_z */
 	    if (G_is_d_null_value(&elevbuf[c2]))
 		z2 = aver_z;
 	    else
 		z2 = (double)elevbuf[c2];
 
-#ifdef DEBUG3
-	    fprintf(Bugsr, "\t\t e2 = %f \t n2 =  %f \t z2 = %f \n", e2, n2,
-		    z2);
-	    fprintf(Bugsr, "\t\t XC = %f \t YC =  %f \t ZC = %f \n", group.XC,
+	    G_debug(5, "\t\t e2 = %f \t n2 =  %f \t z2 = %f", e2, n2, z2);
+	    G_debug(5, "\t\t XC = %f \t YC =  %f \t ZC = %f", group.XC,
 		    group.YC, group.ZC);
-	    fprintf(Bugsr, "\t\t omega = %f \t phi =  %f \t kappa = %f \n",
+	    G_debug(5, "\t\t omega = %f \t phi =  %f \t kappa = %f",
 		    group.omega, group.phi, group.kappa);
-#endif
 
 	    /* ex, nx: photo coordinates */
 	    I_ortho_ref(e2, n2, z2, &ex, &nx, &zx, &group.camera_ref,
 			group.XC, group.YC, group.ZC, group.omega, group.phi,
 			group.kappa);
 
-#ifdef DEBUG3
-	    fprintf(Bugsr,
-		    "\t\tAfter ortho ref (photo cords): ex = %f \t nx =  %f \n",
+	    G_debug(5, "\t\tAfter ortho ref (photo cords): ex = %f \t nx =  %f",
 		    ex, nx);
-	    fflush(Bugsr);
-#endif
 
 	    /* ex, nx: relative to (row,col) = 0 */
 	    I_georef(ex, nx, &ex, &nx, group.E21, group.N21);
 
-#ifdef DEBUG3
-	    fprintf(Bugsr, "\t\tAfter geo ref: ex = %f \t nx =  %f \n", ex,
-		    nx);
-	    fflush(Bugsr);
-#endif
+	    G_debug(5, "\t\tAfter geo ref: ex = %f \t nx =  %f", ex, nx);
+
 	    T_Point[tie_row][tie_col].XT = e2;
 	    T_Point[tie_row][tie_col].YT = n2;
 	    T_Point[tie_row][tie_col].ZT = z2;
@@ -167,10 +138,8 @@
     /* close elev layer so we can open the file to be rectified */
     select_target_env();
     if (!G_close_cell(elevfd)) {
-#ifdef DEBUG3
-	fprintf(Bugsr, "Can't close the elev file %s [%s in%s]",
+	G_debug(1, "Can't close the elev file %s [%s in %s]",
 		elev_layer, mapset_elev, G_location());
-#endif
     }
 
     /* open the result file into target window
@@ -199,10 +168,7 @@
     col = 0;
 
     for (tie_col = 0; tie_col < (x_ties - 1); tie_col++) {
-#ifdef DEBUG3
-	fprintf(Bugsr, "Patching column %d: \n", ncols);
-	fflush(Bugsr);
-#endif
+	G_debug(3, "Patching column %d:", ncols);
 
 	if ((win.cols = ncols) > TIE_COL_DIST)
 	    win.cols = TIE_COL_DIST;
@@ -211,27 +177,19 @@
 	row = 0;
 
 	for (tie_row = 0; tie_row < (y_ties - 1); tie_row++) {
-#ifdef DEBUG3
+	    G_debug(5, "Patching %d row:", nrows);
 
-	    fprintf(Bugsr, "Patching %d row: \n", nrows);
-	    fflush(Bugsr);
-#endif
 	    if ((win.rows = nrows) > TIE_ROW_DIST)
 		win.rows = TIE_ROW_DIST;
 
 	    get_psuedo_control_pt(tie_row, tie_col);
-#ifdef DEBUG3
-	    fprintf(Bugsr, "\t got psuedo pts: row %d \t col %d \n", tie_row,
-		    tie_col);
-	    fflush(Bugsr);
-#endif
 
+	    G_debug(5, "\t got psuedo pts: row %d \t col %d", tie_row, tie_col);
+
 	    compute_georef_matrix(&cellhd, &win);
-#ifdef DEBUG3
-	    fprintf(Bugsr, "\t\tcompute geo matrix\n");
-	    fflush(Bugsr);
-#endif
 
+	    G_debug(5, "\t\tcompute geo matrix");
+
 	    /* open the source imagery file to be rectified */
 	    /* set window to cellhd first to be able to read file exactly */
 	    select_current_env();
@@ -249,13 +207,9 @@
 
 	    /* perform the actual data rectification */
 	    perform_georef(infd, rast);
-#ifdef DEBUG3
-	    fprintf(Bugsr, "\t\tperform georef \n");
-	    fflush(Bugsr);
 
-	    fprintf(Bugsr, "\t\twrite matrix \n");
-	    fflush(Bugsr);
-#endif
+	    G_debug(5, "\t\tperform georef");
+	    G_debug(5, "\t\twrite matrix");
 
 	    /* close the source imagery file and free the buffer */
 	    select_current_env();
@@ -288,17 +242,14 @@
 
     if (target_window.proj != cellhd.proj) {
 	cellhd.proj = target_window.proj;
-	sprintf(buf,
-		"WARNING %s@%s: projection don't match current settings.\n",
+	G_warning(_("%s@%s: projection doesn't match current settings"),
 		name, mapset);
-	G_warning(buf);
     }
 
     if (target_window.zone != cellhd.zone) {
 	cellhd.zone = target_window.zone;
-	sprintf(buf, "WARNING %s@%s: zone don't match current settings .\n",
+	 G_warning(_("%s@%s: zone doesn't match current settings"),
 		name, mapset);
-	G_warning(buf);
     }
 
     target_window.compressed = cellhd.compressed;



More information about the grass-commit mailing list