[GRASS-SVN] r32970 - in grass-addons/gipe: i.latitude i.lmf

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Aug 21 09:32:52 EDT 2008


Author: ychemin
Date: 2008-08-21 09:32:52 -0400 (Thu, 21 Aug 2008)
New Revision: 32970

Modified:
   grass-addons/gipe/i.latitude/main.c
   grass-addons/gipe/i.lmf/fitting.c
   grass-addons/gipe/i.lmf/lmf.c
   grass-addons/gipe/i.lmf/main.c
   grass-addons/gipe/i.lmf/make_matrix.c
Log:
code cleaning, upgrade, standardization

Modified: grass-addons/gipe/i.latitude/main.c
===================================================================
--- grass-addons/gipe/i.latitude/main.c	2008-08-21 13:07:01 UTC (rev 32969)
+++ grass-addons/gipe/i.latitude/main.c	2008-08-21 13:32:52 UTC (rev 32970)
@@ -21,25 +21,25 @@
 
 int main(int argc, char *argv[])
 {
-	struct Cell_head cellhd; //region+header info
-	char *mapset; // mapset name
+	struct Cell_head cellhd; /*region+header info*/
+	char *mapset; /*mapset name*/
 	int nrows, ncols;
 	int row,col;
 
-	int not_ll=0;//if proj is not lat/long, it will be 1.
+	int not_ll=0;/*if proj is not lat/long, it will be 1.*/
 	struct GModule *module;
 	struct Option *input1, *output1;
 	
 	struct Flag *flag1;	
-	struct History history; //metadata
+	struct History history; /*metadata*/
 	
 	struct pj_info iproj;
 	struct pj_info oproj;
 	/************************************/
 	/* FMEO Declarations*****************/
-	char *name;   // input raster name
-	char *result1; //output raster name
-	//File Descriptors
+	char *name;   /*input raster name*/
+	char *result1; /*output raster name*/
+	/*File Descriptors*/
 	int infd;
 	int outfd1;
 	
@@ -52,7 +52,7 @@
 	double latitude, longitude;
 
 	void *inrast;
-	unsigned char *outrast1;
+	DCELL *outrast1;
 	RASTER_MAP_TYPE data_type_output=DCELL_TYPE;
 	RASTER_MAP_TYPE data_type_inrast;
 	/************************************/
@@ -64,15 +64,10 @@
 
 	/* Define the different options */
 	input1 = G_define_standard_option(G_OPT_R_INPUT) ;
-	input1->key	   = _("input");
 	input1->description=_("Name of the input map");
-	input1->answer     =_("input");
 
 	output1 = G_define_standard_option(G_OPT_R_OUTPUT) ;
-	output1->key        =_("latitude");
 	output1->description=_("Name of the output latitude layer");
-	output1->answer     =_("latitude");
-	
 	/********************/
 	if (G_parser(argc, argv))
 		exit (EXIT_FAILURE);
@@ -104,7 +99,7 @@
 	nrows = G_window_rows();
 	ncols = G_window_cols();
 	
-	//Shamelessly stolen from r.sun !!!!	
+	/* Shamelessly stolen from r.sun !!!!	*/
 	/* Set up parameters for projection to lat/long if necessary */
 	if ((G_projection() != PROJECTION_LL)) {
 		not_ll=1;
@@ -123,7 +118,7 @@
 		sprintf(oproj.proj, "ll");
 		if ((oproj.pj = pj_latlong_from_proj(iproj.pj)) == NULL)
 			G_fatal_error(_("Unable to set up lat/long projection parameters"));
-	}//End of stolen from r.sun :P
+	}/* End of stolen from r.sun :P*/
 	
 	outrast1 = G_allocate_raster_buf(data_type_output);
 	if ( (outfd1 = G_open_raster_new (result1,data_type_output)) < 0)
@@ -144,10 +139,10 @@
 				    G_fatal_error(_("Error in pj_do_proj"));
 				}
 			}else{
-				//Do nothing
+				/*Do nothing*/
 			}	
 			d_lat = latitude;
-			((DCELL *) outrast1)[col] = d_lat;
+			outrast1[col] = d_lat;
 		}
 		if (G_put_raster_row (outfd1, outrast1, data_type_output) < 0)
 			G_fatal_error(_("Cannot write to output raster file"));

Modified: grass-addons/gipe/i.lmf/fitting.c
===================================================================
--- grass-addons/gipe/i.lmf/fitting.c	2008-08-21 13:07:01 UTC (rev 32969)
+++ grass-addons/gipe/i.lmf/fitting.c	2008-08-21 13:32:52 UTC (rev 32970)
@@ -18,14 +18,14 @@
 
         nn=nfunc*2+2;
 
-        //Value Initialization
+        /*Value Initialization*/
         for(i=0;i<nn;i++){
                 c[i]=0.0;
         }
         for(i=0;i<npoint;i++){
 		vfit[i]=0.0;
         }
-        //Matrix Initialization
+        /*Matrix Initialization*/
         for(i=0;i<nn;i++){
                 for(j=0;j<nn;j++){
                         tf[i][j]=0.0;
@@ -33,7 +33,7 @@
                 }
                 vec[i]=0.0;
         }
-        //Making Matrix
+        /*Making Matrix*/
         for(i=0;i<npoint;i++){
                 if(idx1[i]==1){
                         for(k1=0;k1<nn;k1++){
@@ -44,7 +44,7 @@
                         }
                 }
         }
-        //Matrix Copy and Inversion
+        /*Matrix Copy and Inversion*/
         for(i=0;i<nn;i++){
                 for(j=i;j<nn;j++){
                         tfij=tf[i][j];
@@ -53,7 +53,7 @@
                 }
         }
         invert_matrix(tinv,nn);
-        //Calculation of Coefficients
+        /*Calculation of Coefficients*/
         for(i=0;i<nn;i++){
                 sum=0.0;
                 for(j=0;j<nn;j++){
@@ -61,7 +61,7 @@
                 }
                 c[i]=sum;
         }
-        //Calculating theoretical value
+        /*Calculating theoretical value*/
         for(i=0;i<npoint;i++){
                 sum=0.0;
                 for(k=0;k<nn;k++){

Modified: grass-addons/gipe/i.lmf/lmf.c
===================================================================
--- grass-addons/gipe/i.lmf/lmf.c	2008-08-21 13:07:01 UTC (rev 32969)
+++ grass-addons/gipe/i.lmf/lmf.c	2008-08-21 13:32:52 UTC (rev 32970)
@@ -32,17 +32,17 @@
         double  tcld,thh,thl;
 	double	vaic,delta;
         int     idx1[NMAX];
-        //for fitting
+        /*for fitting*/
         double  dat[NMAX];
         double  f[NMAX][MAXF],c[MAXF];
         double  vfit[NMAX];
         double  ipoint[MAXB];
-        //for iteration
+        /*for iteration*/
         double  dat0[NMAX],c0[MAXF];
         double  dat1[NMAX];
-        //for Matrix Inversion
+        /*for Matrix Inversion*/
         int     numk[MAXF]={ 1,2,3,4,6,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 };
-        //Set Defaults
+        /*Set Defaults*/
         nfunc=6;
         for(i=0;i<NMAX;i++){
 		for(j=0;j<MAXF;j++){
@@ -52,30 +52,30 @@
         make_matrix(nbands,npoint,nfunc,numk,f);
         nwin=3;
         mmsw=1;
-        //nds=npoint;
+        /*nds=npoint;*/
         nds=2*nfunc+2;
-        //LMF Process
-        //Checking Pixel Value
+        /*LMF Process*/
+        /*Checking Pixel Value*/
         fitsw=1;
-        //fitting method
+        /*fitting method*/
         tcld=0.15;
         fitmd=2;
-        //FITMD0----
+        /*FITMD0----*/
         if(fitmd==0){
                 thh=tcld*2.0;
                 thl=-tcld;
         }
-        //FITMD1----
+        /*FITMD1----*/
         if(fitmd==1){
                thh=tcld;
                thl=-tcld*2.0;
         }
-        //FITMD2----
+        /*FITMD2----*/
         if(fitmd==2){
                 thh=tcld;
                 thl=-tcld;
         }
-        //initialize arrays
+        /*initialize arrays*/
         for(k=0;k<nbands;k++){
                 dat0[k]=0.0;
                 outpix[k]=0.0;
@@ -98,13 +98,13 @@
                 dat0[k]=inpix[k];
                 dat[k]=dat0[k];
          }
-         //Minimax Filter
+         /*Minimax Filter*/
          if(mmsw>=1&&fitmd==0){
                 minmax(nbands,nwin,dat);
          }else if(mmsw>=1&&fitmd==1){
                 maxmin(nbands,nwin,dat);
          }
-         //Fitting
+         /*Fitting*/
          fitting(nbands,3,dat,idx1,f,c,vfit);
          for(k=0;k<nbands;k++){
                 outpix[k]=vfit[k];

Modified: grass-addons/gipe/i.lmf/main.c
===================================================================
--- grass-addons/gipe/i.lmf/main.c	2008-08-21 13:07:01 UTC (rev 32969)
+++ grass-addons/gipe/i.lmf/main.c	2008-08-21 13:32:52 UTC (rev 32970)
@@ -44,20 +44,20 @@
 int
 main(int argc, char *argv[])
 {
-	struct 	Cell_head cellhd;//region+header info
-	char 	*mapset; //mapset name
+	struct 	Cell_head cellhd;/*region+header info*/
+	char 	*mapset; /*mapset name*/
 	int 	nrows, ncols;
 	int 	row,col;
 
 	struct 	GModule *module;
 	struct 	Option *input,*ndate,*output;
 	
-	struct 	History history; //metadata
+	struct 	History history; /*metadata*/
 	/************************************/
 	/* FMEO Declarations*****************/
-	char 	*name; //input raster name
-	char 	*result[MAXFILES]; //output raster name
-	//File Descriptors
+	char 	*name; /*input raster name*/
+	char 	*result[MAXFILES]; /*output raster name*/
+	/*File Descriptors*/
 	int 	nfiles;
 	int 	infd[MAXFILES];
 	int 	outfd[MAXFILES];
@@ -75,10 +75,6 @@
 	RASTER_MAP_TYPE in_data_type[MAXFILES]; /* 0=numbers  1=text */
 	RASTER_MAP_TYPE out_data_type = DCELL_TYPE;
 
-	char	*fileName;
-#define fileNameLe 8
-#define fileNamePosition 3
-
 	int	ndates;
 	double	inpix[MAXFILES]={0.0};
 	double	outpix[MAXFILES]={0.0};
@@ -93,8 +89,7 @@
 
 	/* Define the different options */
 
-	input 		  = G_define_standard_option(G_OPT_R_INPUT) ;
-	input->multiple   = YES;
+	input 		  = G_define_standard_option(G_OPT_R_INPUTS) ;
 	input->description= _("Names of input layers");
 
 	ndate 		  = G_define_option();

Modified: grass-addons/gipe/i.lmf/make_matrix.c
===================================================================
--- grass-addons/gipe/i.lmf/make_matrix.c	2008-08-21 13:07:01 UTC (rev 32969)
+++ grass-addons/gipe/i.lmf/make_matrix.c	2008-08-21 13:32:52 UTC (rev 32970)
@@ -1,7 +1,5 @@
-// Making Triangular Function Matrix/Vector
+/* Making Triangular Function Matrix/Vector*/
 
-// double  f[NMAX][MAXF];
-
 #include<stdio.h>
 #include<stdlib.h>
 #include<math.h>
@@ -17,20 +15,18 @@
         int     i,j,j1,j2;
         double  di,dk;
 	
-//	printf("make_matrix: n=%d\tnpoint=%d\tnfunc=%d\n",n,npoint,nfunc);
         nn=2*nfunc+2;
-//	printf("make_matrix: nn=%d\n",nn);
         eps=1.0;
-        //Set Constants
+        /*Set Constants*/
         vn= (double) npoint;
         angle=2.0*PI/vn;
-        //Matrix Clear
+        /*Matrix Clear*/
         for(i=0;i<n;i++){
                 for(j=0;j<nn;j++){
                         f[i][j]=0.0;
                }
         }
-        //Making Matrix
+        /*Making Matrix*/
         for(i=0;i<n;i++){
                 di= (double) (i+1);
                 for(j=0;j<nfunc;j++){



More information about the grass-commit mailing list