From 2c0f23cdf2606f9ce2196ac514807ade8560164c Mon Sep 17 00:00:00 2001 From: Cedric <cedric.traizet@c-s.fr> Date: Thu, 3 Jan 2019 17:49:19 +0100 Subject: [PATCH] ENH: remove function IsOFTInteger64(field) and replace it with a direct test on the field type --- .../GdalAdapters/include/otbOGRVersionProxy.h | 6 ------ .../Adapters/GdalAdapters/src/otbOGRVersionProxy.cxx | 12 ------------ .../app/otbComputeConfusionMatrix.cxx | 2 +- .../app/otbPolygonClassStatistics.cxx | 2 +- .../AppClassification/app/otbSampleAugmentation.cxx | 2 +- .../AppClassification/app/otbSampleExtraction.cxx | 2 +- .../AppClassification/app/otbSampleSelection.cxx | 2 +- .../AppClassification/app/otbVectorClassifier.cxx | 2 +- .../AppClassification/include/otbTrainVectorBase.hxx | 4 ++-- .../Sampling/src/otbSampleAugmentationFilter.cxx | 2 +- 10 files changed, 9 insertions(+), 27 deletions(-) diff --git a/Modules/Adapters/GdalAdapters/include/otbOGRVersionProxy.h b/Modules/Adapters/GdalAdapters/include/otbOGRVersionProxy.h index 084feff4fe..ec1e158e24 100644 --- a/Modules/Adapters/GdalAdapters/include/otbOGRVersionProxy.h +++ b/Modules/Adapters/GdalAdapters/include/otbOGRVersionProxy.h @@ -48,12 +48,6 @@ 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 * diff --git a/Modules/Adapters/GdalAdapters/src/otbOGRVersionProxy.cxx b/Modules/Adapters/GdalAdapters/src/otbOGRVersionProxy.cxx index b616fe7526..186c09cc5d 100644 --- a/Modules/Adapters/GdalAdapters/src/otbOGRVersionProxy.cxx +++ b/Modules/Adapters/GdalAdapters/src/otbOGRVersionProxy.cxx @@ -49,18 +49,6 @@ namespace ogr namespace version_proxy { -/*-------------------------[GDAL v2 API change]-------------------------------*/ -OTBGdalAdapters_EXPORT bool IsOFTInteger64(OGRFieldType type) -{ -#if GDAL_VERSION_NUM<2000000 - (void)type; - return false; -#else - return type == OFTInteger64; -#endif -} - - GDALDatasetType * Open(const char * filename, bool readOnly , std::vector< std::string > const & options ) { #if GDAL_VERSION_NUM<2000000 diff --git a/Modules/Applications/AppClassification/app/otbComputeConfusionMatrix.cxx b/Modules/Applications/AppClassification/app/otbComputeConfusionMatrix.cxx index da9a2e3c48..f2a87a1161 100644 --- a/Modules/Applications/AppClassification/app/otbComputeConfusionMatrix.cxx +++ b/Modules/Applications/AppClassification/app/otbComputeConfusionMatrix.cxx @@ -204,7 +204,7 @@ private: OGRFieldType fieldType = feature.ogr().GetFieldDefnRef(iField)->GetType(); - if(fieldType == OFTString || fieldType == OFTInteger || ogr::version_proxy::IsOFTInteger64(fieldType)) + if(fieldType == OFTString || fieldType == OFTInteger || fieldType == OFTInteger64) { std::string tmpKey="ref.vector.field."+key.substr(0, end - key.begin()); AddChoice(tmpKey,item); diff --git a/Modules/Applications/AppClassification/app/otbPolygonClassStatistics.cxx b/Modules/Applications/AppClassification/app/otbPolygonClassStatistics.cxx index 751cba5c08..92d159b8b3 100644 --- a/Modules/Applications/AppClassification/app/otbPolygonClassStatistics.cxx +++ b/Modules/Applications/AppClassification/app/otbPolygonClassStatistics.cxx @@ -148,7 +148,7 @@ private: OGRFieldType fieldType = feature.ogr().GetFieldDefnRef(iField)->GetType(); - if(fieldType == OFTString || fieldType == OFTInteger || ogr::version_proxy::IsOFTInteger64(fieldType)) + if(fieldType == OFTString || fieldType == OFTInteger || fieldType == OFTInteger64) { std::string tmpKey="field."+key.substr(0, end - key.begin()); AddChoice(tmpKey,item); diff --git a/Modules/Applications/AppClassification/app/otbSampleAugmentation.cxx b/Modules/Applications/AppClassification/app/otbSampleAugmentation.cxx index a9fbff3aa1..6446b4f434 100644 --- a/Modules/Applications/AppClassification/app/otbSampleAugmentation.cxx +++ b/Modules/Applications/AppClassification/app/otbSampleAugmentation.cxx @@ -168,7 +168,7 @@ private: OGRFieldType fieldType = feature.ogr().GetFieldDefnRef(iField)->GetType(); - if(fieldType == OFTString || fieldType == OFTInteger || ogr::version_proxy::IsOFTInteger64(fieldType)) + if(fieldType == OFTString || fieldType == OFTInteger || fieldType == OFTInteger64) { std::string tmpKey="field."+key.substr(0, end - key.begin()); AddChoice(tmpKey,item); diff --git a/Modules/Applications/AppClassification/app/otbSampleExtraction.cxx b/Modules/Applications/AppClassification/app/otbSampleExtraction.cxx index 2c48308344..9a0741d46c 100644 --- a/Modules/Applications/AppClassification/app/otbSampleExtraction.cxx +++ b/Modules/Applications/AppClassification/app/otbSampleExtraction.cxx @@ -140,7 +140,7 @@ private: OGRFieldType fieldType = feature.ogr().GetFieldDefnRef(iField)->GetType(); - if(fieldType == OFTString || fieldType == OFTInteger || ogr::version_proxy::IsOFTInteger64(fieldType)) + if(fieldType == OFTString || fieldType == OFTInteger || fieldType == OFTInteger64) { std::string tmpKey="field."+key.substr(0, end - key.begin()); AddChoice(tmpKey,item); diff --git a/Modules/Applications/AppClassification/app/otbSampleSelection.cxx b/Modules/Applications/AppClassification/app/otbSampleSelection.cxx index 93af2fc2d6..b0a807425b 100644 --- a/Modules/Applications/AppClassification/app/otbSampleSelection.cxx +++ b/Modules/Applications/AppClassification/app/otbSampleSelection.cxx @@ -248,7 +248,7 @@ private: OGRFieldType fieldType = feature.ogr().GetFieldDefnRef(iField)->GetType(); - if(fieldType == OFTString || fieldType == OFTInteger || ogr::version_proxy::IsOFTInteger64(fieldType)) + if(fieldType == OFTString || fieldType == OFTInteger || fieldType == OFTInteger64) { std::string tmpKey="field."+key.substr(0, end - key.begin()); AddChoice(tmpKey,item); diff --git a/Modules/Applications/AppClassification/app/otbVectorClassifier.cxx b/Modules/Applications/AppClassification/app/otbVectorClassifier.cxx index 648b1d465f..9f0cecea84 100644 --- a/Modules/Applications/AppClassification/app/otbVectorClassifier.cxx +++ b/Modules/Applications/AppClassification/app/otbVectorClassifier.cxx @@ -183,7 +183,7 @@ private: std::transform(key.begin(), key.end(), key.begin(), tolower); OGRFieldType fieldType = layerDefn.GetFieldDefn(iField)->GetType(); - if(fieldType == OFTInteger || ogr::version_proxy::IsOFTInteger64(fieldType) || fieldType == OFTReal) + if(fieldType == OFTInteger || fieldType == OFTInteger64 || fieldType == OFTReal) { std::string tmpKey="feat."+key; AddChoice(tmpKey,item); diff --git a/Modules/Applications/AppClassification/include/otbTrainVectorBase.hxx b/Modules/Applications/AppClassification/include/otbTrainVectorBase.hxx index 482fa32e0f..a87570027a 100644 --- a/Modules/Applications/AppClassification/include/otbTrainVectorBase.hxx +++ b/Modules/Applications/AppClassification/include/otbTrainVectorBase.hxx @@ -131,12 +131,12 @@ void TrainVectorBase::DoUpdateParameters() OGRFieldType fieldType = feature.ogr().GetFieldDefnRef( iField )->GetType(); - if( fieldType == OFTInteger || ogr::version_proxy::IsOFTInteger64( fieldType ) || fieldType == OFTReal ) + if( fieldType == OFTInteger || fieldType == OFTInteger64 || fieldType == OFTReal ) { std::string tmpKey = "feat." + key.substr( 0, static_cast<unsigned long>( end - key.begin() ) ); AddChoice( tmpKey, item ); } - if( fieldType == OFTString || fieldType == OFTInteger || ogr::version_proxy::IsOFTInteger64( fieldType ) ) + if( fieldType == OFTString || fieldType == OFTInteger || fieldType == OFTInteger64 ) { std::string tmpKey = "cfield." + key.substr( 0, static_cast<unsigned long>( end - key.begin() ) ); AddChoice( tmpKey, item ); diff --git a/Modules/Learning/Sampling/src/otbSampleAugmentationFilter.cxx b/Modules/Learning/Sampling/src/otbSampleAugmentationFilter.cxx index 5778de0d93..1ff5bb8043 100644 --- a/Modules/Learning/Sampling/src/otbSampleAugmentationFilter.cxx +++ b/Modules/Learning/Sampling/src/otbSampleAugmentationFilter.cxx @@ -247,7 +247,7 @@ SampleAugmentationFilter { OGRFieldType fieldType = feature.ogr().GetFieldDefnRef(idx)->GetType(); return (fieldType == OFTInteger - || ogr::version_proxy::IsOFTInteger64( fieldType ) + || fieldType == OFTInteger64 || fieldType == OFTReal); } -- GitLab