[GRASS-SVN] r41222 - grass/trunk/raster/r.surf.contour
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun Feb 28 08:12:08 EST 2010
Author: martinl
Date: 2010-02-28 08:12:08 -0500 (Sun, 28 Feb 2010)
New Revision: 41222
Modified:
grass/trunk/raster/r.surf.contour/contour.h
grass/trunk/raster/r.surf.contour/main.c
grass/trunk/raster/r.surf.contour/read_cell.c
Log:
r.surf.contour: use standard options (eliminate G_find_raster())
Modified: grass/trunk/raster/r.surf.contour/contour.h
===================================================================
--- grass/trunk/raster/r.surf.contour/contour.h 2010-02-28 13:02:49 UTC (rev 41221)
+++ grass/trunk/raster/r.surf.contour/contour.h 2010-02-28 13:12:08 UTC (rev 41222)
@@ -38,5 +38,5 @@
int find_con(int, int, double *, double *, CELL *, CELL *);
/* read_cell.c */
-CELL **read_cell(const char *, const char *);
+CELL **read_cell(const char *);
void free_cell(CELL **);
Modified: grass/trunk/raster/r.surf.contour/main.c
===================================================================
--- grass/trunk/raster/r.surf.contour/main.c 2010-02-28 13:02:49 UTC (rev 41221)
+++ grass/trunk/raster/r.surf.contour/main.c 2010-02-28 13:12:08 UTC (rev 41222)
@@ -46,7 +46,7 @@
CELL con1, con2;
double d1, d2;
CELL *alt_row;
- const char *con_name, *alt_name, *con_mapset;
+ const char *con_name, *alt_name;
int file_fd;
CELL value;
struct History history;
@@ -62,35 +62,21 @@
module->description =
_("Generates surface raster map from rasterized contours.");
- opt1 = G_define_option();
- opt1->key = "input";
- opt1->type = TYPE_STRING;
- opt1->required = YES;
- opt1->gisprompt = "old,cell,raster";
- opt1->description = _("Name of existing raster map containing contours");
+ opt1 = G_define_standard_option(G_OPT_R_INPUT);
+ opt1->description = _("Name of input raster map containing contours");
- opt2 = G_define_option();
- opt2->key = "output";
- opt2->type = TYPE_STRING;
- opt2->required = YES;
- opt2->gisprompt = "new,cell,raster";
- opt2->description = _("Output elevation raster map");
+ opt2 = G_define_standard_option(G_OPT_R_OUTPUT);
if (G_parser(argc, argv))
exit(EXIT_FAILURE);
-
-
+
con_name = opt1->answer;
alt_name = opt2->answer;
- con_mapset = G_find_raster2(con_name, "");
- if (!con_mapset)
- G_fatal_error("Contour raster map [%s] not found", con_name);
-
nrows = Rast_window_rows();
ncols = Rast_window_cols();
i_val_l_f = nrows + ncols;
- con = read_cell(con_name, con_mapset);
+ con = read_cell(con_name);
alt_row = (CELL *) G_malloc(ncols * sizeof(CELL));
seen = flag_create(nrows, ncols);
mask = flag_create(nrows, ncols);
@@ -129,12 +115,13 @@
}
Rast_put_row(file_fd, alt_row, CELL_TYPE);
}
- G_percent(r, nrows, 1);
+ G_percent(1, 1, 1);
+
free_cell(con);
flag_destroy(seen);
flag_destroy(mask);
Rast_close(file_fd);
-
+
Rast_short_history(alt_name, "raster", &history);
Rast_command_history(&history);
Rast_write_history(alt_name, &history);
Modified: grass/trunk/raster/r.surf.contour/read_cell.c
===================================================================
--- grass/trunk/raster/r.surf.contour/read_cell.c 2010-02-28 13:02:49 UTC (rev 41221)
+++ grass/trunk/raster/r.surf.contour/read_cell.c 2010-02-28 13:12:08 UTC (rev 41222)
@@ -2,7 +2,7 @@
#include <grass/raster.h>
#include <grass/glocale.h>
-CELL **read_cell(const char *name, const char *mapset)
+CELL **read_cell(const char *name)
{
int nrows = Rast_window_rows();
int ncols = Rast_window_cols();
@@ -10,19 +10,19 @@
int fd;
int row;
- fd = Rast_open_old(name, mapset);
-
+ fd = Rast_open_old(name, "");
+
buf = G_malloc((size_t) nrows * ncols * sizeof(CELL));
idx = G_malloc(nrows * sizeof(CELL *));
-
+
for (row = 0; row < nrows; row++) {
idx[row] = &buf[row * ncols];
Rast_get_c_row(fd, idx[row], row);
}
-
+
Rast_close(fd);
-
+
return idx;
}
@@ -31,4 +31,3 @@
G_free(idx[0]);
G_free(idx);
}
-
More information about the grass-commit
mailing list