[GRASS-SVN] r39264 - grass/branches/develbranch_6/vector/v.in.ascii

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Sep 20 00:56:26 EDT 2009


Author: hamish
Date: 2009-09-20 00:56:25 -0400 (Sun, 20 Sep 2009)
New Revision: 39264

Modified:
   grass/branches/develbranch_6/vector/v.in.ascii/in.c
   grass/branches/develbranch_6/vector/v.in.ascii/points.c
Log:
don't guess column type for missing values (patch from MarkusM, trac #198)

Modified: grass/branches/develbranch_6/vector/v.in.ascii/in.c
===================================================================
--- grass/branches/develbranch_6/vector/v.in.ascii/in.c	2009-09-20 00:31:48 UTC (rev 39263)
+++ grass/branches/develbranch_6/vector/v.in.ascii/in.c	2009-09-20 04:56:25 UTC (rev 39264)
@@ -189,7 +189,7 @@
 
     /* specifying zcol= implies that a 3D map is needed */
     if (zcol >= 0 && !zcoorf->answer)
-	zcoorf->answer = 1;
+	zcoorf->answer = TRUE;
 
     if (zcoorf->answer && format == FORMAT_POINT && zcol < 0)
 	G_fatal_error(_("Please specify reasonable z column"));
@@ -338,7 +338,7 @@
 
 		switch (coltype[i]) {
 		case DB_C_TYPE_INT:
-		    G_verbose_message("Column: %d  type: integer", i + 1);
+		    G_message("Column: %d  type: integer", i + 1);
 		    if (!columns_opt->answer) {
 			sprintf(buf, "int_%d integer", n_int + 1);
 			db_append_string(&sql, buf);
@@ -350,7 +350,7 @@
 		    n_int++;
 		    break;
 		case DB_C_TYPE_DOUBLE:
-		    G_verbose_message("Column: %d  type: double", i + 1);
+		    G_message("Column: %d  type: double", i + 1);
 		    if (!columns_opt->answer) {
 			sprintf(buf, "dbl_%d double precision", n_double + 1);
 			db_append_string(&sql, buf);
@@ -358,7 +358,7 @@
 		    n_double++;
 		    break;
 		case DB_C_TYPE_STRING:
-		    G_verbose_message("Column: %d  type: string length: %d",
+		    G_message("Column: %d  type: string length: %d",
 				      i + 1, collen[i]);
 		    if (!columns_opt->answer) {
 			sprintf(buf, "str_%d varchar(%d)", n_string + 1,

Modified: grass/branches/develbranch_6/vector/v.in.ascii/points.c
===================================================================
--- grass/branches/develbranch_6/vector/v.in.ascii/points.c	2009-09-20 00:31:48 UTC (rev 39263)
+++ grass/branches/develbranch_6/vector/v.in.ascii/points.c	2009-09-20 04:56:25 UTC (rev 39264)
@@ -215,6 +215,11 @@
 		}
 	    }
 
+	    len = strlen(tokens[i]); 
+	    /* do not guess column type for missing values */ 
+	    if (len == 0) 
+		continue; 
+
 	    G_debug(4, "row %d col %d: '%s' is_int = %d is_double = %d",
 		    row, i, tokens[i], is_int(tokens[i]),
 		    is_double(tokens[i]));
@@ -230,7 +235,6 @@
 	    }
 	    /* string */
 	    coltype[i] = DB_C_TYPE_STRING;
-	    len = strlen(tokens[i]);
 	    if (len > collen[i])
 		collen[i] = len;
 	}



More information about the grass-commit mailing list