[GRASS-SVN] r33826 - grass-addons/gipe/r.usler

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Oct 11 20:29:45 EDT 2008


Author: ychemin
Date: 2008-10-11 20:29:45 -0400 (Sat, 11 Oct 2008)
New Revision: 33826

Added:
   grass-addons/gipe/r.usler/r.usler.html
Removed:
   grass-addons/gipe/r.usler/description.html
   grass-addons/gipe/r.usler/sr.c
Modified:
   grass-addons/gipe/r.usler/elswaify85.c
   grass-addons/gipe/r.usler/foster81.c
   grass-addons/gipe/r.usler/main.c
   grass-addons/gipe/r.usler/morgan74.c
   grass-addons/gipe/r.usler/roose75.c
Log:
preparing for main SVN

Deleted: grass-addons/gipe/r.usler/description.html
===================================================================
--- grass-addons/gipe/r.usler/description.html	2008-10-11 21:54:03 UTC (rev 33825)
+++ grass-addons/gipe/r.usler/description.html	2008-10-12 00:29:45 UTC (rev 33826)
@@ -1,23 +0,0 @@
-<H2>DESCRIPTION</H2>
-
-<EM>r.usler</EM> calculates USLE R factor for Rainfall erosivity. It enables several empirical equations: Roosle (1975), Morgan (1974), Foster(1981) and El-Swaify (1985).
-
-<H2>NOTES</H2>
-
-<H2>TODO</H2>
-
-
-<H2>SEE ALSO</H2>
-
-<em>
-<A HREF="r.albedo.html">r.albedo</A><br>
-</em>
-
-
-<H2>AUTHORS</H2>
-Natialia Medvedeva, SIC-ISDC, Ashgabat, Turkmenistan<BR>
-Yann Chemin, SIC-ISDC, Ashgabat, Turkmenistan<BR>
-
-
-<p>
-<i>Last changed: $Date: 2006/10/22 12:30:42 $</i>

Modified: grass-addons/gipe/r.usler/elswaify85.c
===================================================================
--- grass-addons/gipe/r.usler/elswaify85.c	2008-10-11 21:54:03 UTC (rev 33825)
+++ grass-addons/gipe/r.usler/elswaify85.c	2008-10-12 00:29:45 UTC (rev 33826)
@@ -1,7 +1,8 @@
 #include<stdio.h>
 #include<math.h>
 #include<stdlib.h>
- double elswaify_1985(double annual_pmm) 
+
+double elswaify_1985(double annual_pmm) 
 {
     double result;
 

Modified: grass-addons/gipe/r.usler/foster81.c
===================================================================
--- grass-addons/gipe/r.usler/foster81.c	2008-10-11 21:54:03 UTC (rev 33825)
+++ grass-addons/gipe/r.usler/foster81.c	2008-10-12 00:29:45 UTC (rev 33826)
@@ -1,7 +1,8 @@
 #include<stdio.h>
 #include<math.h>
 #include<stdlib.h>
- double foster_1981(double annual_pmm) 
+
+double foster_1981(double annual_pmm) 
 {
     double result;
 

Modified: grass-addons/gipe/r.usler/main.c
===================================================================
--- grass-addons/gipe/r.usler/main.c	2008-10-11 21:54:03 UTC (rev 33825)
+++ grass-addons/gipe/r.usler/main.c	2008-10-12 00:29:45 UTC (rev 33826)
@@ -1,9 +1,8 @@
-
 /****************************************************************************
  *
  * MODULE:       r.usler
  * AUTHOR(S):    Natalia Medvedeva - natmead at gmail.com
- *		 Yann Chemin - ychemin at gmail.com
+ *		 Yann Chemin - yann.chemin at gmail.com
  * PURPOSE:      Calculates USLE R factor 
  * 		 Rainfall Erosion index according to four methods 
  *
@@ -14,179 +13,126 @@
  *   	    	 for details.
  * 
  *****************************************************************************/
-     
     
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <grass/gis.h>
 #include <grass/glocale.h>
-double elswaify_1985(double annaul_pmm);
 
+double elswaify_1985(double annaul_pmm);
 double morgan_1974(double annual_pmm);
-
 double foster_1981(double annual_pmm);
-
 double roose_1975(double annual_pmm);
 
 int main(int argc, char *argv[]) 
 {
-    struct Cell_head cellhd;	/*region+header info */
-
-    char *mapset;		/*mapset name */
-
     int nrows, ncols;
-
     int row, col;
-
     char *nameflag;		/*Switch for particular method */
-
     struct GModule *module;
-
     struct Option *input1, *input2, *output;
-
     struct History history;	/*metadata */
 
-    
-
-	/************************************/ 
-	/* FMEO Declarations**************** */ 
-    char *name;			/*input raster name */
-
+    /************************************/ 
     char *result;		/*output raster name */
-
-    
-	/*File Descriptors */ 
     int infd_annual_pmm;
-
     int outfd;
-
     char *annual_pmm;
 
-    int i = 0, j = 0;
-
     void *inrast_annual_pmm;
-
     DCELL * outrast;
-    RASTER_MAP_TYPE data_type_output = DCELL_TYPE;
-    RASTER_MAP_TYPE data_type_annual_pmm;
-    
 
-	/************************************/ 
-	G_gisinit(argv[0]);
+    /************************************/ 
+    G_gisinit(argv[0]);
+
     module = G_define_module();
     module->keywords = _("rainfall, erosion, USLE");
-    module->description = _("USLE R factor, Rainfall erosivity index.");
+    module->description = _("raster, USLE R factor, Rainfall erosivity index.");
     
-	/* Define the different options */ 
-	input1 = G_define_option();
-    input1->key = _("name");
+    /* Define the different options */ 
+    input1 = G_define_option();
+    input1->key = _("method");
     input1->type = TYPE_STRING;
     input1->required = YES;
     input1->gisprompt = _("Name of method to use");
     input1->description =
 	_("Name of USLE R equation: roose, morgan, foster, elswaify.");
     input1->answer = _("morgan");
+
     input2 = G_define_standard_option(G_OPT_R_INPUT);
-    input2->key = _("annual_precip");
     input2->description = _("Name of the annual precipitation map");
-    input2->answer = _("annual_pmm");
+
     output = G_define_standard_option(G_OPT_R_OUTPUT);
-    output->key = _("usler");
     output->description = _("Name of the output usler layer");
-    output->answer = _("usler");
     
+    /********************/ 
+    if (G_parser(argc, argv))
+        exit(EXIT_FAILURE);
 
-	/********************/ 
-	if (G_parser(argc, argv))
-	exit(EXIT_FAILURE);
     nameflag = input1->answer;
     annual_pmm = input2->answer;
     result = output->answer;
     
-
-	/***************************************************/ 
-	mapset = G_find_cell2(annual_pmm, "");
-    if (mapset == NULL) {
-	G_fatal_error(_("cell file [%s] not found"), annual_pmm);
-    }
-    data_type_annual_pmm = G_raster_map_type(annual_pmm, mapset);
-    if ((infd_annual_pmm = G_open_cell_old(annual_pmm, mapset)) < 0)
+    /***************************************************/ 
+    if ((infd_annual_pmm = G_open_cell_old(annual_pmm, "")) < 0)
 	G_fatal_error(_("Cannot open cell file [%s]"), annual_pmm);
-    if (G_get_cellhd(annual_pmm, mapset, &cellhd) < 0)
-	G_fatal_error(_("Cannot read file header of [%s])"), annual_pmm);
-    inrast_annual_pmm = G_allocate_raster_buf(data_type_annual_pmm);
+    inrast_annual_pmm = G_allocate_d_raster_buf();
     
-
-	/***************************************************/ 
-	G_debug(3, "number of rows %d", cellhd.rows);
+    /***************************************************/ 
     nrows = G_window_rows();
     ncols = G_window_cols();
-    outrast = G_allocate_raster_buf(data_type_output);
+    outrast = G_allocate_d_raster_buf();
     
-	/* Create New raster files */ 
-	if ((outfd = G_open_raster_new(result, data_type_output)) < 0)
+    /* Create New raster files */ 
+    if ((outfd = G_open_raster_new(result, DCELL_TYPE)) < 0)
 	G_fatal_error(_("Could not open <%s>"), result);
     
-	/* Process pixels */ 
-	for (row = 0; row < nrows; row++)
-	 {
-	DCELL d;
+    /* Process pixels */ 
+    for (row = 0; row < nrows; row++)
+    {
+        DCELL d;
 	DCELL d_annual_pmm;
 	G_percent(row, nrows, 2);
 	
-	    /* read input map */ 
-	    if (G_get_raster_row
-		(infd_annual_pmm, inrast_annual_pmm, row,
-		 data_type_annual_pmm) < 0)
+	/* read input map */ 
+	if (G_get_d_raster_row(infd_annual_pmm, inrast_annual_pmm, row) < 0)
 	    G_fatal_error(_("Could not read from <%s>"), annual_pmm);
 	
-	    /*process the data */ 
-	    for (col = 0; col < ncols; col++)
-	     {
+	/*process the data */ 
+	for (col = 0; col < ncols; col++)
+	{
 	    d_annual_pmm = ((DCELL *) inrast_annual_pmm)[col];
-	    if (G_is_d_null_value(&d_annual_pmm)) {
+	    if (G_is_d_null_value(&d_annual_pmm)) 
 		G_set_d_null_value(&outrast[col], 1);
-	    }
-	    else {
-		
-
-				/************************************/ 
-		    /*calculate morgan       */ 
-		    if (!strcoll(nameflag, "morgan")) {
-		    d = morgan_1974(d_annual_pmm);
-		    outrast[col] = d;
-		}
-		
-		    /*calculate roose                   */ 
-		    if (!strcoll(nameflag, "roose")) {
+	    else 
+            {
+                /*calculate morgan       */ 
+                if (!strcmp(nameflag, "morgan"))
+                    d = morgan_1974(d_annual_pmm);
+		/*calculate roose        */ 
+		if (!strcmp(nameflag, "roose")) 
 		    d = roose_1975(d_annual_pmm);
-		    outrast[col] = d;
-		}
-		
-		    /*calculate foster                  */ 
-		    if (!strcoll(nameflag, "foster")) {
+		/*calculate foster       */ 
+		if (!strcmp(nameflag, "foster"))
 		    d = foster_1981(d_annual_pmm);
-		    outrast[col] = d;
-		}
-		
-		    /*calculate elswaify                */ 
-		    if (!strcoll(nameflag, "elswaify")) {
+		/*calculate elswaify     */ 
+		if (!strcmp(nameflag, "elswaify")) 
 		    d = elswaify_1985(d_annual_pmm);
-		    outrast[col] = d;
-		}
 	    }
-	    }
-	if (G_put_raster_row(outfd, outrast, data_type_output) < 0)
+	if (G_put_d_raster_row(outfd, outrast) < 0)
 	    G_fatal_error(_("Cannot write to output raster file"));
 	}
+    }
     G_free(inrast_annual_pmm);
     G_close_cell(infd_annual_pmm);
     G_free(outrast);
     G_close_cell(outfd);
+
     G_short_history(result, "raster", &history);
     G_command_history(&history);
     G_write_history(result, &history);
+
     exit(EXIT_SUCCESS);
 }
 

Modified: grass-addons/gipe/r.usler/morgan74.c
===================================================================
--- grass-addons/gipe/r.usler/morgan74.c	2008-10-11 21:54:03 UTC (rev 33825)
+++ grass-addons/gipe/r.usler/morgan74.c	2008-10-12 00:29:45 UTC (rev 33826)
@@ -1,7 +1,8 @@
 #include<stdio.h>
 #include<math.h>
 #include<stdlib.h>
- double morgan_1974(double annual_pmm) 
+
+double morgan_1974(double annual_pmm) 
 {
     double result;
 

Copied: grass-addons/gipe/r.usler/r.usler.html (from rev 33815, grass-addons/gipe/r.usler/description.html)
===================================================================
--- grass-addons/gipe/r.usler/r.usler.html	                        (rev 0)
+++ grass-addons/gipe/r.usler/r.usler.html	2008-10-12 00:29:45 UTC (rev 33826)
@@ -0,0 +1,24 @@
+<H2>DESCRIPTION</H2>
+
+<EM>r.usler</EM> calculates USLE R factor for Rainfall erosivity. It enables several empirical equations: Roosle (1975), Morgan (1974), Foster(1981) and El-Swaify (1985).
+
+<H2>NOTES</H2>
+
+<H2>TODO</H2>
+
+
+<H2>SEE ALSO</H2>
+
+<em>
+<A HREF="r.uslek.html">r.uslek</A><br>
+<A HREF="r.watershed.html">r.watershed</A><br>
+</em>
+
+
+<H2>AUTHORS</H2>
+Natialia Medvedeva, SIC-ISDC, Ashgabat, Turkmenistan<BR>
+Yann Chemin, SIC-ISDC, Ashgabat, Turkmenistan<BR>
+
+
+<p>
+<i>Last changed: $Date: 2008/10/12 08:30:42 $</i>


Property changes on: grass-addons/gipe/r.usler/r.usler.html
___________________________________________________________________
Name: svn:mergeinfo
   + 

Modified: grass-addons/gipe/r.usler/roose75.c
===================================================================
--- grass-addons/gipe/r.usler/roose75.c	2008-10-11 21:54:03 UTC (rev 33825)
+++ grass-addons/gipe/r.usler/roose75.c	2008-10-12 00:29:45 UTC (rev 33826)
@@ -1,7 +1,8 @@
 #include<stdio.h>
 #include<math.h>
 #include<stdlib.h>
- double roose_1975(double annual_pmm) 
+
+double roose_1975(double annual_pmm) 
 {
     double result;
 

Deleted: grass-addons/gipe/r.usler/sr.c
===================================================================
--- grass-addons/gipe/r.usler/sr.c	2008-10-11 21:54:03 UTC (rev 33825)
+++ grass-addons/gipe/r.usler/sr.c	2008-10-12 00:29:45 UTC (rev 33826)
@@ -1,19 +0,0 @@
-#include<stdio.h>
-#include<math.h>
-#include<stdlib.h>
-
-// Simple Vegetation ratio
-
-double s_r( double redchan, double nirchan )
-{
-	double result;
-	
-	if( ( redchan ) ==  0.0 ){
-		result = -1.0;
-	} else {
-		result =(nirchan/redchan);
-	}
-	
-	return result;
-
-}



More information about the grass-commit mailing list