Skip to content
Snippets Groups Projects
Commit adb3486f authored by Christophe Palmann's avatar Christophe Palmann
Browse files

ENH: added ossimRpcProjection type to otbSensorModelAdapter (and related test)

parent 90aa8afb
No related branches found
No related tags found
No related merge requests found
......@@ -26,6 +26,7 @@
#include "ossim/projection/ossimProjection.h"
#include "ossim/projection/ossimSensorModelFactory.h"
#include "ossim/projection/ossimSensorModel.h"
#include "ossim/projection/ossimRpcProjection.h"
#include "ossim/ossimPluginProjectionFactory.h"
#include "ossim/base/ossimTieGptSet.h"
......@@ -200,16 +201,30 @@ double SensorModelAdapter::Optimize()
if(m_SensorModel != NULL)
{
// try to retrieve a sensor model
ossimSensorModel * sensorModel = NULL;
sensorModel = dynamic_cast<ossimSensorModel *>(m_SensorModel);
sensorModel = dynamic_cast<ossimSensorModel *>(m_SensorModel);
ossimRpcProjection * simpleRpcModel = NULL;
simpleRpcModel = dynamic_cast<ossimRpcProjection *>(m_SensorModel);
//Handle expections
if ( (sensorModel == NULL ) && (simpleRpcModel == NULL ) )
itkExceptionMacro(<< "Optimize(): error, both dynamic_cast from ossimProjection* to ossimSensorModel* / ossimRpcProjection* failed.");
if(sensorModel != NULL)
if(sensorModel != NULL )
{
// Call optimize fit
precision = sensorModel->optimizeFit(*m_TiePoints);
// Call optimize fit
precision = sensorModel->optimizeFit(*m_TiePoints);
}
else
itkExceptionMacro(<< "Optimize(): error, dynamic_cast from ossimProjection* to ossimSensorModel* failed.");
else if (simpleRpcModel != NULL)
{
// Call optimize fit
precision = simpleRpcModel->optimizeFit(*m_TiePoints);
}
}
// Return the precision
......@@ -241,15 +256,31 @@ bool SensorModelAdapter::WriteGeomFile(const std::string & outfile)
ossimSensorModel * sensorModel = NULL;
sensorModel = dynamic_cast<ossimSensorModel *>(m_SensorModel);
if (sensorModel == NULL)
itkExceptionMacro(<< "WriteGeomFile(): error, dynamic_cast from ossimProjection* to ossimSensorModel* failed.");
ossimRpcProjection * simpleRpcModel = NULL;
simpleRpcModel = dynamic_cast<ossimRpcProjection *>(m_SensorModel);
//Handle expections
if ( (sensorModel == NULL ) && (simpleRpcModel == NULL ) )
itkExceptionMacro(<< "Optimize(): error, both dynamic_cast from ossimProjection* to ossimSensorModel* / ossimRpcProjection* failed.");
ossimKeywordlist geom;
bool success = sensorModel->saveState(geom);
ossimKeywordlist geom;
bool success = false;
if(sensorModel != NULL )
{
// Save state
success = sensorModel->saveState(geom);
}
else if (simpleRpcModel != NULL)
{
// Save state
success = simpleRpcModel->saveState(geom);
}
if(success)
{
return geom.write(outfile.c_str());
return geom.write(outfile.c_str());
}
}
return false;
......
......@@ -253,7 +253,7 @@ otb_test_application(NAME apTvPrRefineSensorModel
APP RefineSensorModel
OPTIONS -ingeom ${INPUTDATA}/QB_TOULOUSE_MUL_Extract_500_500.geom
-inpoints ${INPUTDATA}/QB_TOULOUSE_MUL_Extract_500_500_in_tie_points.txt
-outgeom ${TEMP}/apTvPrRefineSensorModelGeomOutput.geom
-outgeom ${TEMP}/apTvPrRefineSensorModelGeomOutput.geom
-outstat ${TEMP}/apTvPrRefineSensorModelStatsOutput.txt
-outvector ${TEMP}/apTvPrRefineSensorModelVectorOutput.shp
-map utm -map.utm.zone 31 -map.utm.northhem 1
......@@ -263,6 +263,17 @@ otb_test_application(NAME apTvPrRefineSensorModel
${BASELINE_FILES}/apTvPrRefineSensorModelGeomOutput.geom
${TEMP}/apTvPrRefineSensorModelGeomOutput.geom)
otb_test_application(NAME apTvPrRefineSensorModel2
APP RefineSensorModel
OPTIONS -ingeom ${INPUTDATA}/s1a-iw-grd-vh-20150210t060009-20150210t060034-004557-0059a3-002.geom
-inpoints ${INPUTDATA}/pts_idV5.txt
-outgeom ${TEMP}/apTvPrRefineSensorModelGeomOutput2.geom
VALID --compare-ascii 0.1
${BASELINE_FILES}/apTvPrRefineSensorModelGeomOutput2.geom
${TEMP}/apTvPrRefineSensorModelGeomOutput2.geom)
#----------- RigidTransformResample TESTS ----------------
otb_test_application(NAME apTvPrRigidTransformResample
......@@ -276,6 +287,8 @@ otb_test_application(NAME apTvPrRigidTransformResample
VALID --compare-image ${NOTOL}
${BASELINE}/owTvRigidTransformResampleTest.tif
${TEMP}/apTvPrRigidTransformResampleTest.tif)
#----------- ImageEnvelope TESTS ----------------
......
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