[GRASS-SVN] r52870 - grass/branches/develbranch_6/vector/v.what.rast

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Aug 24 02:25:24 PDT 2012


Author: mmetz
Date: 2012-08-24 02:25:24 -0700 (Fri, 24 Aug 2012)
New Revision: 52870

Modified:
   grass/branches/develbranch_6/vector/v.what.rast/main.c
Log:
v.what.rast: fix fp precision and message argument

Modified: grass/branches/develbranch_6/vector/v.what.rast/main.c
===================================================================
--- grass/branches/develbranch_6/vector/v.what.rast/main.c	2012-08-24 09:24:44 UTC (rev 52869)
+++ grass/branches/develbranch_6/vector/v.what.rast/main.c	2012-08-24 09:25:24 UTC (rev 52870)
@@ -50,6 +50,7 @@
     RASTER_MAP_TYPE out_type;
     CELL *cell;
     DCELL *dcell;
+    int width;
     double drow, dcol;
     char buf[2000];
     struct Option *vect_opt, *rast_opt, *field_opt, *col_opt, *where_opt;
@@ -142,6 +143,10 @@
 
     out_type = G_get_raster_map_type(fd);
 
+    width = 15;
+    if (out_type == FCELL_TYPE)
+	width = 7;
+
     /* TODO: Later possibly category labels */
     /* 
        if ( G_read_cats (name, mapset, &RCats) < 0 )
@@ -269,12 +274,12 @@
 	    if (out_type == CELL_TYPE) {
 		if (G_get_c_raster_row(fd, cell, cache[point].row) < 0)
 		    G_fatal_error(_("Unable to read raster map <%s> row %d"),
-				  cell, cache[point].row);
+				  rast_opt->answer, cache[point].row);
 	    }
 	    else {
 		if (G_get_d_raster_row(fd, dcell, cache[point].row) < 0)
 		    G_fatal_error(_("Unable to read raster map <%s> row %d"),
-				  dcell, cache[point].row);
+				  rast_opt->answer, cache[point].row);
 	    }
 	}
 	cur_row = cache[point].row;
@@ -334,7 +339,7 @@
 		sprintf(buf, "NULL");
 	    }
 	    else {
-		sprintf(buf, "%.10f", cache[point].dvalue);
+		sprintf(buf, "%.*g", width, cache[point].dvalue);
 	    }
 	}
 	db_append_string(&stmt, buf);



More information about the grass-commit mailing list