diff --git a/Modules/Adapters/OSSIMAdapters/test/CMakeLists.txt b/Modules/Adapters/OSSIMAdapters/test/CMakeLists.txt index 54a7117fc93c342e11d0e77b2b5226c70c0104cc..8dadc14ff05f911b3fa0af4cca37e05592cecced 100644 --- a/Modules/Adapters/OSSIMAdapters/test/CMakeLists.txt +++ b/Modules/Adapters/OSSIMAdapters/test/CMakeLists.txt @@ -31,6 +31,7 @@ otbGeometricSarSensorModelAdapter.cxx otbPlatformPositionAdapter.cxx otbDEMHandlerTest.cxx otbRPCSolverAdapterTest.cxx +otbSarSensorModelAdapterTest.cxx ) add_executable(otbOSSIMAdaptersTestDriver ${OTBOSSIMAdaptersTests}) @@ -499,3 +500,8 @@ otb_add_test(NAME uaTvRPCSolverAdapterValidationTest COMMAND otbOSSIMAdaptersTes ${INPUTDATA}/DEM/egm96.grd ) + +otb_add_test(NAME uaTvSarSensorModelAdapter COMMAND otbOSSIMAdaptersTestDriver + otbSarSensorModelAdapterTest + ${INPUTDATA}/s1a-iw1-slc-vh-amp_xt.geom + ) diff --git a/Modules/Adapters/OSSIMAdapters/test/otbOSSIMAdaptersTestDriver.cxx b/Modules/Adapters/OSSIMAdapters/test/otbOSSIMAdaptersTestDriver.cxx index 911e57e671884e9bb003e399b605b6dfd3dacf29..5f7295d6dffdb208aafde1ab1326ecdd544bd24f 100644 --- a/Modules/Adapters/OSSIMAdapters/test/otbOSSIMAdaptersTestDriver.cxx +++ b/Modules/Adapters/OSSIMAdapters/test/otbOSSIMAdaptersTestDriver.cxx @@ -33,4 +33,5 @@ void RegisterTests() REGISTER_TEST(otbPlatformPositionComputeBaselineTest); REGISTER_TEST(otbDEMHandlerTest); REGISTER_TEST(otbRPCSolverAdapterTest); + REGISTER_TEST(otbSarSensorModelAdapterTest); } diff --git a/Modules/Adapters/OSSIMAdapters/test/otbSarSensorModelAdapterTest.cxx b/Modules/Adapters/OSSIMAdapters/test/otbSarSensorModelAdapterTest.cxx new file mode 100644 index 0000000000000000000000000000000000000000..828ed4f747a503d9044ff46945c5693fecc720ef --- /dev/null +++ b/Modules/Adapters/OSSIMAdapters/test/otbSarSensorModelAdapterTest.cxx @@ -0,0 +1,80 @@ +/* + * Copyright (C) 2005-2017 Centre National d'Etudes Spatiales (CNES) + * + * This file is part of Orfeo Toolbox + * + * https://www.orfeo-toolbox.org/ + * + * 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 <fstream> +#include <iomanip> + +#include "otbSarSensorModelAdapter.h" +#include "otbImageKeywordlist.h" + + +int otbSarSensorModelAdapterTest(int itkNotUsed(argc), char* argv[]) +{ + std::string infname = argv[1]; + + otb::SarSensorModelAdapter::Pointer sensorModel = otb::SarSensorModelAdapter::New(); + + auto kwl = otb::ReadGeometryFromGEOMFile(infname); + + bool success = sensorModel->LoadState(kwl); + + if(!success) + { + std::cerr<<"Could not LoadState() from keyword list read from"<<infname<<std::endl; + return EXIT_FAILURE; + } + + std::vector<std::pair<unsigned long, unsigned long> > lines; + success = sensorModel->Deburst(lines); + + if(!success) + { + std::cerr<<"Deburst() call failed."<<std::endl; + return EXIT_FAILURE; + } + + + otb::ImageKeywordlist outKwl; + success = sensorModel->SaveState(outKwl); + if(!success) + { + std::cerr<<"SaveState() call failed."<<std::endl; + return EXIT_FAILURE; + } + + + otb::SarSensorModelAdapter::Point2DType out1,out2; + otb::SarSensorModelAdapter::Point3DType in; + + // GCP 99 from input geom file + //support_data.geom.gcp[99].world_pt.hgt: 2.238244926818182e+02 + //support_data.geom.gcp[99].world_pt.lat: 4.323458093295080e+01 + //support_data.geom.gcp[99].world_pt.lon: 1.116316013091967e+00 + + in[0] = 4.323458093295080e+01; + in[1] = 1.116316013091967e+00; + in[2] = 2.238244926818182e+02; + + sensorModel->WorldToLineSample(in,out1); + sensorModel->WorldToLineSampleYZ(in,out1,out2); + + return EXIT_SUCCESS; +}