[GRASS-SVN] r64243 - grass-addons/grass7/imagery/i.spec.sam

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Jan 19 09:22:35 PST 2015


Author: ychemin
Date: 2015-01-19 09:22:35 -0800 (Mon, 19 Jan 2015)
New Revision: 64243

Modified:
   grass-addons/grass7/imagery/i.spec.sam/global.h
   grass-addons/grass7/imagery/i.spec.sam/main.c
   grass-addons/grass7/imagery/i.spec.sam/open.c
   grass-addons/grass7/imagery/i.spec.sam/spec_angle.c
Log:
update i.spec.sam

Modified: grass-addons/grass7/imagery/i.spec.sam/global.h
===================================================================
--- grass-addons/grass7/imagery/i.spec.sam/global.h	2015-01-19 16:28:50 UTC (rev 64242)
+++ grass-addons/grass7/imagery/i.spec.sam/global.h	2015-01-19 17:22:35 UTC (rev 64243)
@@ -2,33 +2,29 @@
 #include <grass/imagery.h>
 #include "matrix.h"
 
-#ifndef GLOBAL
-#define GLOBAL extern
-#endif
-
 #define MAXFILES 255
 
-GLOBAL MAT *A;
-GLOBAL VEC *b, *Avector;
-GLOBAL int matrixsize;
-GLOBAL float curr_angle;
+extern MAT *A;
+extern VEC *b, *Avector;
+extern int matrixsize;
+extern float curr_angle;
 
-GLOBAL char *group;
-GLOBAL struct Ref Ref;
+extern char *group;
+extern struct Ref Ref;
 
-GLOBAL CELL **cell;
-GLOBAL int *cellfd;
+extern CELL **cell;
+extern int *cellfd;
 
-GLOBAL CELL **result_cell;
-GLOBAL int *resultfd;
+extern CELL **result_cell;
+extern int *resultfd;
 
-GLOBAL CELL **error_cell;
-GLOBAL int  error_fd;
+extern CELL **error_cell;
+extern int  error_fd;
 
-GLOBAL char result_name[80];
-GLOBAL char *result_prefix, *matrixfile;
+extern char result_name[80];
+extern char *result_prefix, *matrixfile;
 
-GLOBAL struct
+extern struct
     {
      struct Flag *quiet;
     } flag;

Modified: grass-addons/grass7/imagery/i.spec.sam/main.c
===================================================================
--- grass-addons/grass7/imagery/i.spec.sam/main.c	2015-01-19 16:28:50 UTC (rev 64242)
+++ grass-addons/grass7/imagery/i.spec.sam/main.c	2015-01-19 17:22:35 UTC (rev 64243)
@@ -15,7 +15,6 @@
  *
  ********************************************************************/
              
-#define GLOBAL
 #include "global.h"
 #include <stdio.h>
 #include <strings.h>
@@ -196,9 +195,9 @@
 	  Rast_close (resultfd[i]);
 	  Rast_unopen(cellfd[i]);
 	  /* make grey scale color table */
-	  sprintf(result_name, "%s.%d", result_prefix, (i+1));	               
+	  /*sprintf(result_name, "%s.%d", result_prefix, (i+1));	               
           sprintf(command, "r.colors map=%s color=grey >/dev/null", result_name);
-          system(command);
+          system(command);*/ /*Commented by Yann*/
           /* write a color table */
 	}
 

Modified: grass-addons/grass7/imagery/i.spec.sam/open.c
===================================================================
--- grass-addons/grass7/imagery/i.spec.sam/open.c	2015-01-19 16:28:50 UTC (rev 64242)
+++ grass-addons/grass7/imagery/i.spec.sam/open.c	2015-01-19 17:22:35 UTC (rev 64243)
@@ -30,20 +30,14 @@
 
     fp=fopen(matrixfile,"r");
     if (fp == NULL)
-    	{
-    	 fprintf(stderr,"ERROR: Matrixfile %s not found.\n",matrixfile);
-    	 exit(1);
-    	}
+    	G_fatal_error("ERROR: Matrixfile %s not found.\n",matrixfile);
     A = m_finput(fp, MNULL);
     fclose (fp);
     if ( A->m < A->n )
-    {
-	fprintf(stderr, "Need m (rows) >= n (cols) to obtain least squares fit\n");
-	exit(1);
-    }
+	G_fatal_error("Need m (rows) >= n (cols) to obtain least squares fit\n");
     if (!flag.quiet->answer)
     {
-	fprintf(stderr, "Your spectral matrix = ");
+	G_message("Your spectral matrix = ");
 	m_output(A);
     }
     matrixsize = A->n;
@@ -51,26 +45,24 @@
 /* open input files from group */
     if (!I_find_group(group))
     {
-	fprintf (stderr, "group=%s - not found\n", group);
+	G_message("group=%s - not found\n", group);
 	exit(1);
     }
     I_get_group_ref(group, &Ref);
     if (Ref.nfiles <= 1)
     {
-	fprintf (stderr, "Group %s\n", group);
+	G_message("Group %s\n", group);
 	if (Ref.nfiles <= 0)
-	    fprintf (stderr, "doesn't have any files\n");
+	    G_message("doesn't have any files\n");
 	else
-	    fprintf (stderr, "only has 1 file\n");
-	fprintf (stderr, "The group must have at least 2 files\n");
-	exit(1);
+	    G_message("only has 1 file\n");
+	G_fatal_error("The group must have at least 2 files\n");
     }
    /* Error check: input file number must be equal to matrix size */
     if (Ref.nfiles != matrixsize) 
     {
-	fprintf (stderr, "Error: Number of %i input files in group <%s>\n", Ref.nfiles, group);
- 	fprintf (stderr, "       does not match matrix size (%i cols).\n", A->n);
-	exit(1);
+	G_message("Error: Number of %i input files in group <%s>\n", Ref.nfiles, group);
+ 	G_fatal_error("       does not match matrix size (%i cols).\n", A->n);
     }
 
    /* get memory for input files */
@@ -82,12 +74,9 @@
 	name = Ref.file[i].name;
 	mapset = Ref.file[i].mapset;
 	if (!flag.quiet->answer)
-		fprintf (stderr,"Opening input file no. %i [%s]\n", (i+1), name);
+	    G_message("Opening input file no. %i [%s]\n", (i+1), name);
 	if ((cellfd[i] = Rast_open_old (name, mapset)) < 0)
-	{
-	    fprintf (stderr, "Unable to proceed\n");
-	    exit(1);
-	}
+	    G_fatal_error("Unable to proceed\n");
     }
 
   /* open files for results*/
@@ -97,13 +86,9 @@
     {
 	 sprintf(result_name, "%s.%d", result_prefix, (i+1));
 	 if (!flag.quiet->answer)
-		fprintf (stderr,"Opening output file [%s]\n", result_name);	 
+		G_message("Opening output file [%s]\n", result_name);	 
 	 result_cell[i] = Rast_allocate_c_buf();
-	 if ((resultfd[i] = Rast_open_c_new (result_name)) <0)
-	 {	 
-	 	fprintf (stderr, "Unable to proceed\n");
-		exit(1) ;
-	 }
+	 resultfd[i] = Rast_open_c_new (result_name)
     }
 
 

Modified: grass-addons/grass7/imagery/i.spec.sam/spec_angle.c
===================================================================
--- grass-addons/grass7/imagery/i.spec.sam/spec_angle.c	2015-01-19 16:28:50 UTC (rev 64242)
+++ grass-addons/grass7/imagery/i.spec.sam/spec_angle.c	2015-01-19 17:22:35 UTC (rev 64243)
@@ -15,7 +15,7 @@
  *       ISBN 0 7315 1900 0
  *****/
 
-#define GLOBAL
+
 #define MY_PI 3.141592653589793
 
 #include <stdio.h>
@@ -42,7 +42,7 @@
 
 
   VEC *vtmp1;
-      double norm1, norm2, norm3;
+  double norm1, norm2, norm3;
         
   /* Measure spectral angle*/
 



More information about the grass-commit mailing list