Skip to content
Snippets Groups Projects
Commit ad58726d authored by Thomas Feuvrier's avatar Thomas Feuvrier
Browse files

ENH : add preparesrtmdata tests

parent 48cf4df3
Branches
Tags
No related merge requests found
......@@ -22,6 +22,8 @@
#include "itkObjectFactory.h"
#include "base/ossimFilename.h"
namespace otb
{
......@@ -43,30 +45,30 @@ 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;
typedef PrepareSRTMDirectory Self;
typedef itk::Object Superclass;
typedef itk::SmartPointer<Self> Pointer;
typedef itk::SmartPointer<const Self> ConstPointer;
itkTypeMacro(PrepareSRTMDirectory, Object);
/** Method for creation through the object factory. */
itkNewMacro(Self);
itkTypeMacro(PrepareSRTMDirectory, itk::Object);
itkGetMacro( ULLon, double );
itkGetMacro( ULLat, double );
itkGetMacro( LRLon, double );
itkGetMacro( LRLat, double );
itkGetMacro( FullDEMDirectoryPath, string );
itkGetMacro( DEMDirectoryPath, string );
itkGetMacro( FullDEMDirectoryPath, std::string );
itkGetMacro( DEMDirectoryPath, std::string );
itkSetMacro( ULLon, double );
itkSetMacro( ULLat, double );
itkSetMacro( LRLon, double );
itkSetMacro( LRLat, double );
itkSetMacro( FullDEMDirectoryPath, string );
itkSetMacro( DEMDirectoryPath, string );
itkSetMacro( FullDEMDirectoryPath, std::string );
itkSetMacro( DEMDirectoryPath, std::string );
virtual bool Evaluate();
......@@ -84,14 +86,11 @@ private:
double m_ULLat;
double m_LRLon;
double m_LRLat;
string m_FullDEMDirectoryPath;
string m_DEMDirectoryPath;
std::string m_FullDEMDirectoryPath;
std::string m_DEMDirectoryPath;
};
} // namespace otb
#ifndef OTB_MANUAL_INSTANTIATION
#include "otbPrepareSRTMDirectory.txx"
#endif
#endif
......@@ -15,11 +15,11 @@
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef __otbPrepareSRTMDirectory_txx
#define __otbPrepareSRTMDirectory_txx
#include "otbPrepareSRTMDirectory.h"
#include <iostream>
#include <iomanip>
#include "otbMath.h"
namespace otb
{
......@@ -58,11 +58,10 @@ PrepareSRTMDirectory
bool PrepareSRTMDirectory::Evaluate()
{
int startX = floor(m_ULLon);
int endX = ceil(m_LRLon);
int startY = floor(m_LRLat);
int endY = ceil(m_ULLat);
int startX = static_cast<int>(vcl_floor(m_ULLon));
int endX = static_cast<int>(vcl_ceil(m_LRLon));
int startY = static_cast<int>(vcl_floor(m_LRLat));
int endY = static_cast<int>(vcl_ceil(m_ULLat));
std::cout << startX << std::endl;
std::cout << endX << std::endl;
......@@ -84,30 +83,30 @@ bool PrepareSRTMDirectory::Evaluate()
if (j >= 0)
{
inputfilename << "N";
inputfilename << setfill('0') << setw(2) << j;
inputfilename << std::setfill('0') << std::setw(2) << j;
outputfilename << "N";
outputfilename << setfill('0') << setw(2) << j;
outputfilename << std::setfill('0') << std::setw(2) << j;
}
else
{
inputfilename << "S";
inputfilename << setfill('0') << setw(2) << -j;
inputfilename << std::setfill('0') << std::setw(2) << -j;
outputfilename << "S";
outputfilename << setfill('0') << setw(2) << -j;
outputfilename << std::setfill('0') << std::setw(2) << -j;
}
if (i >= 0)
{
inputfilename << "E";
inputfilename << setfill('0') << setw(3) << i;
inputfilename << std::setfill('0') << std::setw(3) << i;
outputfilename << "E";
outputfilename << setfill('0') << setw(3) << i;
outputfilename << std::setfill('0') << std::setw(3) << i;
}
else
{
inputfilename << "W";
inputfilename << setfill('0') << setw(3) << -i;
inputfilename << std::setfill('0') << std::setw(3) << -i;
outputfilename << "W";
outputfilename << setfill('0') << setw(3) << -i;
outputfilename << std::setfill('0') << std::setw(3) << -i;
}
inputfilename << ".hgt";
......@@ -129,4 +128,3 @@ bool PrepareSRTMDirectory::Evaluate()
} // namespace otb
#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_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
......@@ -17,6 +17,7 @@ SET(EPSILON 0.0001)
SET(PROJECTIONS_TESTS1 ${CXX_TEST_PATH}/otbProjectionsTests1)
SET(PROJECTIONS_TESTS2 ${CXX_TEST_PATH}/otbProjectionsTests2)
SET(PROJECTIONS_TESTS3 ${CXX_TEST_PATH}/otbProjectionsTests3)
SET(PROJECTIONS_TESTS4 ${CXX_TEST_PATH}/otbProjectionsTests4)
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ otbPROJECTIONS_TESTS1 ~~~~~~~~~~~~~~~~~~~~~~~~~~
......@@ -335,6 +336,24 @@ ADD_TEST(prTvGeocentricTransform ${PROJECTIONS_TESTS3}
${TEMP}/prTvGeocentricTransform.txt
)
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ otbPROJECTIONS_TESTS4 ~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ADD_TEST(prTuPrepareSRTMDirectoryNew ${PROJECTIONS_TESTS4}
otbPrepareSRTMDirectoryNew )
#=======================================================================================
SET(Projections_SRCS1
otbProjectionBaseNew.cxx
......@@ -365,7 +384,9 @@ otbVectorDataProjectionFilterFromMapToGeo.cxx
otbGeocentricTransformNew.cxx
otbGeocentricTransform.cxx
)
SET(Projections_SRCS4
otbPrepareSRTMDirectoryNew.cxx
)
INCLUDE_DIRECTORIES("${OTBTesting_BINARY_DIR}")
......@@ -375,5 +396,7 @@ ADD_EXECUTABLE(otbProjectionsTests2 otbProjectionsTests2.cxx ${Projections_SRCS2
TARGET_LINK_LIBRARIES(otbProjectionsTests2 OTBProjections OTBIO)
ADD_EXECUTABLE(otbProjectionsTests3 otbProjectionsTests3.cxx ${Projections_SRCS3})
TARGET_LINK_LIBRARIES(otbProjectionsTests3 OTBProjections OTBIO)
ADD_EXECUTABLE(otbProjectionsTests4 otbProjectionsTests4.cxx ${Projections_SRCS4})
TARGET_LINK_LIBRARIES(otbProjectionsTests4 OTBProjections OTBIO)
ENDIF( NOT OTB_DISABLE_CXX_TESTING AND BUILD_TESTING )
/*=========================================================================
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 "itkExceptionObject.h"
#include "otbPrepareSRTMDirectory.h"
int otbPrepareSRTMDirectoryNew(int argc, char * argv[])
{
typedef otb::PrepareSRTMDirectory PrepareSRTMDirectoryType;
PrepareSRTMDirectoryType::Pointer prepareSRTM = PrepareSRTMDirectoryType::New();
return EXIT_SUCCESS;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment