Skip to content

Commit

Permalink
fixes logical->int conversion; #1409
Browse files Browse the repository at this point in the history
  • Loading branch information
edzer committed Feb 7, 2023
1 parent 692e43b commit 558c693
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/gdal_write.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,22 @@ void SetFields(OGRFeature *poFeature, std::vector<OGRFieldType> tp, Rcpp::List o
SetNull(poFeature, j);
} break;
case OFTInteger: {
Rcpp::IntegerVector iv;
iv = obj[j];
if (! Rcpp::IntegerVector::is_na(iv[i])) {
if (shape)
const OGRFieldDefn *def = poFeature->GetFieldDefnRef(j);
if (def->GetSubType() == OFSTBoolean) {
Rcpp::LogicalVector lv;
lv = obj[j];
if (! Rcpp::LogicalVector::is_na(lv[i]))
poFeature->SetField(j, (int) lv[i]);
else
SetNull(poFeature, j); // #nocov
} else { // integer:
Rcpp::IntegerVector iv;
iv = obj[j];
if (! Rcpp::IntegerVector::is_na(iv[i]))
poFeature->SetField(j, (int) iv[i]);
else
poFeature->SetField(nm[j], (int) iv[i]);
} else
SetNull(poFeature, j); // #nocov
SetNull(poFeature, j); // #nocov
}
} break;
case OFTReal: {
Rcpp::NumericVector nv;
Expand Down

0 comments on commit 558c693

Please sign in to comment.