Skip to content
Permalink
Browse files

Fixes #17070 by considering bool fields as OGR integer fields with bo…

…olean subtype
  • Loading branch information
pblottiere committed Nov 13, 2017
1 parent db5b1df commit 3bbe71d99e0678dd11be720f1ed0f6d4c589efa6
Showing with 10 additions and 0 deletions.
  1. +10 −0 src/core/qgsvectorfilewriter.cpp
@@ -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;
@@ -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;

0 comments on commit 3bbe71d

Please sign in to comment.
You can’t perform that action at this time.