Skip to content
Snippets Groups Projects
Commit 8a62a03a authored by Emmanuel Christophe's avatar Emmanuel Christophe
Browse files

TEST: add test for PlatformPosition

parent 82d44c13
No related branches found
No related tags found
No related merge requests found
......@@ -21,6 +21,7 @@ ADD_SUBDIRECTORY(Fuzzy)
ADD_SUBDIRECTORY(MultiTemporal)
ADD_SUBDIRECTORY(Simulation)
ADD_SUBDIRECTORY(Hyperspectral)
ADD_SUBDIRECTORY(UtilitiesAdapters)
IF(OTB_USE_VISU_GUI)
ADD_SUBDIRECTORY(Visu)
......
IF( NOT OTB_DISABLE_CXX_TESTING AND BUILD_TESTING )
SET(BASELINE ${OTB_DATA_ROOT}/Baseline/OTB/Images)
SET(BASELINE_FILES ${OTB_DATA_ROOT}/Baseline/OTB/Files)
SET(INPUTDATA ${OTB_DATA_ROOT}/Input)
SET(TEMP ${OTBTesting_BINARY_DIR}/Temporary)
IF(OTB_DATA_USE_LARGEINPUT)
SET(LARGEINPUT ${OTB_DATA_LARGEINPUT_ROOT} )
ENDIF(OTB_DATA_USE_LARGEINPUT)
SET(NOTOL 0.0)
SET(EPSILON_9 0.000000001)
SET(EPSILON_3 0.001)
SET(UtilitiesAdapters_TESTS1 ${CXX_TEST_PATH}/otbUtilitiesAdaptersTests1)
ADD_TEST(uaTvPlatformPositionComputeBaselineNew
${UtilitiesAdapters_TESTS1}
otbPlatformPositionComputeBaselineNewTest)
IF(OTB_DATA_USE_LARGEINPUT)
ADD_TEST(uaTvPlatformPositionComputeBaselineTest
${UtilitiesAdapters_TESTS1}
--compare-ascii ${EPSILON_9}
${BASELINE_FILES}/uaTvPlatformPositionComputeBaselineTest.txt
${TEMP}/uaTvPlatformPositionComputeBaselineTest.txt
otbPlatformPositionComputeBaselineTest
${LARGEINPUT}/TERRASARX/ULURU/TSX1_SAR__SSC______HS_S_SRA_20090212T204239_20090212T204240/TSX1_SAR__SSC______HS_S_SRA_20090212T204239_20090212T204240.xml
${LARGEINPUT}/TERRASARX/ULURU/TSX1_SAR__SSC______HS_S_SRA_20090223T204240_20090223T204241/TSX1_SAR__SSC______HS_S_SRA_20090223T204240_20090223T204241.xml
${TEMP}/uaTvPlatformPositionComputeBaselineTest.txt)
ENDIF(OTB_DATA_USE_LARGEINPUT)
SET(UtilitiesAdapters_SRCS1
otbUtilitiesAdaptersTests1.cxx
otbPlatformPositionAdapter.cxx
)
ADD_EXECUTABLE(otbUtilitiesAdaptersTests1 otbUtilitiesAdaptersTests1.cxx ${UtilitiesAdapters_SRCS1})
TARGET_LINK_LIBRARIES(otbUtilitiesAdaptersTests1 OTBOssimAdapters OTBTesting)
ENDIF( NOT OTB_DISABLE_CXX_TESTING AND BUILD_TESTING )
/*=========================================================================
Copyright 2011 Emmanuel Christophe
Contributed to ORFEO Toolbox under license Apache 2
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
=========================================================================*/
#include <iomanip>
#include "otbImage.h"
#include "otbImageFileReader.h"
#include "otbPlatformPositionAdapter.h"
int otbPlatformPositionComputeBaselineNewTest(int argc, char* argv[])
{
typedef otb::PlatformPositionAdapter PlatformType;
PlatformType::Pointer masterPlatform = PlatformType::New();
return EXIT_SUCCESS;
}
int otbPlatformPositionComputeBaselineTest(int argc, char* argv[])
{
if (argc != 4)
{
std::cerr << "Usage: " << argv[0] << " masterImageFile slaveImageFile output" << std::endl;
return EXIT_FAILURE;
}
typedef std::complex<double> PixelType;
typedef otb::Image<PixelType,2> ImageType;
typedef otb::ImageFileReader<ImageType> ReaderType;
ReaderType::Pointer master = ReaderType::New();
ReaderType::Pointer slave = ReaderType::New();
master->SetFileName(argv[1]);
slave->SetFileName(argv[2]);
master->UpdateOutputInformation();
slave->UpdateOutputInformation();
typedef otb::PlatformPositionAdapter PlatformType;
PlatformType::Pointer masterPlatform = PlatformType::New();
PlatformType::Pointer slavePlatform = PlatformType::New();
masterPlatform->CreateSensorModel(master->GetOutput()->GetImageKeywordlist());
slavePlatform->CreateSensorModel(slave->GetOutput()->GetImageKeywordlist());
std::vector<double> masterPosition;
std::vector<double> masterSpeed;
masterPosition.resize(3);
masterSpeed.resize(3);
std::vector<double> slavePosition;
std::vector<double> slaveSpeed;
slavePosition.resize(3);
slaveSpeed.resize(3);
masterPlatform->GetPlatformPosition(0, masterPosition, masterSpeed);
slavePlatform->GetPlatformPosition(0, slavePosition, slaveSpeed);
std::ofstream file;
file.open(argv[3]);
file << std::setprecision(15);
file << "Master image:\n";
file << "Pos X: " << masterPosition[0] << " m\n";
file << "Pos Y: " << masterPosition[1] << " m\n";
file << "Pos Z: " << masterPosition[2] << " m\n";
file << "Spd X: " << masterSpeed[0] << " m/s\n";
file << "Spd Y: " << masterSpeed[1] << " m/s\n";
file << "Spd Z: " << masterSpeed[2] << " m/s\n";
file << "Slave image:\n";
file << "Pos X: " << slavePosition[0] << " m\n";
file << "Pos Y: " << slavePosition[1] << " m\n";
file << "Pos Z: " << slavePosition[2] << " m\n";
file << "Spd X: " << slaveSpeed[0] << " m/s\n";
file << "Spd Y: " << slaveSpeed[1] << " m/s\n";
file << "Spd Z: " << slaveSpeed[2] << " m/s\n";
double baselineLength = vcl_sqrt(
(masterPosition[0] - slavePosition[0]) * (masterPosition[0] - slavePosition[0]) +
(masterPosition[1] - slavePosition[1]) * (masterPosition[1] - slavePosition[1]) +
(masterPosition[2] - slavePosition[2]) * (masterPosition[2] - slavePosition[2]));
file << "\nBaseline length:\n";
file << baselineLength << " m \n";
file.close();
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 otbCommonTest for the test driver
// and all it expects is that you have a function called RegisterTests
#include <iostream>
#include "otbTestMain.h"
void RegisterTests()
{
REGISTER_TEST(otbPlatformPositionComputeBaselineNewTest);
REGISTER_TEST(otbPlatformPositionComputeBaselineTest);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment