Procházet zdrojové kódy

v.to.rast: be more verbose (percentage information)
(merge from relbr64, https://trac.osgeo.org/grass/changeset/35364)


git-svn-id: https://svn.osgeo.org/grass/grass/trunk@35366 15284696-431f-4ddb-bdfa-cd5b030d7da7

Martin Landa před 16 roky
rodič
revize
547200e6a2

+ 4 - 1
vector/v.to.rast/do_areas.c

@@ -30,9 +30,11 @@ int do_areas(struct Map_info *Map, struct line_pnts *Points,
     if (nareas <= 0)
 	return 0;
 
+    G_message(_("Reading areas..."));
     for (i = 0; i < nareas; i++) {
 	/* Note: in old version (grass5.0) there was a check here if the current area 
 	 *        is identical to previous one. I don't see any reason for this in topological vectors */
+	G_percent(i, nareas, 2);
 	cat = list[i].cat;
 	G_debug(3, "Area cat = %d", cat);
 
@@ -79,7 +81,8 @@ int do_areas(struct Map_info *Map, struct line_pnts *Points,
 
 	G_plot_polygon(Points->x, Points->y, Points->n_points);
     }
-
+    G_percent(1, 1, 1);
+    
     return nareas;
 }
 

+ 2 - 0
vector/v.to.rast/do_lines.c

@@ -32,7 +32,9 @@ int do_lines(struct Map_info *Map, struct line_pnts *Points,
     count = 0;
     *count_all = 0;
 
+    G_message(_("Reading features..."));
     for (index = 1; index <= nlines; index++) {
+	G_percent(index, nlines, 2);
 	type = Vect_read_line(Map, Points, Cats, index);
 	Vect_cat_get(Cats, field, &cat);
 

+ 9 - 6
vector/v.to.rast/main.c

@@ -8,7 +8,7 @@
  *               Brad Douglas <rez touchofmadness.com>, Glynn Clements <glynn gclements.plus.com>,
  *               Hamish Bowman <hamish_nospam yahoo.com>, Markus Neteler <neteler itc.it>
  * PURPOSE:      
- * COPYRIGHT:    (C) 2003-2006 by the GRASS Development Team
+ * COPYRIGHT:    (C) 2003-2009 by the GRASS Development Team
  *
  *               This program is free software under the GNU General Public
  *               License (>=v2). Read the file COPYING that comes with GRASS
@@ -37,8 +37,8 @@ int main(int argc, char *argv[])
 
     module = G_define_module();
     module->keywords = _("vector, raster, conversion");
-    module->description = _("Converts a binary GRASS vector map layer "
-			    "into a GRASS raster map layer.");
+    module->description = _("Converts a binary GRASS vector map "
+			    "into a GRASS raster map .");
 
     input = G_define_standard_option(G_OPT_V_INPUT);
     output = G_define_standard_option(G_OPT_R_OUTPUT);
@@ -136,7 +136,10 @@ int main(int argc, char *argv[])
     value = atof(val_opt->answer);
     value_type = (strchr(val_opt->answer, '.')) ? USE_DCELL : USE_CELL;
 
-    return vect_to_rast(input->answer, output->answer, field,
-			col->answer, nrows, use, value, value_type,
-			rgbcol_opt->answer, label_opt->answer, type);
+    if (vect_to_rast(input->answer, output->answer, field,
+		     col->answer, nrows, use, value, value_type,
+		     rgbcol_opt->answer, label_opt->answer, type))
+      exit(EXIT_FAILURE);
+   
+    exit(EXIT_SUCCESS);
 }

+ 3 - 1
vector/v.to.rast/raster.c

@@ -137,6 +137,7 @@ int output_raster(int fd)
     int i;
 
     for (i = 0; i < page.rows; i++, at_row++) {
+	G_percent(i, page.rows, 2);
 	switch (format) {
 	case USE_CELL:
 	    cell = raster.cell[i];
@@ -156,7 +157,8 @@ int output_raster(int fd)
 	    break;
 	}
     }
-
+    G_percent(1, 1, 1);
+    
     return configure_plot();
 }
 

+ 8 - 6
vector/v.to.rast/vect2rast.c

@@ -33,7 +33,7 @@ int vect_to_rast(const char *vector_map, const char *raster_map, int field,
 
     nareas = 0;
 
-    G_debug(1, "Loading vector information...");
+    G_message(_("Loading data..."));
     Vect_set_open_level(2);
     Vect_open_old(&Map, vector_map, "");
 
@@ -176,10 +176,7 @@ int vect_to_rast(const char *vector_map, const char *raster_map, int field,
 	    }
 	}
 
-	G_message(_("Converted areas: %d of %d"), nareas, nareas_all);
-	G_message(_("Converted points/lines: %d of %d"), nlines, nplines_all);
-
-	G_debug(1, "Writing raster map ...");
+	G_message(_("Writing raster map..."));
 
 	stat = output_raster(fd);
     } while (stat == 0);
@@ -196,7 +193,7 @@ int vect_to_rast(const char *vector_map, const char *raster_map, int field,
 
     Vect_close(&Map);
 
-    G_debug(1, "Creating support files for raster map...");
+    G_verbose_message(_("Creating support files for raster map..."));
     G_close_cell(fd);
     update_hist(raster_map, vector_map, Map.head.orig_scale);
 
@@ -221,5 +218,10 @@ int vect_to_rast(const char *vector_map, const char *raster_map, int field,
     update_labels(raster_map, vector_map, field, labelcolumn, use, value,
 		  column);
 
+    G_message(_("Converted areas: %d of %d"), nareas, nareas_all);
+    G_message(_("Converted points/lines: %d of %d"), nlines, nplines_all);
+    
+    G_done_msg(" ");
+    
     return 0;
 }