Commit ee4a452e authored by Julien Michel's avatar Julien Michel

Correction bug d'écriture multiple avec gdal.

Ajout d'un test pour mettre en évidence ce bug.
Ajout du répertoire fusion dans les OTB_INSTALL_INCLUDE_DIR.
parent 8d10d05d
......@@ -69,6 +69,12 @@ public:
* LargestPossibleRegion. */
virtual void Write(void);
virtual void SetFileName(std::string filename)
{
this->Superclass::SetFileName(filename);
this->SetImageIO(NULL);
}
protected:
ImageFileWriter();
~ImageFileWriter();
......
......@@ -131,8 +131,19 @@ public:
/** ImageFileWriter Methods */
/** Specify the name of the output file to write. */
itkSetStringMacro(FileName);
itkGetStringMacro(FileName);
/**
* Set the filename and destroy the current driver.
* \param filename the name of the file.
*/
virtual void SetFileName(std::string filename)
{
m_FileName = filename;
m_ImageIO = NULL;
this->Modified();
}
/** Specify the region to write. If left NULL, then the whole image
* is written. */
......
......@@ -182,7 +182,7 @@ namespace otb
OutputImageListPointerType convOutputPtr = this->GetConvexOutput();
OutputImageListPointerType concOutputPtr = this->GetConcaveOutput();
int i = 0;
unsigned int i = 0;
DecompositionFilterPointerType filter;
......
......@@ -1272,6 +1272,26 @@ ADD_TEST(ioTuShapeFileDataWriterTest ${IO_TESTS14}
)
ADD_TEST(ioTvGDALDriverDoubleWritingTest ${IO_TESTS14}
--compare-n-images ${TOL} 4
${INPUTDATA}/poupees.tif
${TEMP}/ioGdalDriverDoubleWritingTestImage1.tif
${INPUTDATA}/ROI_IKO_PAN_LesHalles.tif
${TEMP}/ioGdalDriverDoubleWritingTestImage2.tif
${INPUTDATA}/poupees.tif
${TEMP}/ioGdalDriverDoubleWritingTestImage3.tif
${INPUTDATA}/ROI_IKO_PAN_LesHalles.tif
${TEMP}/ioGdalDriverDoubleWritingTestImage4.tif
otbGDALDriverDoubleWritingTest
${INPUTDATA}/poupees.tif
${INPUTDATA}/ROI_IKO_PAN_LesHalles.tif
${TEMP}/ioGdalDriverDoubleWritingTestImage1.tif
${TEMP}/ioGdalDriverDoubleWritingTestImage2.tif
${TEMP}/ioGdalDriverDoubleWritingTestImage3.tif
${TEMP}/ioGdalDriverDoubleWritingTestImage4.tif
)
#----------------------------------------------------------------------------------
SET(BasicIO_SRCS1
otbImageFileReaderERS.cxx
......@@ -1362,6 +1382,7 @@ SET(BasicIO_SRCS14
otbOGRDriverTest.cxx
otbShapeFileDataReaderTest.cxx
otbShapeFileDataWriterTest.cxx
otbGDALDriverDoubleWritingTest.cxx
)
......
/*=========================================================================
Program: ORFEO Toolbox
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See OTBCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#include "otbVectorImage.h"
#include "otbImageFileReader.h"
#include "otbImageFileWriter.h"
#include "otbStreamingImageFileWriter.h"
int otbGDALDriverDoubleWritingTest(int argc, char * argv[])
{
const char * infname1 = argv[1];
const char * infname2 = argv[2];
const char * outfname1 = argv[3];
const char * outfname2 = argv[4];
const char * outfname3 = argv[5];
const char * outfname4 = argv[6];
typedef otb::VectorImage<double,2>ImageType;
typedef otb::ImageFileReader<ImageType> ReaderType;
typedef otb::ImageFileWriter<ImageType> WriterType;
typedef otb::StreamingImageFileWriter<ImageType> StreamingWriterType;
ReaderType::Pointer reader = ReaderType::New();
WriterType::Pointer writer = WriterType::New();
StreamingWriterType::Pointer streamingWriter = StreamingWriterType::New();
reader->SetFileName(infname1);
writer->SetFileName(outfname1);
writer->SetInput(reader->GetOutput());
writer->Update();
reader->SetFileName(infname2);
writer->SetFileName(outfname2);
writer->Update();
reader->SetFileName(infname1);
streamingWriter->SetFileName(outfname3);
streamingWriter->SetInput(reader->GetOutput());
streamingWriter->Update();
reader->SetFileName(infname2);
streamingWriter->SetFileName(outfname4);
streamingWriter->SetInput(reader->GetOutput());
streamingWriter->Update();
return EXIT_SUCCESS;
}
......@@ -31,4 +31,5 @@ void RegisterTests()
REGISTER_TEST(otbOGRDriverTest);
REGISTER_TEST(otbShapeFileDataReaderTest);
REGISTER_TEST(otbShapeFileDataWriterTest);
REGISTER_TEST(otbGDALDriverDoubleWritingTest);
}
......@@ -148,6 +148,7 @@ SET(OTB_INCLUDE_DIRS_INSTALL_TREE ${OTB_INCLUDE_DIRS_INSTALL_TREE}
${OTB_INSTALL_INCLUDE_DIR}/Projections
${OTB_INSTALL_INCLUDE_DIR}/Radiometry
${OTB_INSTALL_INCLUDE_DIR}/Markov
${OTB_INSTALL_INCLUDE_DIR}/Fusion
${OTB_INSTALL_INCLUDE_DIR}/Utilities
${OTB_INSTALL_INCLUDE_DIR}/Utilities/ITK
${OTB_INSTALL_INCLUDE_DIR}/Utilities/BGL
......
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