[GRASS-SVN] r52910 - grass/branches/develbranch_6/lib/gis

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Aug 25 08:22:35 PDT 2012


Author: mmetz
Date: 2012-08-25 08:22:35 -0700 (Sat, 25 Aug 2012)
New Revision: 52910

Modified:
   grass/branches/develbranch_6/lib/gis/color_look.c
   grass/branches/develbranch_6/lib/gis/color_write.c
Log:
rasterlib: rephrase comment, fix fp precision

Modified: grass/branches/develbranch_6/lib/gis/color_look.c
===================================================================
--- grass/branches/develbranch_6/lib/gis/color_look.c	2012-08-25 15:21:33 UTC (rev 52909)
+++ grass/branches/develbranch_6/lib/gis/color_look.c	2012-08-25 15:22:35 UTC (rev 52910)
@@ -243,6 +243,7 @@
     int cell_type;
     int lookup, max_ind, min_ind, try;
     int (*lower) ();
+    size_t size = G_raster_size(data_type);
 
     if (mod)
 	cp = &colors->modular;
@@ -283,7 +284,7 @@
 
     for (; n-- > 0;
 	 ptr =
-	 G_incr_void_ptr(ptr, G_raster_size(data_type)), red++, grn++, blu++,
+	 G_incr_void_ptr(ptr, size), red++, grn++, blu++,
 	 *set++ = found) {
 	/* if the cell is the same as last one, use the prev color values */
 	if (ptr != raster && G_raster_cmp(ptr, last_ptr, data_type) == 0) {

Modified: grass/branches/develbranch_6/lib/gis/color_write.c
===================================================================
--- grass/branches/develbranch_6/lib/gis/color_write.c	2012-08-25 15:21:33 UTC (rev 52909)
+++ grass/branches/develbranch_6/lib/gis/color_write.c	2012-08-25 15:22:35 UTC (rev 52910)
@@ -121,7 +121,7 @@
     fprintf(fd, "%% %s %s\n", str1, str2);
 
     if (colors->shift) {
-	sprintf(str2, "%.10f", (double)colors->shift);
+	sprintf(str2, "%.15g", (double)colors->shift);
 	G_trim_decimal(str2);
 	fprintf(fd, "shift:%s\n", str2);
     }
@@ -169,7 +169,7 @@
 	if (rule->low.value == dmin)
 	    format_min(str, (double)rule->low.value);
 	else {
-	    sprintf(str, "%.10f", (double)rule->low.value);
+	    sprintf(str, "%.15g", (double)rule->low.value);
 	    G_trim_decimal(str);
 	}
 	fprintf(fd, "%s:%d", str, (int)rule->low.red);
@@ -180,7 +180,7 @@
 	    if (rule->high.value == dmax)
 		format_max(str, (double)rule->high.value);
 	    else {
-		sprintf(str, "%.10f", (double)rule->high.value);
+		sprintf(str, "%.15g", (double)rule->high.value);
 		G_trim_decimal(str);
 	    }
 	    fprintf(fd, " %s:%d", str, (int)rule->high.red);
@@ -251,7 +251,7 @@
     G_trim_decimal(str);
     sscanf(str, "%lf", &dtmp);
     if (dtmp != dval) {  /* if no zeros after decimal point were trimmed */
-	/* lower dval by fraction of GRASS_EPSILON */
+	/* lower dval by GRASS_EPSILON fraction */
 	if (dval > 0)
 	    sprintf(str, "%.15g", dval * (1 - GRASS_EPSILON));
 	else
@@ -270,7 +270,7 @@
     G_trim_decimal(str);
     sscanf(str, "%lf", &dtmp);
     if (dtmp != dval) {  /* if  no zeros after decimal point were trimmed */
-	/* increase dval by fraction of GRASS_EPSILON */
+	/* increase dval by by GRASS_EPSILON fraction */
 	if (dval > 0)
 	    sprintf(str, "%.15g", dval * (1 + GRASS_EPSILON));
 	else



More information about the grass-commit mailing list