Skip to content

Commit

Permalink
Fixes #17070 by considering bool fields as OGR integer fields with bo…
Browse files Browse the repository at this point in the history
…olean subtype
  • Loading branch information
pblottiere committed Nov 15, 2017
1 parent db5b1df commit 3bbe71d
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/core/qgsvectorfilewriter.cpp
Expand Up @@ -496,6 +496,12 @@ void QgsVectorFileWriter::init( QString vectorFileName,
ogrPrecision = 0;
break;

case QVariant::Bool:
ogrType = OFTInteger;
ogrWidth = 1;
ogrPrecision = 0;
break;

case QVariant::Double:
ogrType = OFTReal;
break;
Expand Down Expand Up @@ -2039,6 +2045,10 @@ gdal::ogr_feature_unique_ptr QgsVectorFileWriter::createFeature( const QgsFeatur
case QVariant::ULongLong:
OGR_F_SetFieldInteger64( poFeature.get(), ogrField, attrValue.toLongLong() );
break;
case QVariant::Bool:
OGR_F_SetFieldInteger( poFeature.get(), ogrField, attrValue.toInt() );
OGR_Fld_SetSubType( OGR_F_GetFieldDefnRef( poFeature.get(), ogrField ), OFSTBoolean );
break;
case QVariant::String:
OGR_F_SetFieldString( poFeature.get(), ogrField, mCodec->fromUnicode( attrValue.toString() ).constData() );
break;
Expand Down

0 comments on commit 3bbe71d

Please sign in to comment.