Commit 01d2eddb authored by Jordi Inglada's avatar Jordi Inglada

Eric Bughin has modified the class in order to accept .img, .mw and...

Eric Bughin has modified the class in order to accept .img, .mw and no-extension files for read, but only .mw for write.
parent a0ae646d
......@@ -71,18 +71,12 @@ bool MWImageIO::CanReadFile( const char* filename )
std::string lFileName(filename);
// Test the extension
std::string extension = GetExtension(filename);
if((extension!="img")&&(extension!=""))
{
if((extension!="img")&&(extension!="")&&(extension!="mw"))
return false;
}
if( System::IsADirName(lFileName) == true )
{
return false;
}
if( m_File.is_open() )
{
m_File.close();
}
std::fstream header_file;
header_file.open( filename, std::ios::in | std::ios::binary );
......@@ -241,19 +235,13 @@ bool MWImageIO::CanWriteFile( const char* filename )
{
std::string lFileName(filename);
std::string extension = GetExtension(filename);
if ((extension!="img")&&(extension!=""))
{
if (extension!="mw")
return false;
}
else if( System::IsADirName(lFileName) == true )
{
if( System::IsADirName(lFileName) == true )
return false;
}
else
{
return true;
}
}
return true;
}
void MWImageIO::Write(const void* buffer)
{
......@@ -420,8 +408,8 @@ std::string MWImageIO::GetExtension( const std::string& filename )
std::string fileExt3("");
return( fileExt3 );
}
else
return( fileExt );
return( fileExt );
}
......
......@@ -163,27 +163,39 @@ ADD_TEST(ioTvImageFileReaderShortLUM2LUM ${IO_TESTS1}
# ------- otb::MWImageIO ------------------------------
# CanRead()
ADD_TEST(ioTuMWImageIOCanRead ${IO_TESTS1} otbMWImageIOTestCanRead
ADD_TEST(ioTuMWImageIOCanReadIMG ${IO_TESTS1} otbMWImageIOTestCanRead
${BASELINE}/QB_Toulouse_Ortho_PAN.img)
ADD_TEST(ioTvImageFileReaderMW2TIF ${IO_TESTS1}
ADD_TEST(ioTuMWImageIOCanReadMW ${IO_TESTS1} otbMWImageIOTestCanRead
${BASELINE}/QB_Toulouse_Ortho_PAN.mw)
ADD_TEST(ioTvImageFileReaderMW2TIFIMG ${IO_TESTS1}
--compare-image ${TOL} ${BASELINE}/QB_Toulouse_Ortho_PAN.img
${TEMP}/ioImageFileReaderMW2TIF.tif
otbImageFileReaderTest
${INPUTDATA}/QB_Toulouse_Ortho_PAN.tif
${TEMP}/ioImageFileReaderMW2TIF.tif )
ADD_TEST(ioTvImageFileReaderMW2TIFMW ${IO_TESTS1}
--compare-image ${TOL} ${BASELINE}/QB_Toulouse_Ortho_PAN.mw
${TEMP}/ioImageFileReaderMW2TIF.tif
otbImageFileReaderTest
${INPUTDATA}/QB_Toulouse_Ortho_PAN.tif
${TEMP}/ioImageFileReaderMW2TIF.tif )
# CanWrite()
ADD_TEST(ioTuMWImageIOCanWrite ${IO_TESTS1} otbMWImageIOTestCanWrite
${TEMP}/QB_Toulouse_Ortho_PAN.img)
${TEMP}/QB_Toulouse_Ortho_PAN.mw)
ADD_TEST(ioTvImageFileReaderTIF2MW ${IO_TESTS1}
--compare-image ${TOL} ${INPUTDATA}/QB_Toulouse_Ortho_PAN.tif
${TEMP}/ioImageFileReaderTIF2MW.img
${TEMP}/ioImageFileReaderTIF2MW.mw
otbImageFileReaderTest
${BASELINE}/QB_Toulouse_Ortho_PAN.img
${TEMP}/ioImageFileReaderTIF2MW.img )
${BASELINE}/QB_Toulouse_Ortho_PAN.mw
${TEMP}/ioImageFileReaderTIF2MW.mw )
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ otbIOTests2 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
......
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