[GRASS-SVN] r39371 - in grass/trunk: lib/vector/Vlib vector/v.out.ascii

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Oct 2 04:21:36 EDT 2009


Author: martinl
Date: 2009-10-02 04:21:35 -0400 (Fri, 02 Oct 2009)
New Revision: 39371

Modified:
   grass/trunk/lib/vector/Vlib/ascii.c
   grass/trunk/vector/v.out.ascii/main.c
Log:
v.out.ascii: print warning if no features exported (points)


Modified: grass/trunk/lib/vector/Vlib/ascii.c
===================================================================
--- grass/trunk/lib/vector/Vlib/ascii.c	2009-10-02 07:22:40 UTC (rev 39370)
+++ grass/trunk/lib/vector/Vlib/ascii.c	2009-10-02 08:21:35 UTC (rev 39371)
@@ -263,7 +263,7 @@
   \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 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 @@
     /* get the region */
     G_get_window(&window);
 
+    n_lines = 0;
     ncats = 0;
     cats = NULL;
     
@@ -347,7 +348,7 @@
 		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 @@
 	    break;
 	default:
 	    ctype = 'X';
-	    G_warning(_("got type %d"), (int)type);
+	    G_warning(_("Uknown feature type %d"), (int)type);
 	    break;
 	}
 
@@ -559,9 +560,11 @@
 		}
 	    }
 	}
+	n_lines++;
     }
 
     /* not reached */
+    return n_lines;
 }
 
 int srch(const void *pa, const void *pb)

Modified: grass/trunk/vector/v.out.ascii/main.c
===================================================================
--- grass/trunk/vector/v.out.ascii/main.c	2009-10-02 07:22:40 UTC (rev 39370)
+++ grass/trunk/vector/v.out.ascii/main.c	2009-10-02 08:21:35 UTC (rev 39371)
@@ -31,7 +31,7 @@
     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 @@
 			  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);



More information about the grass-commit mailing list