Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v.in.ogr: skip columns with unsupported data type instead of failing to import #2630

Merged
merged 9 commits into from
Nov 10, 2022
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 26 additions & 10 deletions vector/v.in.ogr/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ int main(int argc, char *argv[])
struct Option *snap, *type, *outloc, *cnames, *encoding, *key, *geom;
} param;
struct _flag {
struct Flag *list, *no_clean, *force2d, *notab,
struct Flag *list, *no_clean, *force2d, *notab, *drop,
nilason marked this conversation as resolved.
Show resolved Hide resolved
*region, *over, *extend, *formats, *tolower, *no_import,
*proj;
} flag;
Expand Down Expand Up @@ -380,6 +380,12 @@ int main(int argc, char *argv[])
flag.notab = G_define_standard_flag(G_FLG_V_TABLE);
flag.notab->guisection = _("Attributes");

flag.drop = G_define_flag();
flag.drop->guisection = _("Attributes");
flag.drop->key = 'd';
flag.drop->description =
_("Drop columns with unsupported data type from import");

ninsbl marked this conversation as resolved.
Show resolved Hide resolved
flag.over = G_define_flag();
flag.over->key = 'o';
flag.over->label =
Expand Down Expand Up @@ -1053,8 +1059,8 @@ int main(int argc, char *argv[])
if (key_idx[layer] > -1 && key_idx[layer] == i)
continue; /* skip defined key (FID column) */

i_out++;
i_out++;
nilason marked this conversation as resolved.
Show resolved Hide resolved

Ogr_field = OGR_FD_GetFieldDefn(Ogr_featuredefn, i);
Ogr_ftype = OGR_Fld_GetType(Ogr_field);

Expand Down Expand Up @@ -1175,13 +1181,23 @@ int main(int argc, char *argv[])
Ogr_fieldname, OFTIntegerListlength);
}
else {
G_warning(_("Column type (Ogr_ftype: %d) not supported (Ogr_fieldname: %s)"),
Ogr_ftype, Ogr_fieldname);
buf[0] = 0;
col_info[i_out].type = G_store(buf);
Comment on lines -1178 to -1181
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep the current behaviour, add

i_out--;

remove

col_info[i_out].type = G_store(buf);

}
G_free(Ogr_fieldname);
}
/* handle columns of unsupported data type */
G_warning(_("Column type (Ogr_ftype: %d) not supported (Ogr_fieldname: %s)\n"),
Ogr_ftype, Ogr_fieldname);
if (flag.drop->answer) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As above, the drop flag does not make sense: unsupported column types can not be transferred in any reasonable way.

col_info[i_out] = col_info[i_out + 1];
i_out--;
ncols_out--;
G_warning(_("Column <%s> will be omitted from import"),
Ogr_fieldname);
wenzeslaus marked this conversation as resolved.
Show resolved Hide resolved
}
else {
buf[0] = 0;
col_info[i_out].type = G_store(buf);
}
}
G_free(Ogr_fieldname);
}

/* fix duplicate column names */
done = 0;
Expand Down