[GRASS-SVN] r33934 - grass-addons/gipe/i.sattime

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Oct 20 07:39:43 EDT 2008


Author: ychemin
Date: 2008-10-20 07:39:43 -0400 (Mon, 20 Oct 2008)
New Revision: 33934

Added:
   grass-addons/gipe/i.sattime/i.sattime.html
Removed:
   grass-addons/gipe/i.sattime/description.html
Modified:
   grass-addons/gipe/i.sattime/main.c
Log:
bug fixing, prepare for main SVN

Deleted: grass-addons/gipe/i.sattime/description.html
===================================================================
--- grass-addons/gipe/i.sattime/description.html	2008-10-20 11:16:03 UTC (rev 33933)
+++ grass-addons/gipe/i.sattime/description.html	2008-10-20 11:39:43 UTC (rev 33934)
@@ -1,25 +0,0 @@
-<H2>DESCRIPTION</H2>
-
-<EM>i.sattime</EM> creates a map of the time of satellite overpass. It takes input from sun elevation, latitude and DOY.
-
-<H2>NOTES</H2>
-
-
-
-<H2>TODO</H2>
-
-
-<H2>SEE ALSO</H2>
-
-<em>
-<A HREF="i.latitude.html">i.latitude</A><br>
-</em>
-
-
-<H2>AUTHORS</H2>
-
-Yann Chemin, GRASS Development Team<BR>
-
-
-<p>
-<i>Last changed: $Date: 2007/02/19 16:19:59 $</i>

Copied: grass-addons/gipe/i.sattime/i.sattime.html (from rev 33842, grass-addons/gipe/i.sattime/description.html)
===================================================================
--- grass-addons/gipe/i.sattime/i.sattime.html	                        (rev 0)
+++ grass-addons/gipe/i.sattime/i.sattime.html	2008-10-20 11:39:43 UTC (rev 33934)
@@ -0,0 +1,25 @@
+<H2>DESCRIPTION</H2>
+
+<EM>i.sattime</EM> creates a map of the time of satellite overpass. It takes input from sun elevation, latitude and DOY.
+
+<H2>NOTES</H2>
+
+
+
+<H2>TODO</H2>
+
+
+<H2>SEE ALSO</H2>
+
+<em>
+<A HREF="i.latitude.html">i.latitude</A><br>
+</em>
+
+
+<H2>AUTHORS</H2>
+
+Yann Chemin, GRASS Development Team<BR>
+
+
+<p>
+<i>Last changed: $Date: 2007/02/19 16:19:59 $</i>


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

Modified: grass-addons/gipe/i.sattime/main.c
===================================================================
--- grass-addons/gipe/i.sattime/main.c	2008-10-20 11:16:03 UTC (rev 33933)
+++ grass-addons/gipe/i.sattime/main.c	2008-10-20 11:39:43 UTC (rev 33934)
@@ -1,4 +1,3 @@
-
 /****************************************************************************
  *
  * MODULE:       i.sattime
@@ -13,7 +12,6 @@
  *   	    	 for details.
  *
  *****************************************************************************/
-     
     
 #include <stdio.h>
 #include <stdlib.h>
@@ -23,88 +21,70 @@
 #include <grass/glocale.h>
     
 #define PI 3.1415927
+
 int main(int argc, char *argv[]) 
 {
     struct Cell_head cellhd;	/*region+header info */
-
     char *mapset;		/*mapset name */
-
     int nrows, ncols;
-
     int row, col;
-
     struct GModule *module;
-
     struct Option *input1, *input2, *input3, *input4, *output1;
-
     struct Flag *flag1;
-
     struct History history;	/*metadata */
 
-    
-
-	/************************************/ 
-	/* FMEO Declarations**************** */ 
+    /************************************/ 
     char *name;			/*input raster name */
-
     char *result1;		/*output raster name */
-
     
-	/*File Descriptors */ 
+    /*File Descriptors */ 
     int infd_lat, infd_lon, infd_doy, infd_phi;
-
     int outfd1;
-
     char *lat, *lon, *doy, *phi;
-
     int i = 0, j = 0;
-
     void *inrast_lat, *inrast_lon, *inrast_doy, *inrast_phi;
 
     DCELL * outrast1;
-    RASTER_MAP_TYPE data_type_output = DCELL_TYPE;
-    RASTER_MAP_TYPE data_type_lat;
-    RASTER_MAP_TYPE data_type_lon;
-    RASTER_MAP_TYPE data_type_doy;
-    RASTER_MAP_TYPE data_type_phi;
-    
 
-	/************************************/ 
-	G_gisinit(argv[0]);
+    /************************************/ 
+    G_gisinit(argv[0]);
     module = G_define_module();
     module->keywords = _("satellite time, overpass");
     module->description = _("creates a satellite overpass time map");
     
-	/* Define the different options */ 
-	input1 = G_define_standard_option(G_OPT_R_INPUT);
+    /* Define the different options */ 
+    input1 = G_define_standard_option(G_OPT_R_INPUT);
     input1->key = _("doy");
     input1->description = _("Name of the DOY input map");
+
     input2 = G_define_standard_option(G_OPT_R_INPUT);
     input2->key = _("lat");
     input2->description = _("Name of the latitude input map");
+
     input3 = G_define_standard_option(G_OPT_R_INPUT);
     input3->key = _("long");
     input3->description = _("Name of the longitude input map");
+
     input4 = G_define_standard_option(G_OPT_R_INPUT);
     input4->key = _("sun_elev");
     input4->description = _("Name of the sun elevation angle input map");
+
     output1 = G_define_standard_option(G_OPT_R_OUTPUT);
     output1->description =
 	_("Name of the output satellite overpass time layer");
-    
 
-	/********************/ 
-	if (G_parser(argc, argv))
+    /********************/ 
+    if (G_parser(argc, argv))
 	exit(EXIT_FAILURE);
+
     doy = input1->answer;
     lat = input2->answer;
     lon = input3->answer;
     phi = input4->answer;
     result1 = output1->answer;
-    
 
-	/***************************************************/ 
-	mapset = G_find_cell2(doy, "");
+    /***************************************************/ 
+    mapset = G_find_cell2(doy, "");
     if (mapset == NULL) {
 	G_fatal_error(_("cell file [%s] not found"), doy);
     }
@@ -114,10 +94,9 @@
     if (G_get_cellhd(doy, mapset, &cellhd) < 0)
 	G_fatal_error(_("Cannot read file header of [%s])"), doy);
     inrast_doy = G_allocate_raster_buf(data_type_doy);
-    
 
-	/***************************************************/ 
-	mapset = G_find_cell2(lat, "");
+    /***************************************************/ 
+    mapset = G_find_cell2(lat, "");
     if (mapset == NULL) {
 	G_fatal_error(_("cell file [%s] not found"), lat);
     }
@@ -128,9 +107,8 @@
 	G_fatal_error(_("Cannot read file header of [%s])"), lat);
     inrast_lat = G_allocate_raster_buf(data_type_lat);
     
-
-	/***************************************************/ 
-	mapset = G_find_cell2(lon, "");
+    /***************************************************/ 
+    mapset = G_find_cell2(lon, "");
     if (mapset == NULL) {
 	G_fatal_error(_("cell file [%s] not found"), lon);
     }
@@ -141,9 +119,8 @@
 	G_fatal_error(_("Cannot read file header of [%s])"), lon);
     inrast_lon = G_allocate_raster_buf(data_type_lon);
     
-
-	/***************************************************/ 
-	mapset = G_find_cell2(phi, "");
+    /***************************************************/ 
+    mapset = G_find_cell2(phi, "");
     if (mapset == NULL) {
 	G_fatal_error(_("cell file [%s] not found"), phi);
     }
@@ -154,16 +131,16 @@
 	G_fatal_error(_("Cannot read file header of [%s])"), phi);
     inrast_phi = G_allocate_raster_buf(data_type_phi);
     
-
-	/***************************************************/ 
-	G_debug(3, "number of rows %d", cellhd.rows);
+    /***************************************************/ 
     nrows = G_window_rows();
     ncols = G_window_cols();
-    outrast1 = G_allocate_raster_buf(data_type_output);
-    if ((outfd1 = G_open_raster_new(result1, data_type_output)) < 0)
+
+    outrast1 = G_allocate_d_raster_buf();
+    if ((outfd1 = G_open_raster_new(result1, DCELL_TYPE)) < 0)
 	G_fatal_error(_("Could not open <%s>"), result1);
+
     for (row = 0; row < nrows; row++)
-	 {
+    {
 	DCELL d;
 	DCELL d_frac_year;
 	DCELL d_tc_wa;
@@ -177,60 +154,23 @@
 	DCELL d_doy;
 	DCELL d_phi;
 	G_percent(row, nrows, 2);
-	if (G_get_raster_row(infd_doy, inrast_doy, row, data_type_doy) < 0)
+
+	if (G_get_raster_row(infd_doy, inrast_doy, row, DCELL_TYPE) < 0)
 	    G_fatal_error(_("Could not read from <%s>"), doy);
-	if (G_get_raster_row(infd_lat, inrast_lat, row, data_type_lat) < 0)
+	if (G_get_raster_row(infd_lat, inrast_lat, row, DCELL_TYPE) < 0)
 	    G_fatal_error(_("Could not read from <%s>"), lat);
-	if (G_get_raster_row(infd_lon, inrast_lon, row, data_type_lon) < 0)
+	if (G_get_raster_row(infd_lon, inrast_lon, row, DCELL_TYPE) < 0)
 	    G_fatal_error(_("Could not read from <%s>"), lon);
-	if (G_get_raster_row(infd_phi, inrast_phi, row, data_type_phi) < 0)
+	if (G_get_raster_row(infd_phi, inrast_phi, row, DCELL_TYPE) < 0)
 	    G_fatal_error(_("Could not read from <%s>"), phi);
+
 	for (col = 0; col < ncols; col++)
-	     {
-	    switch (data_type_doy) {
-	    case CELL_TYPE:
-		d_doy = (double)((CELL *) inrast_doy)[col];
-		break;
-	    case FCELL_TYPE:
-		d_doy = (double)((FCELL *) inrast_doy)[col];
-		break;
-	    case DCELL_TYPE:
-		d_doy = ((DCELL *) inrast_doy)[col];
-		break;
-	    }
-	    switch (data_type_lat) {
-	    case CELL_TYPE:
-		d_lat = (double)((CELL *) inrast_lat)[col];
-		break;
-	    case FCELL_TYPE:
-		d_lat = (double)((FCELL *) inrast_lat)[col];
-		break;
-	    case DCELL_TYPE:
-		d_lat = ((DCELL *) inrast_lat)[col];
-		break;
-	    }
-	    switch (data_type_lon) {
-	    case CELL_TYPE:
-		d_lon = (double)((CELL *) inrast_lon)[col];
-		break;
-	    case FCELL_TYPE:
-		d_lon = (double)((FCELL *) inrast_lon)[col];
-		break;
-	    case DCELL_TYPE:
-		d_lon = ((DCELL *) inrast_lon)[col];
-		break;
-	    }
-	    switch (data_type_phi) {
-	    case CELL_TYPE:
-		d_phi = (double)((CELL *) inrast_phi)[col];
-		break;
-	    case FCELL_TYPE:
-		d_phi = (double)((FCELL *) inrast_phi)[col];
-		break;
-	    case DCELL_TYPE:
-		d_phi = ((DCELL *) inrast_phi)[col];
-		break;
-	    }
+        {
+            d_doy = ((DCELL *) inrast_doy)[col];
+            d_lat = ((DCELL *) inrast_lat)[col];
+            d_lon = ((DCELL *) inrast_lon)[col];
+            d_phi = ((DCELL *) inrast_phi)[col];
+
 	    d_frac_year = (360.0 / 365.25) * d_doy;
 	    d_delta =
 		0.396372 - 22.91327 * cos(d_frac_year * PI / 180.0) +
@@ -251,10 +191,10 @@
 	    d_Wa = acos(d_Wa1 / d_Wa2);
 	    d_time = ((d_Wa - (d_lon * PI / 180.0) - d_tc_wa) / 15.0) + 12.0;
 	    outrast1[col] = d_time;
-	    }
-	if (G_put_raster_row(outfd1, outrast1, data_type_output) < 0)
+        }
+	if (G_put_raster_row(outfd1, outrast1, DCELL_TYPE) < 0)
 	    G_fatal_error(_("Cannot write to output raster file"));
-	}
+    }
     G_free(inrast_lat);
     G_free(inrast_lon);
     G_free(inrast_doy);
@@ -265,9 +205,11 @@
     G_close_cell(infd_phi);
     G_free(outrast1);
     G_close_cell(outfd1);
+
     G_short_history(result1, "raster", &history);
     G_command_history(&history);
     G_write_history(result1, &history);
+
     exit(EXIT_SUCCESS);
 }
 



More information about the grass-commit mailing list