Skip to content

Commit 0fdfad4

Browse files
committed
[ogr] compatibility for 64 bit integers -> ifdefd
GDAL 2 related
1 parent e3a57a3 commit 0fdfad4

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/providers/ogr/qgsogrfeatureiterator.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,9 @@ 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+
#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 2000000
282283
case QVariant::LongLong: value = QVariant( OGR_F_GetFieldAsInteger64( ogrFet, attindex ) ); break;
284+
#endif
283285
case QVariant::Double: value = QVariant( OGR_F_GetFieldAsDouble( ogrFet, attindex ) ); break;
284286
case QVariant::Date:
285287
case QVariant::DateTime:

src/providers/ogr/qgsogrprovider.cpp

+12-1
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,14 @@ bool QgsOgrProvider::convertField( QgsField &field, const QTextCodec &encoding )
8989
switch ( field.type() )
9090
{
9191
case QVariant::LongLong:
92+
#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 2000000
9293
ogrType = OFTInteger64;
93-
ogrWidth = ogrWidth > 0 && ogrWidth <= 21 ? ogrWidth : 21;
94+
ogrPrecision = 0;
95+
#else
96+
ogrType = OFTString;
9497
ogrPrecision = -1;
98+
#endif
99+
ogrWidth = ogrWidth > 0 && ogrWidth <= 21 ? ogrWidth : 21;
95100
break;
96101
97102
case QVariant::String:
@@ -439,7 +444,9 @@ QgsOgrProvider::QgsOgrProvider( QString const & uri )
439444

440445
mNativeTypes
441446
<< QgsVectorDataProvider::NativeType( tr( "Whole number (integer)" ), "integer", QVariant::Int, 1, 10 )
447+
#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 2000000
442448
<< QgsVectorDataProvider::NativeType( tr( "Whole number (integer 64 bit)" ), "integer64", QVariant::LongLong, 1, 10 )
449+
#endif
443450
<< QgsVectorDataProvider::NativeType( tr( "Decimal number (real)" ), "double", QVariant::Double, 1, 20, 0, 15 )
444451
<< QgsVectorDataProvider::NativeType( tr( "Text (string)" ), "string", QVariant::String, 1, 255 )
445452
<< QgsVectorDataProvider::NativeType( tr( "Date" ), "date", QVariant::Date, 8, 8 );
@@ -772,7 +779,9 @@ void QgsOgrProvider::loadFields()
772779
switch ( ogrType )
773780
{
774781
case OFTInteger: varType = QVariant::Int; break;
782+
#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 2000000
775783
case OFTInteger64: varType = QVariant::LongLong; break;
784+
#endif
776785
case OFTReal: varType = QVariant::Double; break;
777786
#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 1400
778787
case OFTDate: varType = QVariant::Date; break;
@@ -1133,9 +1142,11 @@ bool QgsOgrProvider::addAttributes( const QList<QgsField> &attributes )
11331142
case QVariant::Int:
11341143
type = OFTInteger;
11351144
break;
1145+
#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 2000000
11361146
case QVariant::LongLong:
11371147
type = OFTInteger64;
11381148
break;
1149+
#endif
11391150
case QVariant::Double:
11401151
type = OFTReal;
11411152
break;

0 commit comments

Comments
 (0)