[GRASS-SVN] r54277 - grass/trunk/raster/r.out.gdal

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Dec 13 16:02:34 PST 2012


Author: mmetz
Date: 2012-12-13 16:02:34 -0800 (Thu, 13 Dec 2012)
New Revision: 54277

Modified:
   grass/trunk/raster/r.out.gdal/Makefile
   grass/trunk/raster/r.out.gdal/export_band.c
   grass/trunk/raster/r.out.gdal/local_proto.h
   grass/trunk/raster/r.out.gdal/main.c
Log:
r.out.gdal: code clean up, add GRASS version to metadata

Modified: grass/trunk/raster/r.out.gdal/Makefile
===================================================================
--- grass/trunk/raster/r.out.gdal/Makefile	2012-12-13 23:49:37 UTC (rev 54276)
+++ grass/trunk/raster/r.out.gdal/Makefile	2012-12-14 00:02:34 UTC (rev 54277)
@@ -5,6 +5,7 @@
 LIBES = $(GPROJLIB) $(IMAGERYLIB) $(DBMILIB) $(RASTERLIB) $(GISLIB) $(GDALLIBS) $(MATHLIB)
 DEPENDENCIES = $(GPROJDEP) $(IMAGERYDEP) $(DBMIDEP) $(RASTERDEP) $(GISDEP)
 EXTRA_INC = $(PROJINC) $(GDALCFLAGS)
+EXTRA_CFLAGS = -DGRASS_VERSION_NUMBER=\"'$(GRASS_VERSION_NUMBER)'\" \
 
 include $(MODULE_TOPDIR)/include/Make/Module.make
 

Modified: grass/trunk/raster/r.out.gdal/export_band.c
===================================================================
--- grass/trunk/raster/r.out.gdal/export_band.c	2012-12-13 23:49:37 UTC (rev 54276)
+++ grass/trunk/raster/r.out.gdal/export_band.c	2012-12-14 00:02:34 UTC (rev 54277)
@@ -35,10 +35,8 @@
 		double nodataval, const char *nodatakey,
 		int default_nodataval)
 {
-    int bHaveMinMax;
     double dfCellMin;
     double dfCellMax;
-    struct FPRange sRange;
     int fd;
     int cols = cellhead->cols;
     int rows = cellhead->rows;
@@ -47,15 +45,6 @@
     /* Open GRASS raster */
     fd = Rast_open_old(name, mapset);
 
-    /* Get min/max values. */
-    if (Rast_read_fp_range(name, mapset, &sRange) == -1) {
-	bHaveMinMax = FALSE;
-    }
-    else {
-	bHaveMinMax = TRUE;
-	Rast_get_fp_range_min_max(&sRange, &dfCellMin, &dfCellMax);
-    }
-
     /* Create GRASS raster buffer */
     void *bufer = Rast_allocate_buf(maptype);
 
@@ -207,11 +196,10 @@
  * returns 0 on success
  * -1 on raster data read/write error
  * */
-int export_band(GDALDatasetH hMEMDS, GDALDataType export_datatype, int band,
+int export_band(GDALDatasetH hMEMDS, int band,
 		const char *name, const char *mapset,
 		struct Cell_head *cellhead, RASTER_MAP_TYPE maptype,
-		double nodataval, const char *nodatakey,
-		int suppress_main_colortable, int default_nodataval)
+		double nodataval, int suppress_main_colortable)
 {
     struct Colors sGrassColors;
     GDALColorTableH hCT;
@@ -224,6 +212,7 @@
     int cols = cellhead->cols;
     int rows = cellhead->rows;
     int ret = 0;
+    char value[200];
 
     /* Open GRASS raster */
     fd = Rast_open_old(name, mapset);
@@ -249,12 +238,15 @@
     CPLPushErrorHandler(CPLQuietErrorHandler);
     GDALSetRasterColorInterpretation(hBand, GPI_RGB);
     CPLPopErrorHandler();
+    
+    sprintf(value, "GRASS %s", GRASS_VERSION_NUMBER);
+    GDALSetMetadataItem(hBand, "Generated_with", value, NULL);
 
     /* use default color rules if no color rules are given */
     if (Rast_read_colors(name, mapset, &sGrassColors) >= 0) {
 	int maxcolor, i;
 	CELL min, max;
-	char key[200], value[200];
+	char key[200];
 	int rcount;
 
 	Rast_get_c_color_range(&min, &max, &sGrassColors);

Modified: grass/trunk/raster/r.out.gdal/local_proto.h
===================================================================
--- grass/trunk/raster/r.out.gdal/local_proto.h	2012-12-13 23:49:37 UTC (rev 54276)
+++ grass/trunk/raster/r.out.gdal/local_proto.h	2012-12-14 00:02:34 UTC (rev 54277)
@@ -54,9 +54,9 @@
 #define GRASS_MAX_COLORS TYPE_UINT16_MAX    /* ok? */
 
 /* export_band.c */
-int export_band(GDALDatasetH, GDALDataType, int, const char *, 
+int export_band(GDALDatasetH, int, const char *, 
 		const char *, struct Cell_head *, RASTER_MAP_TYPE, 
-		double, const char *, int, int);
+		double, int);
 int exact_checks(GDALDataType, const char *, const char *,
                  struct Cell_head *, RASTER_MAP_TYPE, double,
 		 const char *, int);

Modified: grass/trunk/raster/r.out.gdal/main.c
===================================================================
--- grass/trunk/raster/r.out.gdal/main.c	2012-12-13 23:49:37 UTC (rev 54276)
+++ grass/trunk/raster/r.out.gdal/main.c	2012-12-14 00:02:34 UTC (rev 54277)
@@ -119,7 +119,7 @@
     double dfCellMin, export_min;
     double dfCellMax, export_max;
     struct FPRange sRange;
-    int retval = 0, check_range;
+    int retval = 0;
 
     G_gisinit(argv[0]);
 
@@ -340,7 +340,6 @@
     /* get min/max values */
     int band;
 
-    check_range = 0;
     bHaveMinMax = TRUE;
     export_min = TYPE_FLOAT64_MIN;
     export_max = TYPE_FLOAT64_MAX;
@@ -560,7 +559,7 @@
 	G_warning(_("Unable to set geo transform"));
 
     /* Set Projection  */
-    CPLErr ret;
+    CPLErr ret = CE_None;
 
     if (srswkt)
 	ret = GDALSetProjection(hCurrDS, srswkt);
@@ -581,9 +580,9 @@
 	}
 
 	retval = export_band
-	    (hCurrDS, datatype, band + 1, ref.file[band].name,
+	    (hCurrDS, band + 1, ref.file[band].name,
 	     ref.file[band].mapset, &cellhead, maptype, nodataval,
-	     nodataopt->key, flag_c->answer, default_nodataval);
+	     flag_c->answer);
 
 	/* read/write error */
 	if (retval == -1) {



More information about the grass-commit mailing list