[GRASS-SVN] r43396 - grass-addons/imagery/i.topo.corr

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Sep 3 11:58:49 EDT 2010


Author: ejtizado
Date: 2010-09-03 15:58:49 +0000 (Fri, 03 Sep 2010)
New Revision: 43396

Modified:
   grass-addons/imagery/i.topo.corr/correction.c
   grass-addons/imagery/i.topo.corr/description.html
   grass-addons/imagery/i.topo.corr/local_proto.h
   grass-addons/imagery/i.topo.corr/main.c
Log:
Two bugs corrected

Modified: grass-addons/imagery/i.topo.corr/correction.c
===================================================================
--- grass-addons/imagery/i.topo.corr/correction.c	2010-09-03 15:44:49 UTC (rev 43395)
+++ grass-addons/imagery/i.topo.corr/correction.c	2010-09-03 15:58:49 UTC (rev 43396)
@@ -83,25 +83,22 @@
     /* Calculating Constants */
     switch (method) {
     case MINNAERT:
-	cka = cos_z;
-	ckb = 0.;
+	cka = ckb = 0.;
 	kk = m;
 	G_message("Minnaert constant = %lf", kk);
 	break;
     case C_CORRECT:
-	cka = cos_z + a / m;
-	ckb = a / m;
+	cka = ckb = m / a;
 	kk = 1.;
-	G_message("C-factor constant = %lf (a=%.4f; m=%.4f)", a / m, a, m);
+	G_message("C-factor constant = %lf (a=%.4f; m=%.4f)", cka, a, m);
 	break;
     case PERCENT:
-	cka = 2.;
+	cka = 2. - cos_z;
 	ckb = 1.;
 	kk = 1.;
 	break;
     default:			/* COSINE */
-	cka = cos_z;
-	ckb = 0.;
+	cka = ckb = 0.;
 	kk = 1.;
     }
     /* Topographic correction */
@@ -135,21 +132,12 @@
 	    }
 	    else {
 		ref_i = (double)*((DCELL *) pref);
-		if (method == MINNAERT) {
-		    G_debug(3,
-			    "Old val: %f, cka: %f, cos_i: %f, ckb: %f, kk: %f, New val: %f",
-			    ref_i, cka, cos_i, ckb, kk, (DCELL) (ref_i * pow(cos_z / cos_i, kk)));
-		    ((DCELL *) out->rast)[col] =
-			(DCELL) (ref_i * pow(cos_z / cos_i, kk));
-		}
-		else {
-		    G_debug(3,
-			    "Old val: %f, cka: %f, cos_i: %f, ckb: %f, kk: %f, New val: %f",
-			    ref_i, cka, cos_i, ckb, kk, (DCELL) (ref_i * (cka / (cos_i + ckb))));
-		    ((DCELL *) out->rast)[col] =
-			(DCELL) (ref_i * (cka / (cos_i + ckb)));
-		}
-
+		((DCELL *) out->rast)[col] =
+		    (DCELL) (ref_i * pow((cos_z + cka) / (cos_i + ckb), kk));
+		G_debug(3,
+			"Old val: %f, cka: %f, cos_i: %f, ckb: %f, kk: %f, New val: %f",
+			ref_i, cka, cos_i, ckb, kk,
+			((DCELL *) out->rast)[col]);
 	    }
 	}
 	G_put_raster_row(out->fd, out->rast, out->type);

Modified: grass-addons/imagery/i.topo.corr/description.html
===================================================================
--- grass-addons/imagery/i.topo.corr/description.html	2010-09-03 15:44:49 UTC (rev 43395)
+++ grass-addons/imagery/i.topo.corr/description.html	2010-09-03 15:58:49 UTC (rev 43396)
@@ -36,7 +36,7 @@
 	<li>ref_c = ref_o · (cos_z + c)/ (cos_i + c)</li>
 </ul>
 where,
-<em>c</em> is a/m from ref_o = a + m cos_i.</p>
+<em>c</em> is m/a from ref_o = a + m cos_i.</p>
 
 <H3>Method: percent</H3>
 

Modified: grass-addons/imagery/i.topo.corr/local_proto.h
===================================================================
--- grass-addons/imagery/i.topo.corr/local_proto.h	2010-09-03 15:44:49 UTC (rev 43395)
+++ grass-addons/imagery/i.topo.corr/local_proto.h	2010-09-03 15:58:49 UTC (rev 43396)
@@ -7,11 +7,11 @@
 
 typedef struct
 {
-	int     fd;
-	char    name[128];
-	char *	mapset;
-	void *  rast;
-	RASTER_MAP_TYPE type;
+    int fd;
+    char name[128];
+    char *mapset;
+    void *rast;
+    RASTER_MAP_TYPE type;
 } Gfile;
 
 #define LAMBERTIAN		 	 0
@@ -21,8 +21,9 @@
 #define MINNAERT			11
 #define C_CORRECT			12
 
-
-void eval_cosi(Gfile *, Gfile *, double, double);
+void eval_c_cosi(Gfile *, Gfile *, double, double);
+void eval_f_cosi(Gfile *, Gfile *, double, double);
+void eval_d_cosi(Gfile *, Gfile *, double, double);
 void eval_tcor(int, Gfile *, Gfile *, Gfile *, double);
 
 #endif

Modified: grass-addons/imagery/i.topo.corr/main.c
===================================================================
--- grass-addons/imagery/i.topo.corr/main.c	2010-09-03 15:44:49 UTC (rev 43395)
+++ grass-addons/imagery/i.topo.corr/main.c	2010-09-03 15:58:49 UTC (rev 43396)
@@ -22,10 +22,6 @@
 
 #include "local_proto.h"
 
-extern void eval_c_cosi(Gfile *, Gfile *, double, double);
-extern void eval_f_cosi(Gfile *, Gfile *, double, double);
-extern void eval_d_cosi(Gfile *, Gfile *, double, double);
-
 int full_open_old(Gfile * gf, char *fname)
 {
     gf->fd = -1;
@@ -259,6 +255,5 @@
 	G_close_cell(dem.fd);
     }
 
-    G_done_msg(" ");
     exit(EXIT_SUCCESS);
 }



More information about the grass-commit mailing list