Skip to content
Snippets Groups Projects
Commit 7dc7f069 authored by Patrick Imbo's avatar Patrick Imbo
Browse files

TEST: add test fro Hermite interpolation

parent bf63d67e
No related branches found
No related tags found
No related merge requests found
......@@ -72,6 +72,14 @@ ADD_TEST(utTvOssimTileMapModelTestToulouse ${UTILITIES_TESTS}
ADD_TEST(utTvOssimpluginsHermiteInterpolationTest ${UTILITIES_TESTS}
ossimpluginsHermiteInterpolationTest)
IF(OTB_DATA_USE_LARGEINPUT)
ADD_TEST(utTvOssimpluginsHermiteInterpolationPlateformPositionRadarSat2Test ${UTILITIES_TESTS}
ossimpluginsHermiteInterpolationPlateformPositionTest
${IMAGEDATA}/RADARSAT2/ALTONA/Fine_Quad-Pol_Dataset/PK6621_DK406_FQ9_20080405_124900_HH_VV_HV_VH_SLC_Altona/product.xml
)
ENDIF(OTB_DATA_USE_LARGEINPUT)
# ------- lib otbsvm ------------------------------
ADD_TEST(utTuSvmKernelFunctorTest ${UTILITIES_TESTS}
......@@ -479,6 +487,7 @@ ossimElevManagerTest.cxx
ossimXmlDocumentTest.cxx
ossimTileMapModelTest.cxx
ossimpluginsHermiteInterpolation.cxx
ossimpluginsHermiteInterpolationPlateformPosition.cxx
svmGenericKernelFunctor.cxx
svmTest.cxx
svmGenericKernelTest.cxx
......
/*=========================================================================
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 <cstdlib>
#include <iostream>
#include <iomanip>
#include <cmath>
#include "ossim/base/ossimCommon.h"
#include "ossim/init/ossimInit.h"
#include "otb/HermiteInterpolator.h"
#include "otb/PlatformPosition.h"
#include "otb/Ephemeris.h"
#include "otb/JSDDateTime.h"
#include "itkTimeProbe.h"
#include "projection/ossimProjection.h"
#include "projection/ossimProjectionFactoryRegistry.h"
#include "ossim/ossimPluginProjectionFactory.h"
#include "ossim/base/ossimKeywordlist.h"
int ossimpluginsHermiteInterpolationPlateformPositionTest(int argc, char * argv[])
{
ossimInit::instance()->initialize(argc, argv);
if(argc!=2)
{
std::cout << "<input filename>" << std::endl;
return EXIT_FAILURE;
}
char * filename = argv[1];
/** Don't use FactoryRegistry because of its default factory that can conflict
* with plugins factor (cf. TSX .tif image read as QB)*/
// test ossim plugin factory
ossimProjection * projection = ossimplugins::ossimPluginProjectionFactory::instance()->createProjection(
ossimFilename(filename), 0);
// if ossim plugins factory failed, then test ossim factory
if (!projection)
{
projection = ossimProjectionFactoryRegistry::instance()->createProjection(ossimFilename(filename), 0);
if (!projection)
{
std::cout<<"OSSIM Instanciate projection FAILED ! ";
return EXIT_FAILURE;
}
}
ossimKeywordlist geom;
std::cout << "Read ossim Keywordlist...";
bool hasMetaData = false;
hasMetaData = projection->saveState(geom);
if (!hasMetaData)
{
std::cout << "Bad metadata parsing " << std::endl;
return EXIT_FAILURE;
}
// Get plateform position count :
const char* platform_positions_count_str = geom.find("platform_positions_count");
unsigned int platform_positions_count = atoi(platform_positions_count_str);
std::cout << "plateform_positions_count :" << platform_positions_count << std::endl;
ossimplugins::PlatformPosition * platform_position;
hasMetaData = platform_position->loadState(geom);
if (!hasMetaData)
{
std::cout << "Bad metadata parsing " << std::endl;
return EXIT_FAILURE;
}
for(unsigned int i = 0 ; i < platform_position->getNbrData() ; ++i)
{
ossimplugins::Ephemeris * ephemeris = platform_position->getData(i);
double * position = ephemeris->get_position();
double * velocity = ephemeris->get_vitesse();
ossimplugins::JSDDateTime date = ephemeris->get_date();
ossimplugins::Ephemeris * interpolateEphemeris = platform_position->Interpolate(date);
double * interpolatePosition = interpolateEphemeris->get_position();
double * interpolateVelocity = interpolateEphemeris->get_vitesse();
ossimplugins::JSDDateTime interpolateDate = interpolateEphemeris->get_date();
double diffPosition = 0.0;
double diffVelocity = 0.0;
for(unsigned int j = 0 ; j <3 ; ++j)
{
diffPosition += (interpolatePosition[j]-position[j]) * (interpolatePosition[j]-position[j]);
diffVelocity += (interpolateVelocity[j]-velocity[j]) * (interpolateVelocity[j]-velocity[j]);
}
std::cout << "Diff position ["<< i<<"] =" << diffPosition << std::endl;
std::cout << "Diff velocity ["<< i<<"] =" << diffVelocity << std::endl;
}
return EXIT_SUCCESS;
}
......@@ -32,6 +32,7 @@ REGISTER_TEST(ossimElevManagerTest);
REGISTER_TEST(ossimXmlDocumentTest);
REGISTER_TEST(ossimTileMapModelTest);
REGISTER_TEST(ossimpluginsHermiteInterpolationTest);
REGISTER_TEST(ossimpluginsHermiteInterpolationPlateformPositionTest);
REGISTER_TEST(svmGenericKernelFunctor);
REGISTER_TEST(svmTest);
REGISTER_TEST(svmGenericKernelTest);
......
......@@ -105,7 +105,6 @@ Ephemeris* PlatformPosition::Interpolate(JSDDateTime date)
double * y = new double[_nbrData];
double * yd = new double[_nbrData];
double dt = 0.0;
bool echIrreg = false;
double d;
x[0] = 0.0 ;
......@@ -115,24 +114,6 @@ Ephemeris* PlatformPosition::Interpolate(JSDDateTime date)
* JOURCIVIL_LENGTH
+ _data[i]->get_date().get_second() - _data[0]->get_date().get_second()
+ _data[i]->get_date().get_decimal() - _data[0]->get_date().get_decimal();
d = x[i] - x[i-1] ;
/*
* Non increasing time
*/
if (d <= 0.0)/* Non increasing time */
{
delete ephem;
ephem = NULL;
}
else if (i == 1)
{
dt = d ;
}
else if (fabs (d-dt) >= 1.0e-4) /* Irregular sampling */
{
echIrreg = true;
}
}
if (ephem != NULL)
......@@ -143,10 +124,6 @@ Ephemeris* PlatformPosition::Interpolate(JSDDateTime date)
+ date.get_second() - _data[0]->get_date().get_second()
+ date.get_decimal() - _data[0]->get_date().get_decimal();
/* If nPts odd or if the searched date is not situated in the middle of the ephemeris list -> Lagrange */
d = (dt - x[_nbrData/2-1]) / (x[_nbrData/2] - x[_nbrData/2-1]) ;
/* Computation by Everett */
/*---------------------*/
double pos[3];
......@@ -160,7 +137,6 @@ Ephemeris* PlatformPosition::Interpolate(JSDDateTime date)
}
HermiteInterpolator interpolator(_nbrData,x,y,yd);
interpolator.Interpolate(dt, pos[j], vit[j]);
}
ephem->set_position(pos);
ephem->set_vitesse(vit);
......@@ -182,6 +158,21 @@ void PlatformPosition::setData(Ephemeris** data, int nbrData)
_nbrData = nbrData;
}
Ephemeris* PlatformPosition::getData(int noData) const
{
if(noData >=0 && noData < _nbrData)
{
return _data[noData];
}
return NULL;
}
int PlatformPosition::getNbrData() const
{
return _nbrData;
}
bool PlatformPosition::saveState(ossimKeywordlist& kwl,
const char* prefix) const
{
......
......@@ -71,7 +71,9 @@ public:
};
void setData(Ephemeris** data, int nbrData);
Ephemeris* getData(int noData) const;
int getNbrData() const;
/**
* @brief Method to save object state to a keyword list.
* @param kwl Keyword list to save to.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment