[GRASS-SVN] r42044 - grass/branches/releasebranch_6_4/raster/r.external

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Apr 27 06:36:12 EDT 2010


Author: martinl
Date: 2010-04-27 06:36:11 -0400 (Tue, 27 Apr 2010)
New Revision: 42044

Modified:
   grass/branches/releasebranch_6_4/raster/r.external/Makefile
   grass/branches/releasebranch_6_4/raster/r.external/main.c
Log:
glynn: Create imagery group for multiple bands (bug #1043)
(merge r42035 from trunk)


Modified: grass/branches/releasebranch_6_4/raster/r.external/Makefile
===================================================================
--- grass/branches/releasebranch_6_4/raster/r.external/Makefile	2010-04-27 09:59:46 UTC (rev 42043)
+++ grass/branches/releasebranch_6_4/raster/r.external/Makefile	2010-04-27 10:36:11 UTC (rev 42044)
@@ -2,8 +2,8 @@
 
 PGM  = r.external
 
-LIBES= $(GPROJLIB) $(GISLIB) $(IMAGERYLIB) $(GDALLIBS) $(GMATHLIB)
-DEPENDENCIES = $(GPROJDEP) $(GISDEP) $(IMAGERYDEP) $(GMATHDEP)
+LIBES= $(GPROJLIB) $(GISLIB) $(GDALLIBS) $(GMATHLIB) $(IMAGERYLIB)
+DEPENDENCIES = $(GPROJDEP) $(GISDEP) $(GMATHDEP) $(IMAGERYDEP)
 EXTRA_INC = $(PROJINC) $(GDALCFLAGS)
 
 include $(MODULE_TOPDIR)/include/Make/Module.make

Modified: grass/branches/releasebranch_6_4/raster/r.external/main.c
===================================================================
--- grass/branches/releasebranch_6_4/raster/r.external/main.c	2010-04-27 09:59:46 UTC (rev 42043)
+++ grass/branches/releasebranch_6_4/raster/r.external/main.c	2010-04-27 10:36:11 UTC (rev 42044)
@@ -480,8 +480,6 @@
 	G_put_cell_title(output, title);
 
     G_message(_("<%s> created"), output);
-
-    return;
 }
 
 int main(int argc, char *argv[])
@@ -500,6 +498,7 @@
     struct Flag *flag_o, *flag_f, *flag_e, *flag_r;
     int min_band, max_band, band;
     struct band_info info;
+    struct Ref reference;
 
     G_gisinit(argv[0]);
 
@@ -614,6 +613,12 @@
 
     G_verbose_message(_("Proceeding with import..."));
 
+    if (max_band > min_band) {
+	if (I_find_group(output) == 1)
+	    G_warning(_("Imagery group <%s> already exists and will be overwritten."), output);
+	I_init_group_ref(&reference);
+    }
+
     for (band = min_band; band <= max_band; band++) {
 	char *output2, *title2 = NULL;
 
@@ -627,6 +632,8 @@
 	    G_asprintf(&output2, "%s.%d", output, band);
 	    if (title)
 		G_asprintf(&title2, "%s (band %d)", title, band);
+	    G_debug(1, "Adding raster map <%s> to group <%s>", output2, output);
+	    I_add_file_to_group_ref(output2, G_mapset(), &reference);
 	}
 	else {
 	    output2 = G_store(output);
@@ -644,6 +651,13 @@
     if (flag_e->answer)
 	update_default_window(&cellhd);
 
+    /* Create the imagery group if multiple bands are imported */
+    if (max_band > min_band) {
+    	I_put_group_ref(output, &reference);
+	I_put_group(output);
+	G_message(_("Imagery group <%s> created"), output);
+    }
+
     G_done_msg(" ");
 
     exit(EXIT_SUCCESS);



More information about the grass-commit mailing list