Skip to content

Commit

Permalink
[ogr] compatibility for 64 bit integers
Browse files Browse the repository at this point in the history
GDAL 2 related
  • Loading branch information
m-kuhn committed Dec 10, 2015
1 parent aa4f288 commit e3a57a3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/providers/ogr/qgsogrfeatureiterator.cpp
Expand Up @@ -279,6 +279,7 @@ void QgsOgrFeatureIterator::getFeatureAttribute( OGRFeatureH ogrFet, QgsFeature
{ {
case QVariant::String: value = QVariant( mSource->mEncoding->toUnicode( OGR_F_GetFieldAsString( ogrFet, attindex ) ) ); break; case QVariant::String: value = QVariant( mSource->mEncoding->toUnicode( OGR_F_GetFieldAsString( ogrFet, attindex ) ) ); break;
case QVariant::Int: value = QVariant( OGR_F_GetFieldAsInteger( ogrFet, attindex ) ); break; case QVariant::Int: value = QVariant( OGR_F_GetFieldAsInteger( ogrFet, attindex ) ); break;
case QVariant::LongLong: value = QVariant( OGR_F_GetFieldAsInteger64( ogrFet, attindex ) ); break;
case QVariant::Double: value = QVariant( OGR_F_GetFieldAsDouble( ogrFet, attindex ) ); break; case QVariant::Double: value = QVariant( OGR_F_GetFieldAsDouble( ogrFet, attindex ) ); break;
case QVariant::Date: case QVariant::Date:
case QVariant::DateTime: case QVariant::DateTime:
Expand Down
7 changes: 6 additions & 1 deletion src/providers/ogr/qgsogrprovider.cpp
Expand Up @@ -89,7 +89,7 @@ bool QgsOgrProvider::convertField( QgsField &field, const QTextCodec &encoding )
switch ( field.type() ) switch ( field.type() )
{ {
case QVariant::LongLong: case QVariant::LongLong:
ogrType = OFTString; ogrType = OFTInteger64;
ogrWidth = ogrWidth > 0 && ogrWidth <= 21 ? ogrWidth : 21; ogrWidth = ogrWidth > 0 && ogrWidth <= 21 ? ogrWidth : 21;
ogrPrecision = -1; ogrPrecision = -1;
break; break;
Expand Down Expand Up @@ -439,6 +439,7 @@ QgsOgrProvider::QgsOgrProvider( QString const & uri )


mNativeTypes mNativeTypes
<< QgsVectorDataProvider::NativeType( tr( "Whole number (integer)" ), "integer", QVariant::Int, 1, 10 ) << QgsVectorDataProvider::NativeType( tr( "Whole number (integer)" ), "integer", QVariant::Int, 1, 10 )
<< QgsVectorDataProvider::NativeType( tr( "Whole number (integer 64 bit)" ), "integer64", QVariant::LongLong, 1, 10 )
<< QgsVectorDataProvider::NativeType( tr( "Decimal number (real)" ), "double", QVariant::Double, 1, 20, 0, 15 ) << QgsVectorDataProvider::NativeType( tr( "Decimal number (real)" ), "double", QVariant::Double, 1, 20, 0, 15 )
<< QgsVectorDataProvider::NativeType( tr( "Text (string)" ), "string", QVariant::String, 1, 255 ) << QgsVectorDataProvider::NativeType( tr( "Text (string)" ), "string", QVariant::String, 1, 255 )
<< QgsVectorDataProvider::NativeType( tr( "Date" ), "date", QVariant::Date, 8, 8 ); << QgsVectorDataProvider::NativeType( tr( "Date" ), "date", QVariant::Date, 8, 8 );
Expand Down Expand Up @@ -771,6 +772,7 @@ void QgsOgrProvider::loadFields()
switch ( ogrType ) switch ( ogrType )
{ {
case OFTInteger: varType = QVariant::Int; break; case OFTInteger: varType = QVariant::Int; break;
case OFTInteger64: varType = QVariant::LongLong; break;
case OFTReal: varType = QVariant::Double; break; case OFTReal: varType = QVariant::Double; break;
#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 1400 #if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 1400
case OFTDate: varType = QVariant::Date; break; case OFTDate: varType = QVariant::Date; break;
Expand Down Expand Up @@ -1131,6 +1133,9 @@ bool QgsOgrProvider::addAttributes( const QList<QgsField> &attributes )
case QVariant::Int: case QVariant::Int:
type = OFTInteger; type = OFTInteger;
break; break;
case QVariant::LongLong:
type = OFTInteger64;
break;
case QVariant::Double: case QVariant::Double:
type = OFTReal; type = OFTReal;
break; break;
Expand Down

1 comment on commit e3a57a3

@m-kuhn
Copy link
Member Author

@m-kuhn m-kuhn commented on e3a57a3 Dec 10, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pushed by accident, will fix before lunch

Please sign in to comment.