Commit aa52541c authored by Emmanuel Christophe's avatar Emmanuel Christophe
Browse files

work in progress

parent bca420bd
/*=========================================================================
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.
=========================================================================*/
#ifndef _otbPrepareSRTMDirectory_h
#define _otbPrepareSRTMDirectory_h
#include "itkObject.h"
#include "itkObjectFactory.h"
#include "base/ossimFilename.h"
namespace otb
{
/**
* \class PrepareSRTMDirectory
* \brief Prepare SRTM directory for Ossim from a full archive
*
* As ossim has some issue with directories containing too many SRTM tiles
* (>5000) this class enable to copy only the required tiles from
* FullDEMDirectoryPath containing all the SRTM tiles to DEMDirectoryPath
* that will be passed as the argument of the SetDEMDirectoryPath() of
* the otb::DEMToImageGenerator for example
*
*
*/
class ITK_EXPORT PrepareSRTMDirectory : public itk::Object
{
public:
/** Standard class typedefs. */
typedef PrepareSRTMDirectory Self;
typedef itk::SmartPointer<Self> Pointer;
typedef itk::SmartPointer<const Self> ConstPointer;
typedef itk::Object Superclass;
itkTypeMacro(PrepareSRTMDirectory, Object);
/** Method for creation through the object factory. */
itkNewMacro(Self);
itkGetMacro( ULLon, double );
itkGetMacro( ULLat, double );
itkGetMacro( LRLon, double );
itkGetMacro( LRLat, double );
itkGetMacro( FullDEMDirectoryPath, string );
itkGetMacro( DEMDirectoryPath, string );
itkSetMacro( ULLon, double );
itkSetMacro( ULLat, double );
itkSetMacro( LRLon, double );
itkSetMacro( LRLat, double );
itkSetMacro( FullDEMDirectoryPath, string );
itkSetMacro( DEMDirectoryPath, string );
virtual bool Evaluate();
protected:
PrepareSRTMDirectory();
~PrepareSRTMDirectory(){};
void PrintSelf(std::ostream& os, itk::Indent indent) const;
private:
PrepareSRTMDirectory( const Self& ); //purposely not implemented
void operator=( const Self& ); //purposely not implemented
double m_ULLon;
double m_ULLat;
double m_LRLon;
double m_LRLat;
string m_FullDEMDirectoryPath;
string m_DEMDirectoryPath;
};
} // namespace otb
#ifndef OTB_MANUAL_INSTANTIATION
#include "otbPrepareSRTMDirectory.txx"
#endif
#endif
/*=========================================================================
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.
=========================================================================*/
#ifndef _otbPrepareSRTMDirectory_txx
#define _otbPrepareSRTMDirectory_txx
#include "otbPrepareSRTMDirectory.h"
namespace otb
{
/**
* Constructor
*/
PrepareSRTMDirectory::PrepareSRTMDirectory()
{
m_ULLon = 0.0;
m_ULLat = 0.0;
m_LRLon = 0.0;
m_LRLat = 0.0;
m_FullDEMDirectoryPath = "";
m_DEMDirectoryPath = "";
}
/**
*
*/
void
PrepareSRTMDirectory
::PrintSelf(std::ostream& os, itk::Indent indent) const
{
this->Superclass::PrintSelf(os,indent);
os << indent << " m_ULLon " << m_ULLon << std::endl;
os << indent << " m_ULLat " << m_ULLat << std::endl;
os << indent << " m_LRLon " << m_LRLon << std::endl;
os << indent << " m_LRLat " << m_LRLat << std::endl;
os << indent << " m_FullDEMDirectoryPath" << m_FullDEMDirectoryPath << std::endl;
os << indent << " m_DEMDirectoryPath" << m_DEMDirectoryPath << std::endl;
}
bool PrepareSRTMDirectory::Evaluate()
{
int startX = floor(m_ULLon);
int endX = ceil(m_LRLon);
int startY = floor(m_LRLat);
int endY = ceil(m_ULLat);
std::cout << startX << std::endl;
std::cout << endX << std::endl;
std::cout << startY << std::endl;
std::cout << endY << std::endl;
for (int j=startY; j<endY; j++)
{
for (int i=startX; i< endX; i++)
{
std::ostringstream inputfilename;
inputfilename << m_FullDEMDirectoryPath;
inputfilename << "/";
std::ostringstream outputfilename;
outputfilename << m_DEMDirectoryPath;
outputfilename << "/";
if (j >= 0)
{
inputfilename << "N";
inputfilename << setfill('0') << setw(2) << j;
outputfilename << "N";
outputfilename << setfill('0') << setw(2) << j;
}
else
{
inputfilename << "S";
inputfilename << setfill('0') << setw(2) << -j;
outputfilename << "S";
outputfilename << setfill('0') << setw(2) << -j;
}
if (i >= 0)
{
inputfilename << "E";
inputfilename << setfill('0') << setw(3) << i;
outputfilename << "E";
outputfilename << setfill('0') << setw(3) << i;
}
else
{
inputfilename << "W";
inputfilename << setfill('0') << setw(3) << -i;
outputfilename << "W";
outputfilename << setfill('0') << setw(3) << -i;
}
inputfilename << ".hgt";
outputfilename << ".hgt";
std::cout << "Copying " << inputfilename.str() << " to " << outputfilename.str() << std::endl;
//copy input file to output file
ossimFilename inputFile(inputfilename.str().c_str());
ossimFilename outputFile(outputfilename.str().c_str());
inputFile.copyFileTo(outputFile);
}
}
return true;
}
} // namespace otb
#endif
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