Skip to content

Commit

Permalink
always commit at the end
Browse files Browse the repository at this point in the history
  • Loading branch information
Ylannl committed Jul 28, 2020
1 parent 4f566fa commit ea9c74d
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions postgis_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,10 @@ void OGRPostGISWriterNode::process()
// Create GDAL feature attributes
for (auto& term : poly_input("attributes").sub_terminals()) {
std::string name = term->get_name();
std::cout << "Field " << name << " has a size of " << term->get_data_vec().size() << std::endl;
if (geom_size != term->get_data_vec().size()) {
throw(gfException("Number of attributes not equal to number of geometries [field name =" + name + "]"));
}
// std::cout << "Field " << name << " has a size of " << term->get_data_vec().size() << std::endl;
//see if we need to rename this attribute
auto search = output_attribute_names.find(name);
if(search != output_attribute_names.end()) {
Expand Down Expand Up @@ -153,9 +153,10 @@ void OGRPostGISWriterNode::process()
fcnt = layer->GetLayerDefn()->GetFieldCount();
for (auto& term : poly_input("attributes").sub_terminals()) {
std::string name = term->get_name();
std::cout << "Field " << name << " has a size of " << term->get_data_vec().size() << std::endl;
if (geom_size != term->get_data_vec().size()) {
throw(gfException("Number of attributes not equal to number of geometries [field name =" + name + "]")); }
// std::cout << "Field " << name << " has a size of " << term->get_data_vec().size() << std::endl;
throw(gfException("Number of attributes not equal to number of geometries [field name =" + name + "]"));
}
//see if we need to rename this attribute
auto search = output_attribute_names.find(name);
if(search != output_attribute_names.end()) {
Expand Down Expand Up @@ -264,6 +265,10 @@ void OGRPostGISWriterNode::process()
}
}

if (dataSource->CommitTransaction() != OGRERR_NONE) {
throw(gfException("Committing features to database failed.\n"));
}

GDALClose(dataSource);
// GDALClose(driver);
}
Expand Down

0 comments on commit ea9c74d

Please sign in to comment.