Commit 335f2b2d authored by Emmanuel Christophe's avatar Emmanuel Christophe

TEST: add test for TileMapImageIO

parent b2caa63b
......@@ -69,6 +69,12 @@ IF(ITK_USE_REVIEW)
TARGET_LINK_LIBRARIES(LidarToImageExample OTBIO OTBCommon ITKCommon ITKIO otbossim )
ENDIF(ITK_USE_REVIEW)
IF( OTB_USE_CURL )
ADD_EXECUTABLE(TileMapImageIOExample TileMapImageIOExample.cxx)
TARGET_LINK_LIBRARIES(TileMapImageIOExample OTBIO OTBCommon)
ENDIF( OTB_USE_CURL )
#ADD_EXECUTABLE(ImageReadExportVTK ImageReadExportVTK.cxx )
#TARGET_LINK_LIBRARIES(ImageReadExportVTK ITKCommon ITKIO)
......@@ -119,6 +125,7 @@ SET(TEMP ${OTB_BINARY_DIR}/Testing/Temporary)
SET(EXE_TESTS1 ${CXX_TEST_PATH}/otbIOExamplesTests1)
SET(EXE_TESTS2 ${CXX_TEST_PATH}/otbIOExamplesTests2)
SET(TOL 0.0)
......@@ -179,8 +186,27 @@ ADD_TEST(LidarToImageExample2Test ${EXE_TESTS1}
)
ENDIF(ITK_USE_REVIEW)
IF( OTB_USE_CURL )
ADD_TEST(TileMapImageIOExampleTest ${EXE_TESTS2}
--compare-image ${TOL} ${BASELINE}/openStreetMap.png
${TEMP}/openStreetMap.png
TileMapImageIOExampleTest
${INPUTDATA}/osmfile.otb
${TEMP}/openStreetMap.png
${TEMP}
1.4835345
43.55968261
12
)
ENDIF( OTB_USE_CURL )
ADD_EXECUTABLE(otbIOExamplesTests1 otbIOExamplesTests1.cxx)
TARGET_LINK_LIBRARIES(otbIOExamplesTests1 otbossim OTBBasicFilters OTBCommon OTBDisparityMap OTBIO OTBSpatialReasoning OTBChangeDetection OTBFeatureExtraction OTBLearning OTBMultiScale OTBProjections ITKIO ITKAlgorithms ITKStatistics ITKCommon ${OTB_IO_UTILITIES_DEPENDENT_LIBRARIES})
IF( OTB_USE_CURL )
ADD_EXECUTABLE(otbIOExamplesTests2 otbIOExamplesTests2.cxx)
TARGET_LINK_LIBRARIES(otbIOExamplesTests2 OTBCommon OTBIO ${OTB_IO_UTILITIES_DEPENDENT_LIBRARIES} ${CURL_LIBRARY} )
ENDIF( OTB_USE_CURL )
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.
=========================================================================*/
#if defined(_MSC_VER)
#pragma warning ( disable : 4786 )
#endif
// Software Guide : BeginCommandLineArgs
// INPUTS: {osmfile.otb}
// OUTPUTS: {openStreetMap.png}
// ${GeneratedFolder} 1.4835345 43.55968261 12
// Software Guide : EndCommandLineArgs
#include "itkRGBPixel.h"
#include "otbImage.h"
#include "otbImageFileReader.h"
#include "otbTileMapImageIO.h"
#include "otbInverseSensorModel.h"
#include "otbExtractROI.h"
#include "otbImageFileWriter.h"
#include "ossim/projection/ossimTileMapModel.h"
int main( int argc, char* argv[] )
{
if(argc!=7)
{
std::cout << argv[0] <<" <inputFilename> <outputFilename> "
<< "<cacheDirectory> <lon> <lat> <depth>"
<< std::endl;
return EXIT_FAILURE;
}
char * inputFilename = argv[1];
char * outputFilename = argv[2];
char * cacheDirectory = argv[3];
double lon = atof(argv[4]);
double lat = atof(argv[5]);
int depth = atoi(argv[6]);
typedef itk::RGBPixel<unsigned char> RGBPixelType;
typedef otb::Image<RGBPixelType, 2> ImageType;
typedef otb::ImageFileReader<ImageType> ReaderType;
typedef otb::TileMapImageIO ImageIOType;
ImageIOType::Pointer tileIO = ImageIOType::New();
ReaderType::Pointer readerTile = ReaderType::New();
tileIO->SetDepth(depth);
tileIO->SetCacheDirectory(cacheDirectory);
readerTile->SetImageIO(tileIO);
readerTile->SetFileName(inputFilename);
readerTile->UpdateOutputInformation();
typedef otb::InverseSensorModel<double> ModelType;
ModelType::Pointer model= ModelType::New();
model->SetImageGeometry(readerTile->GetOutput()->GetImageKeywordlist());
dynamic_cast<ossimTileMapModel*>(model->GetOssimModel())->setDepth(depth);
if(!model)
{
std::cerr << "Unable to create a model" << std::endl;
return 1;
}
typedef itk::Point <double, 2> PointType;
PointType lonLatPoint;
lonLatPoint[0]=lon;
lonLatPoint[1]=lat;
PointType tilePoint;
tilePoint=model->TransformPoint(lonLatPoint);
long int startX=static_cast<long int>(tilePoint[0]);
long int startY=static_cast<long int>(tilePoint[1]);
long int sizeX = 500;
long int sizeY = 500;
std::cerr << startX <<", "<< startY << std::endl;
std::cerr << sizeX <<", "<< sizeY << std::endl;
typedef otb::ExtractROI< RGBPixelType, RGBPixelType > ExtractROIFilterType;
ExtractROIFilterType::Pointer extractROIOsmFilter = ExtractROIFilterType::New();
extractROIOsmFilter->SetStartX(startX-sizeX/2);
extractROIOsmFilter->SetStartY(startY-sizeY/2);
extractROIOsmFilter->SetSizeX( sizeX );
extractROIOsmFilter->SetSizeY( sizeY );
extractROIOsmFilter->SetInput(readerTile->GetOutput());
typedef otb::ImageFileWriter<ImageType> WriterType;
WriterType::Pointer writer = WriterType::New();
writer->SetFileName(outputFilename);
writer->SetInput(extractROIOsmFilter->GetOutput());
writer->Update();
return EXIT_SUCCESS;
}
/*=========================================================================
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.
=========================================================================*/
// this file defines the otbMultiScaleTest for the test driver
// and all it expects is that you have a function called RegisterTests
#if defined(_MSC_VER)
#pragma warning ( disable : 4786 )
#endif
#include <iostream>
#include "otbTestMain.h"
void RegisterTests()
{
REGISTER_TEST(TileMapImageIOExampleTest);
}
#undef main
#define main TileMapImageIOExampleTest
#include "TileMapImageIOExample.cxx"
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