[GRASS-SVN] r31831 - in grass/trunk/imagery: i.gensig i.gensigset
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Jun 23 13:35:57 EDT 2008
Author: glynn
Date: 2008-06-23 13:35:57 -0400 (Mon, 23 Jun 2008)
New Revision: 31831
Removed:
grass/trunk/imagery/i.gensig/opencell.c
grass/trunk/imagery/i.gensigset/DIR
grass/trunk/imagery/i.gensigset/opencell.c
Modified:
grass/trunk/imagery/i.gensig/covariance.c
grass/trunk/imagery/i.gensig/files.h
grass/trunk/imagery/i.gensig/local_proto.h
grass/trunk/imagery/i.gensig/means.c
grass/trunk/imagery/i.gensig/openfiles.c
grass/trunk/imagery/i.gensigset/files.h
grass/trunk/imagery/i.gensigset/local_proto.h
grass/trunk/imagery/i.gensigset/openfiles.c
grass/trunk/imagery/i.gensigset/read_data.c
Log:
Convert i.gensig[set] to FP
Modified: grass/trunk/imagery/i.gensig/covariance.c
===================================================================
--- grass/trunk/imagery/i.gensig/covariance.c 2008-06-23 17:24:41 UTC (rev 31830)
+++ grass/trunk/imagery/i.gensig/covariance.c 2008-06-23 17:35:57 UTC (rev 31831)
@@ -12,7 +12,8 @@
int n;
int b,b1,b2;
int nrows, ncols, row, col;
- CELL *class, *cell1, *cell2;
+ CELL *class;
+ DCELL *cell1, *cell2;
for (n = 0; n < S->nsigs; n++) /* for each signature (aka class) */
for (b1 = 0; b1 < S->nbands; b1++)
@@ -33,7 +34,7 @@
G_percent (row, nrows, 2);
read_training_map (class, row, ncols, files);
for (b = 0; b < files->nbands; b++) /* NOTE: files->nbands == S->nbands */
- if (G_get_c_raster_row (files->band_fd[b], files->band_cell[b], row) < 0) exit(1);
+ if (G_get_d_raster_row (files->band_fd[b], files->band_cell[b], row) < 0) exit(1);
for (b1 = 0; b1 < files->nbands; b1++)
{
cell1 = files->band_cell[b1];
Modified: grass/trunk/imagery/i.gensig/files.h
===================================================================
--- grass/trunk/imagery/i.gensig/files.h 2008-06-23 17:24:41 UTC (rev 31830)
+++ grass/trunk/imagery/i.gensig/files.h 2008-06-23 17:35:57 UTC (rev 31831)
@@ -7,7 +7,7 @@
struct Categories training_labels;
int *band_fd;
- CELL **band_cell;
+ DCELL **band_cell;
int nbands;
};
int closefiles(struct files *);
Modified: grass/trunk/imagery/i.gensig/local_proto.h
===================================================================
--- grass/trunk/imagery/i.gensig/local_proto.h 2008-06-23 17:24:41 UTC (rev 31830)
+++ grass/trunk/imagery/i.gensig/local_proto.h 2008-06-23 17:35:57 UTC (rev 31831)
@@ -13,5 +13,3 @@
int tred2(double **, int, double [], double []);
/* lookup_class.c */
int lookup_class(CELL *, int, CELL *, int, CELL *);
-/* opencell.c */
-CELL *open_cell(char *, char *, int *);
Modified: grass/trunk/imagery/i.gensig/means.c
===================================================================
--- grass/trunk/imagery/i.gensig/means.c 2008-06-23 17:24:41 UTC (rev 31830)
+++ grass/trunk/imagery/i.gensig/means.c 2008-06-23 17:35:57 UTC (rev 31831)
@@ -11,7 +11,8 @@
int n, n_nulls;
int b;
int nrows, ncols, row, col;
- CELL *class, *cell;
+ CELL *class;
+ DCELL *cell;
for (n = 0; n < S->nsigs; n++) /* for each signature (aka class) */
for (b = 0; b < S->nbands; b++) /* for each band file */
@@ -32,10 +33,11 @@
read_training_map (class, row, ncols, files);
for (b = 0; b < files->nbands; b++) /* NOTE: files->nbands == S->nbands */
{
- if (G_get_c_raster_row (files->band_fd[b], cell = files->band_cell[b], row) < 0) exit(1);
+ if (G_get_d_raster_row (files->band_fd[b], cell = files->band_cell[b], row) < 0)
+ exit(1);
for (col = 0; col < ncols; col++)
{
- if(G_is_c_null_value(&cell[col]))
+ if(G_is_d_null_value(&cell[col]))
{
n_nulls++;
continue;
Deleted: grass/trunk/imagery/i.gensig/opencell.c
===================================================================
--- grass/trunk/imagery/i.gensig/opencell.c 2008-06-23 17:24:41 UTC (rev 31830)
+++ grass/trunk/imagery/i.gensig/opencell.c 2008-06-23 17:35:57 UTC (rev 31831)
@@ -1,15 +0,0 @@
-#include <stdlib.h>
-#include <grass/gis.h>
-#include <grass/glocale.h>
-
-
-CELL *
-open_cell (char *name, char *mapset, int *fd)
-{
- if (mapset == NULL) mapset = G_find_cell (name, "");
- *fd = G_open_cell_old (name, mapset);
- if (*fd < 0)
- G_fatal_error(_("Unable to open raster map <%s>"), name);
-
- return G_allocate_cell_buf();
-}
Modified: grass/trunk/imagery/i.gensig/openfiles.c
===================================================================
--- grass/trunk/imagery/i.gensig/openfiles.c 2008-06-23 17:24:41 UTC (rev 31830)
+++ grass/trunk/imagery/i.gensig/openfiles.c 2008-06-23 17:35:57 UTC (rev 31831)
@@ -9,7 +9,7 @@
openfiles (struct parms *parms, struct files *files)
{
struct Ref Ref; /* subgroup reference list */
- CELL *open_cell(); /* opens existing rastermaps and returns fd and allocated io buffer */
+ char *mapset;
int n;
@@ -24,14 +24,23 @@
/* allocate file descriptors, and array of io buffers */
files->nbands = Ref.nfiles;
files->band_fd = (int *) G_calloc (Ref.nfiles, sizeof(int));
- files->band_cell = (CELL **) G_calloc (Ref.nfiles, sizeof(CELL *));
+ files->band_cell = (DCELL **) G_calloc (Ref.nfiles, sizeof(DCELL *));
+ /* open training map for reading */
+ mapset = G_find_cell2(parms->training_map, "");
+ files->train_fd = G_open_cell_old(parms->training_map, mapset);
+ if (files->train_fd < 0)
+ G_fatal_error(_("Unable to open training map <%s>"), parms->training_map);
+ files->train_cell = G_allocate_c_raster_buf();
+
/* open all maps for reading */
- files->train_cell = open_cell (parms->training_map, NULL, &files->train_fd);
for (n = 0; n < Ref.nfiles; n++)
- files->band_cell[n] =
- open_cell (Ref.file[n].name, Ref.file[n].mapset,
- &files->band_fd[n]);
+ {
+ files->band_fd[n] = G_open_cell_old(Ref.file[n].name, Ref.file[n].mapset);
+ if (files->band_fd[n] < 0)
+ G_fatal_error(_("Unable to open training map <%s in %s>"), Ref.file[n].name, Ref.file[n].mapset);
+ files->band_cell[n] = G_allocate_d_raster_buf();
+ }
return 0;
}
Deleted: grass/trunk/imagery/i.gensigset/DIR
===================================================================
--- grass/trunk/imagery/i.gensigset/DIR 2008-06-23 17:24:41 UTC (rev 31830)
+++ grass/trunk/imagery/i.gensigset/DIR 2008-06-23 17:35:57 UTC (rev 31831)
@@ -1 +0,0 @@
-imagery/i.gensigset/cmd
Modified: grass/trunk/imagery/i.gensigset/files.h
===================================================================
--- grass/trunk/imagery/i.gensigset/files.h 2008-06-23 17:24:41 UTC (rev 31830)
+++ grass/trunk/imagery/i.gensigset/files.h 2008-06-23 17:35:57 UTC (rev 31831)
@@ -9,7 +9,7 @@
struct Categories training_labels;
int *band_fd;
- CELL **band_cell;
+ DCELL **band_cell;
int nbands;
};
Modified: grass/trunk/imagery/i.gensigset/local_proto.h
===================================================================
--- grass/trunk/imagery/i.gensigset/local_proto.h 2008-06-23 17:24:41 UTC (rev 31830)
+++ grass/trunk/imagery/i.gensigset/local_proto.h 2008-06-23 17:35:57 UTC (rev 31831)
@@ -2,7 +2,5 @@
int invert(double **, int, double *, int *, double **, double *);
/* lookup_class.c */
int lookup_class(CELL *, int, CELL *, int, CELL *);
-/* opencell.c */
-CELL *open_cell(char *, char *, int *);
/* subcluster.c */
void subcluster(struct SigSet *, int, int *, int);
Deleted: grass/trunk/imagery/i.gensigset/opencell.c
===================================================================
--- grass/trunk/imagery/i.gensigset/opencell.c 2008-06-23 17:24:41 UTC (rev 31830)
+++ grass/trunk/imagery/i.gensigset/opencell.c 2008-06-23 17:35:57 UTC (rev 31831)
@@ -1,14 +0,0 @@
-#include <stdlib.h>
-#include <grass/gis.h>
-
-CELL *
-open_cell (char *name, char *mapset, int *fd)
-{
- if (mapset == NULL) mapset = G_find_cell (name, "");
- *fd = G_open_cell_old (name, mapset);
- if (*fd >= 0)
- return G_allocate_cell_buf();
-
- fprintf (stderr, "ERROR: unable to open raster map [%s]\n", name);
- exit(1);
-}
Modified: grass/trunk/imagery/i.gensigset/openfiles.c
===================================================================
--- grass/trunk/imagery/i.gensigset/openfiles.c 2008-06-23 17:24:41 UTC (rev 31830)
+++ grass/trunk/imagery/i.gensigset/openfiles.c 2008-06-23 17:35:57 UTC (rev 31831)
@@ -1,12 +1,13 @@
#include <stdlib.h>
#include <grass/imagery.h>
+#include <grass/glocale.h>
#include "files.h"
#include "parms.h"
int openfiles (struct parms *parms, struct files *files)
{
struct Ref Ref; /* subgroup reference list */
- CELL *open_cell(); /* opens existing rastermaps and returns fd and allocated io buffer */
+ char *mapset;
int n;
@@ -27,12 +28,23 @@
/* allocate file descriptors, and array of io buffers */
files->nbands = Ref.nfiles;
files->band_fd = (int *) G_calloc (Ref.nfiles, sizeof(int));
- files->band_cell = (CELL **) G_calloc (Ref.nfiles, sizeof(CELL *));
+ files->band_cell = (DCELL **) G_calloc (Ref.nfiles, sizeof(DCELL *));
+ /* open training map for reading */
+ mapset = G_find_cell2(parms->training_map, "");
+ files->train_fd = G_open_cell_old(parms->training_map, mapset);
+ if (files->train_fd < 0)
+ G_fatal_error(_("Unable to open training map <%s>"), parms->training_map);
+ files->train_cell = G_allocate_c_raster_buf();
+
/* open all maps for reading */
- files->train_cell = open_cell (parms->training_map, NULL, &files->train_fd);
for (n = 0; n < Ref.nfiles; n++)
- files->band_cell[n] = open_cell (Ref.file[n].name, Ref.file[n].mapset, &files->band_fd[n]);
+ {
+ files->band_fd[n] = G_open_cell_old(Ref.file[n].name, Ref.file[n].mapset);
+ if (files->band_fd[n] < 0)
+ G_fatal_error(_("Unable to open training map <%s in %s>"), Ref.file[n].name, Ref.file[n].mapset);
+ files->band_cell[n] = G_allocate_d_raster_buf();
+ }
return 0;
}
Modified: grass/trunk/imagery/i.gensigset/read_data.c
===================================================================
--- grass/trunk/imagery/i.gensigset/read_data.c 2008-06-23 17:24:41 UTC (rev 31830)
+++ grass/trunk/imagery/i.gensigset/read_data.c 2008-06-23 17:35:57 UTC (rev 31831)
@@ -22,7 +22,8 @@
G_percent (row, nrows, 2);
read_training_map (class, row, ncols, files);
for (b = 0; b < files->nbands; b++)
- if (G_get_c_raster_row (files->band_fd[b], files->band_cell[b], row) < 0) exit(1);
+ if (G_get_d_raster_row (files->band_fd[b], files->band_cell[b], row) < 0)
+ exit(1);
for (col = 0; col < ncols; col++)
{
@@ -31,10 +32,10 @@
Data = &S->ClassSig[n].ClassData;
for (b = 0; b < files->nbands; b++)
{
- if(G_is_c_null_value(&files->band_cell[b][col]))
+ if(G_is_d_null_value(&files->band_cell[b][col]))
G_set_d_null_value(&Data->x[Data->count][b], 1);
else
- Data->x[Data->count][b] = (double) files->band_cell[b][col];
+ Data->x[Data->count][b] = files->band_cell[b][col];
}
Data->count++;
}
More information about the grass-commit
mailing list