[GRASS-SVN] r54548 - grass/trunk/raster/r.fill.dir

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Jan 6 05:47:25 PST 2013


Author: martinl
Date: 2013-01-06 05:47:24 -0800 (Sun, 06 Jan 2013)
New Revision: 54548

Modified:
   grass/trunk/raster/r.fill.dir/main.c
Log:
r.fill.dir: copy color table from input for depressionless map


Modified: grass/trunk/raster/r.fill.dir/main.c
===================================================================
--- grass/trunk/raster/r.fill.dir/main.c	2013-01-06 13:23:56 UTC (rev 54547)
+++ grass/trunk/raster/r.fill.dir/main.c	2013-01-06 13:47:24 UTC (rev 54548)
@@ -77,6 +77,7 @@
     void *in_buf;
     CELL *out_buf;
     struct band3 bnd, bndC;
+    struct Colors colors; 
 
     /*  Initialize the GRASS environment variables */
     G_gisinit(argv[0]);
@@ -145,7 +146,9 @@
     
     /* open the maps and get their file id  */
     map_id = Rast_open_old(map_name, "");
-
+    if (Rast_read_colors(map_name, "", &colors) < 0)
+        G_warning(_("Unable to read color table for raster map <%s>"), map_name);
+    
     /* allocate cell buf for the map layer */
     in_type = Rast_get_map_type(map_id);
 
@@ -181,7 +184,7 @@
     fd = open(tempfile2, O_RDWR | O_CREAT, 0666);	/* dirn */
     fm = open(tempfile3, O_RDWR | O_CREAT, 0666);	/* problems */
 
-    G_message(_("Reading elevation map..."));
+    G_message(_("Reading input elevation raste map..."));
     for (i = 0; i < nrows; i++) {
 	G_percent(i, nrows, 2);
 	get_row(map_id, in_buf, i);
@@ -258,10 +261,13 @@
 	Rast_put_row(dir_id, out_buf, CELL_TYPE);
     }
     G_percent(1, 1, 1);
-    
+
+    /* copy color table from input */
+    Rast_write_colors(new_map_name, G_mapset(), &colors);
+
     Rast_close(new_id);
     close(fe);
-
+    
     Rast_close(dir_id);
     close(fd);
 



More information about the grass-commit mailing list