瀏覽代碼

v.out.ascii: print warning if no features exported (points)

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@39371 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 15 年之前
父節點
當前提交
b5360a86b2
共有 2 個文件被更改,包括 20 次插入8 次删除
  1. 7 4
      lib/vector/Vlib/ascii.c
  2. 13 4
      vector/v.out.ascii/main.c

+ 7 - 4
lib/vector/Vlib/ascii.c

@@ -263,7 +263,7 @@ int Vect_read_ascii_head(FILE *dascii, struct Map_info *Map)
   \param dascii pointer to the ASCII file
   \param Map    pointer to Map_info structure
 
-  \return 0 on sucess
+  \return number of written features
   \return -1 on error
 */
 int Vect_write_ascii(FILE *ascii,
@@ -271,7 +271,7 @@ int Vect_write_ascii(FILE *ascii,
 		     int format, int dp, char *fs, int region_flag,
 		     int field, char* where, char **columns)
 {
-    int type, ctype, i, cat, proj;
+    int type, ctype, i, cat, proj, n_lines;
     double *xptr, *yptr, *zptr, x, y;
     static struct line_pnts *Points;
     struct line_cats *Cats;
@@ -289,6 +289,7 @@ int Vect_write_ascii(FILE *ascii,
     /* get the region */
     G_get_window(&window);
 
+    n_lines = 0;
     ncats = 0;
     cats = NULL;
     
@@ -347,7 +348,7 @@ int Vect_write_ascii(FILE *ascii,
 		db_close_database(driver);
 		db_shutdown_driver(driver);
 	    }
-	    return 0;
+	    return n_lines;
 	}
 
 	if (format == GV_ASCII_FORMAT_POINT && !(type & GV_POINTS))
@@ -407,7 +408,7 @@ int Vect_write_ascii(FILE *ascii,
 	    break;
 	default:
 	    ctype = 'X';
-	    G_warning(_("got type %d"), (int)type);
+	    G_warning(_("Uknown feature type %d"), (int)type);
 	    break;
 	}
 
@@ -559,9 +560,11 @@ int Vect_write_ascii(FILE *ascii,
 		}
 	    }
 	}
+	n_lines++;
     }
 
     /* not reached */
+    return n_lines;
 }
 
 int srch(const void *pa, const void *pb)

+ 13 - 4
vector/v.out.ascii/main.c

@@ -31,7 +31,7 @@ int main(int argc, char *argv[])
     struct Option *input, *output, *format_opt, *dp_opt, *delim_opt,
 	*field_opt, *column_opt, *where_opt;
     struct Flag *verf, *region_flag;
-    int format, dp, field;
+    int format, dp, field, ret;
     char *fs;
     struct Map_info Map;
     int ver = 5, pnt = 0;
@@ -182,9 +182,18 @@ int main(int argc, char *argv[])
 			  output->answer);
     }
 
-    Vect_write_ascii(ascii, att, &Map, ver, format, dp, fs,
-		     region_flag->answer, field, where_opt->answer,
-		     column_opt->answers);
+    ret = Vect_write_ascii(ascii, att, &Map, ver, format, dp, fs,
+			   region_flag->answer, field, where_opt->answer,
+			   column_opt->answers);
+
+    if (ret < 1) {
+	if (format == GV_ASCII_FORMAT_POINT) {
+	    G_warning(_("No points found, nothing to be exported"));
+	}
+	else {
+	    G_warning(_("No features found, nothing to be exported"));
+	}
+    }
     
     if (ascii != NULL)
 	fclose(ascii);