Browse Source

v.to.rast: print message if missing attribute values are replaced with 0 (#173)

print message if missing attribute values are replaced with 0 (zero)
Markus Metz 5 years ago
parent
commit
1762dd0b0f
1 changed files with 12 additions and 1 deletions
  1. 12 1
      vector/v.to.rast/vect2rast.c

+ 12 - 1
vector/v.to.rast/vect2rast.c

@@ -14,7 +14,7 @@ int vect_to_rast(const char *vector_map, const char *raster_map, const char *fie
 {
     struct Map_info Map;
     struct line_pnts *Points;
-    int i, field;
+    int i, j, field;
     struct cat_list *cat_list = NULL;
     int fd;			/* for raster map */
     int nareas, nlines;		/* number of converted features */
@@ -82,6 +82,7 @@ int vect_to_rast(const char *vector_map, const char *raster_map, const char *fie
 
 	db_close_database_shutdown_driver(Driver);
 
+	j = 0;
 	for (i = 0; i < cvarr.n_values; i++) {
 	    if (ctype == DB_C_TYPE_INT) {
 		G_debug(3, "cat = %d val = %d", cvarr.value[i].cat,
@@ -91,6 +92,16 @@ int vect_to_rast(const char *vector_map, const char *raster_map, const char *fie
 		G_debug(3, "cat = %d val = %f", cvarr.value[i].cat,
 			cvarr.value[i].val.d);
 	    }
+	    /* check for null values */
+	    if (!cat_list || Vect_cat_in_cat_list(cvarr.value[i].cat, cat_list)) {
+		if (cvarr.value[i].isNull) {
+		    j++;
+		}
+	    }
+	}
+	if (j) {
+	    G_important_message(_("%d of %d records in column <%s> are empty and replaced with 0 (zero)"),
+	                          j, nrec, column);
 	}
 	
 	switch (ctype) {