Commit 1d9d59bd authored by Cédric Traizet's avatar Cédric Traizet

Merge branch 'bug_opening_envi_dataset' into 'release-7.1'

Error when opening ENVI datasets

See merge request !701
parents 567e66be 90a6d237
Pipeline #4004 failed with stages
in 73 minutes and 36 seconds
......@@ -22,6 +22,7 @@
#include "otbConfigurationManager.h"
#include <cassert>
#include <itksys/SystemTools.hxx>
#include "otbMacro.h"
......@@ -59,6 +60,7 @@
#include "otbSensorModelAdapter.h"
#include <memory>
#include <boost/scoped_ptr.hpp>
#include <boost/algorithm/string/predicate.hpp>
namespace otb
{
......@@ -344,6 +346,17 @@ ImageKeywordlist ReadGeometryFromRPCTag(const std::string& filename)
ossimKeywordlist geom_kwl;
ImageKeywordlist otb_kwl;
// Don't call GDALIdentifyDriver on a hdr file because this makes the ENVI driver throw an error:
// "ERROR 1: The selected file is an ENVI header file, but to open ENVI datasets, the data file
// should be selected instead of the .hdr file. Please try again selecting the data file corresponding
// to the header file"
// No driver can open hdr file anyway.
std::string extension = itksys::SystemTools::GetFilenameLastExtension(filename);
if (boost::iequals(extension, ".hdr"))
{
return otb_kwl;
}
// try to use GeoTiff RPC tag if present.
// Warning : RPC in subdatasets are not supported
GDALDriverH identifyDriverH = GDALIdentifyDriver(filename.c_str(), nullptr);
......
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