Skip to content

Commit e3a57a3

Browse files
committed
[ogr] compatibility for 64 bit integers
GDAL 2 related
1 parent aa4f288 commit e3a57a3

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/providers/ogr/qgsogrfeatureiterator.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,7 @@ void QgsOgrFeatureIterator::getFeatureAttribute( OGRFeatureH ogrFet, QgsFeature
279279
{
280280
case QVariant::String: value = QVariant( mSource->mEncoding->toUnicode( OGR_F_GetFieldAsString( ogrFet, attindex ) ) ); break;
281281
case QVariant::Int: value = QVariant( OGR_F_GetFieldAsInteger( ogrFet, attindex ) ); break;
282+
case QVariant::LongLong: value = QVariant( OGR_F_GetFieldAsInteger64( ogrFet, attindex ) ); break;
282283
case QVariant::Double: value = QVariant( OGR_F_GetFieldAsDouble( ogrFet, attindex ) ); break;
283284
case QVariant::Date:
284285
case QVariant::DateTime:

src/providers/ogr/qgsogrprovider.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ bool QgsOgrProvider::convertField( QgsField &field, const QTextCodec &encoding )
8989
switch ( field.type() )
9090
{
9191
case QVariant::LongLong:
92-
ogrType = OFTString;
92+
ogrType = OFTInteger64;
9393
ogrWidth = ogrWidth > 0 && ogrWidth <= 21 ? ogrWidth : 21;
9494
ogrPrecision = -1;
9595
break;
@@ -439,6 +439,7 @@ QgsOgrProvider::QgsOgrProvider( QString const & uri )
439439

440440
mNativeTypes
441441
<< QgsVectorDataProvider::NativeType( tr( "Whole number (integer)" ), "integer", QVariant::Int, 1, 10 )
442+
<< QgsVectorDataProvider::NativeType( tr( "Whole number (integer 64 bit)" ), "integer64", QVariant::LongLong, 1, 10 )
442443
<< QgsVectorDataProvider::NativeType( tr( "Decimal number (real)" ), "double", QVariant::Double, 1, 20, 0, 15 )
443444
<< QgsVectorDataProvider::NativeType( tr( "Text (string)" ), "string", QVariant::String, 1, 255 )
444445
<< QgsVectorDataProvider::NativeType( tr( "Date" ), "date", QVariant::Date, 8, 8 );
@@ -771,6 +772,7 @@ void QgsOgrProvider::loadFields()
771772
switch ( ogrType )
772773
{
773774
case OFTInteger: varType = QVariant::Int; break;
775+
case OFTInteger64: varType = QVariant::LongLong; break;
774776
case OFTReal: varType = QVariant::Double; break;
775777
#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 1400
776778
case OFTDate: varType = QVariant::Date; break;
@@ -1131,6 +1133,9 @@ bool QgsOgrProvider::addAttributes( const QList<QgsField> &attributes )
11311133
case QVariant::Int:
11321134
type = OFTInteger;
11331135
break;
1136+
case QVariant::LongLong:
1137+
type = OFTInteger64;
1138+
break;
11341139
case QVariant::Double:
11351140
type = OFTReal;
11361141
break;

0 commit comments

Comments
 (0)