[GRASS-SVN] r71431 - grass/trunk/vector/v.in.ogr
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Aug 23 09:53:37 PDT 2017
Author: mmetz
Date: 2017-08-23 09:53:37 -0700 (Wed, 23 Aug 2017)
New Revision: 71431
Modified:
grass/trunk/vector/v.in.ogr/main.c
Log:
v.in.ogr: account for empty fields even if the field is set (since GDAL 2.2)
Modified: grass/trunk/vector/v.in.ogr/main.c
===================================================================
--- grass/trunk/vector/v.in.ogr/main.c 2017-08-21 21:52:37 UTC (rev 71430)
+++ grass/trunk/vector/v.in.ogr/main.c 2017-08-23 16:53:37 UTC (rev 71431)
@@ -1203,20 +1203,22 @@
sprintf(buf, "insert into %s values ( %d", Fi->table, cat);
db_set_string(&sql, buf);
for (i = 0; i < ncols; i++) {
+ const char *Ogr_fstring = NULL;
if (key_idx > -1 && key_idx == i)
continue; /* skip defined key (FID column) */
Ogr_field = OGR_FD_GetFieldDefn(Ogr_featuredefn, i);
Ogr_ftype = OGR_Fld_GetType(Ogr_field);
- if (OGR_F_IsFieldSet(Ogr_feature, i)) {
+ if (OGR_F_IsFieldSet(Ogr_feature, i))
+ Ogr_fstring = OGR_F_GetFieldAsString(Ogr_feature, i);
+ if (Ogr_fstring && *Ogr_fstring) {
if (Ogr_ftype == OFTInteger ||
#if GDAL_VERSION_NUM >= 2000000
Ogr_ftype == OFTInteger64 ||
#endif
Ogr_ftype == OFTReal) {
- sprintf(buf, ", %s",
- OGR_F_GetFieldAsString(Ogr_feature, i));
+ sprintf(buf, ", %s", Ogr_fstring);
}
#if GDAL_VERSION_NUM >= 1320
/* should we use OGR_F_GetFieldAsDateTime() here ? */
@@ -1224,9 +1226,7 @@
|| Ogr_ftype == OFTDateTime) {
char *newbuf;
- db_set_string(&strval, (char *)
- OGR_F_GetFieldAsString(Ogr_feature,
- i));
+ db_set_string(&strval, (char *)Ogr_fstring);
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 */
@@ -1240,9 +1240,7 @@
|| Ogr_ftype == OFTInteger64List
#endif
) {
- db_set_string(&strval, (char *)
- OGR_F_GetFieldAsString(Ogr_feature,
- i));
+ db_set_string(&strval, (char *)Ogr_fstring);
db_double_quote_string(&strval);
sprintf(buf, ", '%s'", db_get_string(&strval));
}
More information about the grass-commit
mailing list