Commit 2454972b authored by Julien Michel's avatar Julien Michel
Browse files

ENH: Allowing access to tie points and optimize fit in sensor model adapter

parent 0ea9c0fc
......@@ -25,15 +25,18 @@
#include "ossim/projection/ossimProjection.h"
#include "ossim/projection/ossimSensorModelFactory.h"
#include "projection/ossimSensorModel.h"
#include "ossim/ossimPluginProjectionFactory.h"
#include "base/ossimTieGptSet.h"
namespace otb
{
SensorModelAdapter::SensorModelAdapter():
m_SensorModel(NULL), m_UseDEM(false), m_Epsilon(0.0001), m_NbIter(1) // FIXME keeping the original value but...
m_SensorModel(NULL), m_TiePoints(NULL), m_UseDEM(false), m_Epsilon(0.0001), m_NbIter(1) // FIXME keeping the original value but...
{
m_DEMHandler = DEMHandler::New();
m_TiePoints = new ossimTieGptSet();
}
SensorModelAdapter::~SensorModelAdapter()
......@@ -43,6 +46,11 @@ SensorModelAdapter::~SensorModelAdapter()
delete m_SensorModel;
m_SensorModel = NULL;
}
if(m_TiePoints!=NULL)
{
delete m_TiePoints;
m_TiePoints = NULL;
}
}
void SensorModelAdapter::CreateProjection(const ImageKeywordlist& image_kwl)
......@@ -186,4 +194,55 @@ void SensorModelAdapter::InverseTransformPoint(double lon, double lat, double h,
z = ossimGPoint.height();
}
void SensorModelAdapter::AddTiePoint(double x, double y, double z, double lon, double lat)
{
// Create the tie point
ossimDpt imagePoint(x,y);
ossimGpt ossimGPoint(lat, lon);
if (this->m_UseDEM)
{
double height = this->m_DEMHandler->GetHeightAboveMSL(lon, lat);
if(!ossim::isnan(height))
{
ossimGPoint.height(height);
}
}
else if (z != -32768)
{
ossimGPoint.height(z);
}
// Add the tie point to the container
m_TiePoints->addTiePoint(new ossimTieGpt(ossimGPoint,imagePoint,0));
}
void SensorModelAdapter::ClearTiePoints()
{
m_TiePoints->clearTiePoints();
}
double SensorModelAdapter::Optimize()
{
double precision = 0.;
// If tie points and model are allocated
if(m_SensorModel != NULL)
{
// try to retrieve a sensor model
ossimSensorModel * sensorModel = NULL;
sensorModel = dynamic_cast<ossimSensorModel *>(m_SensorModel);
if(sensorModel != NULL)
{
// Call optimize fit
precision = sensorModel->optimizeFit(*m_TiePoints);
}
}
// Return the precision
return precision;
}
} // namespace otb
......@@ -23,6 +23,7 @@
#include "otbDEMHandler.h"
class ossimProjection;
class ossimTieGptSet;
namespace otb
{
......@@ -54,6 +55,7 @@ public:
typedef ossimProjection* InternalMapProjectionPointer;
typedef const ossimProjection* InternalMapProjectionConstPointer;
typedef ossimTieGptSet* InternalTiePointsContainerPointer;
/** Method for creation through the object factory. */
itkNewMacro(Self);
......@@ -75,6 +77,12 @@ public:
void InverseTransformPoint(double lon, double lat, double h,
double& x, double& y, double& z) const;
void AddTiePoint(double x, double y, double z, double lon, double lat);
void ClearTiePoints();
double Optimize();
/** Is sensor model valid method. return false if the m_SensorModel is null*/
bool IsValidSensorModel();
......@@ -88,6 +96,7 @@ private:
InternalMapProjectionPointer m_SensorModel;
InternalTiePointsContainerPointer m_TiePoints;
/** Object that read and use DEM */
DEMHandler::Pointer m_DEMHandler;
......
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