[GRASS-CVS] markus: grass6/vector/v.in.ogr main.c, 1.68.4.3, 1.68.4.4

grass at intevation.de grass at intevation.de
Sat Nov 24 08:32:41 EST 2007


Author: markus

Update of /grassrepository/grass6/vector/v.in.ogr
In directory doto:/tmp/cvs-serv17931

Modified Files:
      Tag: releasebranch_6_2
	main.c 
Log Message:
OFTDate, OFTTime and OFTDateTime backported

Index: main.c
===================================================================
RCS file: /grassrepository/grass6/vector/v.in.ogr/main.c,v
retrieving revision 1.68.4.3
retrieving revision 1.68.4.4
diff -u -d -r1.68.4.3 -r1.68.4.4
--- main.c	2 Dec 2006 06:21:51 -0000	1.68.4.3
+++ main.c	24 Nov 2007 13:32:39 -0000	1.68.4.4
@@ -624,6 +624,10 @@
 		/** Double byte string (unsupported)         OFTWideString = 6     **/
 		/** List of wide strings (unsupported)       OFTWideStringList = 7 **/
 		/** Raw Binary data (unsupported)            OFTBinary = 8         **/
+		/**                                          OFTDate = 9           **/
+		/**                                          OFTTime = 10          **/
+		/**                                          OFTDateTime = 11      **/
+
 
 		if( Ogr_ftype == OFTInteger ) {
 		    sprintf (buf, ", %s integer", Ogr_fieldname );
@@ -636,21 +640,25 @@
 #if GDAL_VERSION_NUM >= 1320
 		} else if( Ogr_ftype == OFTDate ) {
 		    sprintf (buf, ", %s date", Ogr_fieldname );
+		} else if( Ogr_ftype == OFTTime ) {
+		    sprintf (buf, ", %s time", Ogr_fieldname );
+		} else if( Ogr_ftype == OFTDateTime ) {
+		    sprintf (buf, ", %s datetime", Ogr_fieldname );
 #endif
 		} else if( Ogr_ftype == OFTString ) {
 		    int fwidth;
 		    fwidth = OGR_Fld_GetWidth(Ogr_field);
 		    /* TODO: read all records first and find the longest string length */
 		    if ( fwidth == 0) {
-			G_warning (_("Width for column '%s' set to 255 (was not specified by OGR), "
-				   "some strings may be truncated!"), Ogr_fieldname );
+			G_warning (_("Width for column %s set to 255 (was not specified by OGR), "
+				     "some strings may be truncated!"), Ogr_fieldname );
 			fwidth = 255;
 		    }
 		    sprintf (buf, ", %s varchar ( %d )", Ogr_fieldname, fwidth );
 		} else if( Ogr_ftype == OFTStringList ) {
 		    /* hack: treat as string */
 		    sprintf (buf, ", %s varchar ( %d )", Ogr_fieldname, OFTIntegerListlength );
-		    G_warning (_("Writing column <%s> with fixed length %d chars (may be truncated)"), Ogr_fieldname, OFTIntegerListlength);
+		    G_warning (_("Writing column %s with fixed length %d chars (may be truncated)"), Ogr_fieldname, OFTIntegerListlength);
 		} else {
 		    G_warning (_("Column type not supported (%s)"), Ogr_fieldname );
 		    buf[0] = 0;
@@ -711,10 +719,16 @@
 			if( Ogr_ftype == OFTInteger || Ogr_ftype == OFTReal ) {
 			    sprintf (buf, ", %s", OGR_F_GetFieldAsString( Ogr_feature, i) );
 #if GDAL_VERSION_NUM >= 1320
-			} else if( Ogr_ftype == OFTString || Ogr_ftype == OFTIntegerList || Ogr_ftype == OFTDate ) {
-#else
-			} else if( Ogr_ftype == OFTString || Ogr_ftype == OFTIntegerList ) {
+			/* should we use OGR_F_GetFieldAsDateTime() here ? */
+			} else if( Ogr_ftype == OFTDate || Ogr_ftype == OFTTime || Ogr_ftype == OFTDateTime ) {
+			    char *newbuf;
+			    db_set_string ( &strval,  (char *) OGR_F_GetFieldAsString( Ogr_feature, i) );
+			    db_double_quote_string (&strval);
+			    sprintf (buf, ", '%s'", db_get_string(&strval) );
+			    newbuf = G_str_replace(buf, "/", "-"); /* fix 2001/10/21 to 2001-10-21 */
+			    sprintf (buf, "%s", newbuf);
 #endif
+			} else if( Ogr_ftype == OFTString || Ogr_ftype == OFTIntegerList ) {
 			    db_set_string ( &strval,  (char *) OGR_F_GetFieldAsString( Ogr_feature, i) );
 			    db_double_quote_string (&strval);
 			    sprintf (buf, ", '%s'", db_get_string(&strval) );




More information about the grass-commit mailing list