Skip to content
Permalink
Browse files

[ogr] compatibility for 64 bit integers -> ifdefd

GDAL 2 related
  • Loading branch information
m-kuhn committed Dec 10, 2015
1 parent e3a57a3 commit 0fdfad42833c32a7c7a03322eebc24ac563f6a1c
Showing with 14 additions and 1 deletion.
  1. +2 −0 src/providers/ogr/qgsogrfeatureiterator.cpp
  2. +12 −1 src/providers/ogr/qgsogrprovider.cpp
@@ -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:
@@ -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;

0 comments on commit 0fdfad4

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