Commit 1c38cb95 authored by Julien Michel's avatar Julien Michel

COMP: Use the OGR version proxy to hide that OFTInteger64 type only exists for gdal>=2.0

parent 386d0971
......@@ -23,6 +23,16 @@
#include "otbConfigure.h"
#include "itkMacro.h"
#if defined(_MSC_VER)
#pragma warning ( push )
#pragma warning ( disable: 4251 )
#include "ogr_core.h" // OGR enums
#pragma warning ( pop )
#else
#include "ogr_core.h" // OGR enums
#endif
#ifdef OTB_USE_GDAL_20
class GDALDataset;
class GDALDriver;
......@@ -40,6 +50,12 @@ namespace ogr
namespace version_proxy
{
/**
* With Gdal >= 2.0, this function will test equality between type and
* OFTInteger64 enum. Otherwise, it returns false.
*/
OTBGdalAdapters_EXPORT bool IsOFTInteger64(OGRFieldType type);
/**
* This namespace holds proxy functions hiding interface changes in gdal 2.0
*
......
......@@ -33,6 +33,12 @@ namespace ogr
namespace version_proxy
{
OTBGdalAdapters_EXPORT bool IsOFTInteger64(OGRFieldType type)
{
return false;
}
GDALDatasetType * Open(const char * filename, bool readOnly)
{
return OGRSFDriverRegistrar::Open(filename,!readOnly);
......
......@@ -34,6 +34,11 @@ namespace ogr
namespace version_proxy
{
OTBGdalAdapters_EXPORT bool IsOFTInteger64(OGRFieldType type)
{
return type == OFTInteger64;
}
GDALDatasetType * Open(const char * filename, bool readOnly)
{
return (GDALDatasetType *)GDALOpenEx(filename, (readOnly? GDAL_OF_READONLY : GDAL_OF_UPDATE) | GDAL_OF_VECTOR,NULL,NULL,NULL);
......
......@@ -140,7 +140,7 @@ private:
OGRFieldType fieldType = feature.ogr().GetFieldDefnRef(iField)->GetType();
if(fieldType == OFTInteger || fieldType == OFTInteger64)
if(fieldType == OFTInteger || ogr::version_proxy::IsOFTInteger64(fieldType))
{
std::string tmpKey="field."+key.substr(0, end - key.begin());
AddChoice(tmpKey,item);
......
......@@ -135,7 +135,7 @@ private:
OGRFieldType fieldType = feature.ogr().GetFieldDefnRef(iField)->GetType();
if(fieldType == OFTInteger || fieldType == OFTInteger64)
if(fieldType == OFTInteger || fieldType == ogr::version_proxy::IsOFTInteger64(fieldType))
{
std::string tmpKey="field."+key.substr(0, end - key.begin());
AddChoice(tmpKey,item);
......
......@@ -242,7 +242,7 @@ private:
OGRFieldType fieldType = feature.ogr().GetFieldDefnRef(iField)->GetType();
if(fieldType == OFTInteger || fieldType == OFTInteger64)
if(fieldType == OFTInteger || ogr::version_proxy::IsOFTInteger64(fieldType))
{
std::string tmpKey="field."+key.substr(0, end - key.begin());
AddChoice(tmpKey,item);
......
......@@ -166,12 +166,12 @@ private:
OGRFieldType fieldType = feature.ogr().GetFieldDefnRef(iField)->GetType();
if(fieldType == OFTInteger || fieldType == OFTInteger64 || fieldType == OFTReal)
if(fieldType == OFTInteger || ogr::version_proxy::IsOFTInteger64(fieldType) || fieldType == OFTReal)
{
std::string tmpKey="feat."+key.substr(0, end - key.begin());
AddChoice(tmpKey,item);
}
if(fieldType == OFTInteger || fieldType == OFTInteger64)
if(fieldType == OFTInteger || ogr::version_proxy::IsOFTInteger64(fieldType))
{
std::string tmpKey="cfield."+key.substr(0, end - key.begin());
AddChoice(tmpKey,item);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment