[ogr] compatibility for 64 bit integers -> ifdefd

GDAL 2 related
This commit is contained in:
Matthias Kuhn 2015-12-10 12:05:09 +01:00
parent e3a57a358d
commit 0fdfad4283
2 changed files with 14 additions and 1 deletions

View File

@ -279,7 +279,9 @@ void QgsOgrFeatureIterator::getFeatureAttribute( OGRFeatureH ogrFet, QgsFeature
{
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;
#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 2000000
case QVariant::LongLong: value = QVariant( OGR_F_GetFieldAsInteger64( ogrFet, attindex ) ); break;
#endif
case QVariant::Double: value = QVariant( OGR_F_GetFieldAsDouble( ogrFet, attindex ) ); break;
case QVariant::Date:
case QVariant::DateTime:

View File

@ -89,9 +89,14 @@ bool QgsOgrProvider::convertField( QgsField &field, const QTextCodec &encoding )
switch ( field.type() )
{
case QVariant::LongLong:
#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 2000000
ogrType = OFTInteger64;
ogrWidth = ogrWidth > 0 && ogrWidth <= 21 ? ogrWidth : 21;
ogrPrecision = 0;
#else
ogrType = OFTString;
ogrPrecision = -1;
#endif
ogrWidth = ogrWidth > 0 && ogrWidth <= 21 ? ogrWidth : 21;
break;
case QVariant::String:
@ -439,7 +444,9 @@ QgsOgrProvider::QgsOgrProvider( QString const & uri )
mNativeTypes
<< QgsVectorDataProvider::NativeType( tr( "Whole number (integer)" ), "integer", QVariant::Int, 1, 10 )
#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 2000000
<< QgsVectorDataProvider::NativeType( tr( "Whole number (integer 64 bit)" ), "integer64", QVariant::LongLong, 1, 10 )
#endif
<< 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( "Date" ), "date", QVariant::Date, 8, 8 );
@ -772,7 +779,9 @@ void QgsOgrProvider::loadFields()
switch ( ogrType )
{
case OFTInteger: varType = QVariant::Int; break;
#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 2000000
case OFTInteger64: varType = QVariant::LongLong; break;
#endif
case OFTReal: varType = QVariant::Double; break;
#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 1400
case OFTDate: varType = QVariant::Date; break;
@ -1133,9 +1142,11 @@ bool QgsOgrProvider::addAttributes( const QList<QgsField> &attributes )
case QVariant::Int:
type = OFTInteger;
break;
#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 2000000
case QVariant::LongLong:
type = OFTInteger64;
break;
#endif
case QVariant::Double:
type = OFTReal;
break;