Commit 090e88ea authored by Julien Osman's avatar Julien Osman
Browse files

REFACT: Update filters so they use ImageMetadata instead of KeywordLists

parent 195eaf46
......@@ -137,27 +137,48 @@ public:
return m_Transform->GetInputProjectionRef();
}
/** Set/Get Input Keywordlist*/
/** Set/Get Input Keywordlist
* \deprecated
*/
void SetInputKeywordList(const ImageKeywordlist& kwl)
{
m_Transform->SetOutputKeywordList(kwl);
this->Modified();
}
const ImageKeywordlist GetInputKeywordList()
{
return m_Transform->GetOutputKeywordList();
}
/** Set/Get output Keywordlist*/
/** Set/Get output Keywordlist
* \deprecated
*/
void SetOutputKeywordList(const ImageKeywordlist& kwl)
{
m_Transform->SetInputKeywordList(kwl);
this->Modified();
}
const ImageKeywordlist GetOutputKeywordList()
{
return m_Transform->GetInputKeywordList();
}
/** Set/Get ImageMetadata*/
const ImageMetadata* GetInputImageMetadata() const
{
return m_Transform->GetInputImageMetadata();
}
void SetInputImageMetadata(ImageMetadata* imd)
{
m_Transform->SetInputImageMetadata(imd);
this->Modified();
}
const ImageMetadata* GetOutputImageMetadata() const
{
return m_Transform->GetOutputImageMetadata();
}
void SetOutputImageMetadata(ImageMetadata* imd)
{
m_Transform->SetOutputImageMetadata(imd);
this->Modified();
}
/** Useful to set the output parameters from an existing image*/
......
......@@ -64,17 +64,9 @@ void DEMToImageGenerator<TDEMImage>::GenerateOutputInformation()
output->SetSignedSpacing(m_OutputSpacing);
output->SetOrigin(m_OutputOrigin);
// Get the Output MetaData Dictionary
itk::MetaDataDictionary& dict = output->GetMetaDataDictionary();
// Encapsulate the metadata set by the user
itk::EncapsulateMetaData<std::string>(dict, MetaDataKey::ProjectionRefKey, m_Transform->GetInputProjectionRef());
if (this->GetOutputKeywordList().GetSize() > 0)
{
itk::EncapsulateMetaData<ImageKeywordlist>(dict, MetaDataKey::OSSIMKeywordlistKey, m_Transform->GetInputKeywordList());
}
// Add the metadata set by the user to the output
output->m_Imd.Add(MDGeom::ProjectionProj, m_Transform->GetInputProjectionRef());
output->m_Imd.Merge(*m_Transform->GetInputImageMetadata());
}
// InstantiateTransform method
......
......@@ -61,7 +61,7 @@ int otbRegionProjectionResampler(int argc, char* argv[])
typedef otb::Image<double, 2> ImageType;
typedef otb::ImageFileReader<ImageType> ReaderType;
typedef otb::ImageFileWriter<ImageType> WriterType;
typedef otb::RPCInverseTransform<double> ModelType;
typedef otb::RPCInverseTransform<double, 2, 2> ModelType;
typedef itk::LinearInterpolateImageFunction<ImageType, double> InterpolatorType;
typedef itk::RescaleIntensityImageFilter<ImageType, CharImageType> RescalerType;
typedef otb::StreamingResampleImageFilter<ImageType, ImageType> ResamplerType;
......@@ -90,7 +90,7 @@ int otbRegionProjectionResampler(int argc, char* argv[])
reader->GenerateOutputInformation();
ImageType::ConstPointer inputImage = reader->GetOutput();
model->SetImageGeometry(reader->GetOutput()->GetImageKeywordlist());
model->SetMetadataModel(reader->GetOutput()->GetImageMetadata()[otb::MDGeom::RPC]);
if (model->IsValidSensorModel() == false)
{
......
......@@ -223,7 +223,7 @@ void GCPsToRPCSensorModelImageFilter<TImage>::ComputeErrors()
typedef GenericRSTransform<double, 3, 3> RSTransformType;
RSTransformType::Pointer rsTransform = RSTransformType::New();
rsTransform->SetInputKeywordList(m_Keywordlist);
rsTransform->SetInputImageMetadata(this->GetOutput()->GetImageMetadata());
rsTransform->InstantiateTransform();
ContinuousIndexType idFix, idOut;
......
......@@ -167,27 +167,51 @@ public:
return m_Transform->GetInputProjectionRef();
}
/** Set/Get Input Keywordlist*/
/** Set/Get Input Keywordlist
* \depricated
*/
void SetInputKeywordList(const ImageKeywordlist& kwl)
{
m_Transform->SetOutputKeywordList(kwl);
this->Modified();
}
const ImageKeywordlist GetInputKeywordList()
{
return m_Transform->GetOutputKeywordList();
}
/** Set/Get output Keywordlist*/
/** Set/Get output Keywordlist
* \depricated
*/
void SetOutputKeywordList(const ImageKeywordlist& kwl)
{
m_Transform->SetInputKeywordList(kwl);
this->Modified();
}
const ImageKeywordlist GetOutputKeywordList()
{
return m_Transform->GetInputKeywordList();
}
/** Set/Get Input ImageMetadata
*/
void SetInputImageMetadata(ImageMetadata* imd)
{
m_Transform->SetOutputImageMetadata(imd);
this->Modified();
}
const ImageMetadata* GetInputImageMetadata()
{
return m_Transform->GetOutputImageMetadata();
}
/** Set/Get Output ImageMetadata
*/
void SetOutputImageMetadata(ImageMetadata* imd)
{
m_Transform->SetInputImageMetadata(imd);
this->Modified();
}
const ImageMetadata* GetOutputImageMetadata()
{
return m_Transform->GetInputImageMetadata();
}
/** Useful to set the output parameters from an existing image*/
......
......@@ -125,20 +125,16 @@ void GenericRSResampleImageFilter<TInputImage, TOutputImage>::EstimateOutputRpcM
tempPtr->SetRegions(region);
// Encapsulate the output metadata in the temp image
itk::MetaDataDictionary& tempDict = tempPtr->GetMetaDataDictionary();
itk::EncapsulateMetaData<std::string>(tempDict, MetaDataKey::ProjectionRefKey, this->GetOutputProjectionRef());
itk::EncapsulateMetaData<ImageKeywordlist>(tempDict, MetaDataKey::OSSIMKeywordlistKey, this->GetOutputKeywordList());
tempPtr->m_Imd.Add(MDGeom::ProjectionProj, this->GetOutputProjectionRef());
ImageMetadata* imd = const_cast<ImageMetadata*>(this->GetOutputImageMetadata());
tempPtr->m_Imd.Merge(*imd);
// Estimate the rpc model from the temp image
m_OutputRpcEstimator->SetInput(tempPtr);
m_OutputRpcEstimator->UpdateOutputInformation();
// Encapsulate the estimated rpc model in the output
if (m_OutputRpcEstimator->GetOutput()->GetImageKeywordlist().GetSize() > 0)
{
// Fill the transform with the right kwl
m_Transform->SetInputKeywordList(m_OutputRpcEstimator->GetOutput()->GetImageKeywordlist());
}
// Fill the transform with the right metadata
m_Transform->SetInputImageMetadata(m_OutputRpcEstimator->GetOutput()->GetImageMetadata());
}
/**
......@@ -150,9 +146,8 @@ void GenericRSResampleImageFilter<TInputImage, TOutputImage>::UpdateTransform()
{
if (!m_EstimateInputRpcModel)
{
m_Transform->SetOutputDictionary(this->GetInput()->GetMetaDataDictionary());
m_Transform->SetOutputImageMetadata(this->GetInput()->GetImageMetadata());
m_Transform->SetOutputProjectionRef(this->GetInput()->GetProjectionRef());
m_Transform->SetOutputKeywordList(this->GetInput()->GetImageKeywordlist());
}
m_Transform->InstantiateTransform();
}
......@@ -187,10 +182,8 @@ void GenericRSResampleImageFilter<TInputImage, TOutputImage>::EstimateInputRpcMo
m_InputRpcEstimator->SetInput(tempPtr);
m_InputRpcEstimator->UpdateOutputInformation();
// No need to override the input kwl, just setup the
// transform with the kwl estimated
if (m_InputRpcEstimator->GetInput()->GetImageKeywordlist().GetSize() > 0)
m_Transform->SetOutputKeywordList(m_InputRpcEstimator->GetOutput()->GetImageKeywordlist());
// setup the transform with the estimated RPC model
m_Transform->SetOutputImageMetadata(m_InputRpcEstimator->GetOutput()->GetImageMetadata());
// Update the flag for input rpcEstimation in order to not compute
// the rpc model for each stream
......
......@@ -26,6 +26,8 @@
#include "otbImageReference.h"
#include "itkTransform.h"
#include "otbGenericRSTransform.h"
#include "otbImageMetadata.h"
#include "otbImageKeywordlist.h"
#include "OTBProjectionExport.h"
#include <string>
......@@ -143,21 +145,20 @@ private:
* \since OTB v 3.14.0
*
* \param[in] InputGeometriesSet
* \param[in] InputKeywordList if the \em InputGeometriesSet doesn't have a
* \param[in] InputImageMetadata if the \em InputGeometriesSet doesn't have a
* projection reference (i.e. a \c OGRSpatialReference), this filter will use
* the \em InputKeywordList to describe the positionning of the geometries set.
* the \em InputImageMetadata to describe the positionning of the geometries set.
*
* \param[in,out] OutputGeometriesSet This set of geometries needs to be given to
* the filter (in order to set the exact output file/OGR driver). However the
* filter is in charge of filling the geometries set.
* \param[in] OutputProjectionRef wkt description of the \c OGRSpatialReference
* to project the \em InputGeometriesSet into.
* \param[in] OutputKeywordList if no \em OutputProjectionRef is set, the
* projection will be done according to the \em OutputKeywordList.
* \param[in] OutputImageMetadata if no \em OutputProjectionRef is set, the
* projection will be done according to the \em OutputImageMetadata.
*
* \note Unlike \c VectorDataProjectionFilter, we have to explicitly set which
* to use between projection reference or keyword list. There is no \em
* MetaDataDictionary property.
* to use between projection reference or ImageMetadata.
*
* \note This filter does not support \em in-place transformation as the spatial
* references of the new layer are expected to change.
......@@ -252,13 +253,22 @@ public:
void SetInputOrigin(ImageReference::OriginType const& origin);
void SetOutputOrigin(ImageReference::OriginType const& origin);
//@}
/**\name Keywords lists accessors and mutators */
/**\name Keywords lists accessors and mutators
* \deprecated
*/
ImageKeywordlist& GetInputKeywordList(){};
void SetInputKeywordList(const ImageKeywordlist& kwl){};
/**\name ImageMetadata accessors and mutators */
//@{
itkGetMacro(InputKeywordList, ImageKeywordlist);
void SetInputKeywordList(const ImageKeywordlist& kwl);
itkGetMacro(InputImageMetadata, ImageMetadata*);
void SetInputImageMetadata(ImageMetadata* imd);
void SetInputImageMetadata(ImageMetadata imd);
itkGetMacro(OutputKeywordList, ImageKeywordlist);
void SetOutputKeywordList(const ImageKeywordlist& kwl);
itkGetMacro(OutputImageMetadata, ImageMetadata*);
void SetOutputImageMetadata(ImageMetadata* imd);
void SetOutputImageMetadata(ImageMetadata imd);
//@}
/**\name Projection references accessors and mutators
......@@ -296,8 +306,8 @@ private:
//@}
std::string m_OutputProjectionRef; // in WKT format!
ImageKeywordlist m_InputKeywordList;
ImageKeywordlist m_OutputKeywordList;
ImageMetadata* m_InputImageMetadata = nullptr;
ImageMetadata* m_OutputImageMetadata = nullptr;
};
} // end namespace otb
......
......@@ -79,16 +79,27 @@ inline void otb::GeometriesProjectionFilter::SetOutputOrigin(ImageReference::Ori
m_OutputImageReference.SetOrigin(origin);
}
inline void otb::GeometriesProjectionFilter::SetInputImageMetadata(ImageMetadata* imd)
{
this->m_InputImageMetadata = imd;
this->Modified();
}
inline void otb::GeometriesProjectionFilter::SetInputImageMetadata(ImageMetadata imd)
{
this->m_InputImageMetadata = &imd;
this->Modified();
}
inline void otb::GeometriesProjectionFilter::SetInputKeywordList(const ImageKeywordlist& kwl)
inline void otb::GeometriesProjectionFilter::SetOutputImageMetadata(ImageMetadata* imd)
{
this->m_InputKeywordList = kwl;
this->m_OutputImageMetadata = imd;
this->Modified();
}
inline void otb::GeometriesProjectionFilter::SetOutputKeywordList(const ImageKeywordlist& kwl)
inline void otb::GeometriesProjectionFilter::SetOutputImageMetadata(ImageMetadata imd)
{
this->m_OutputKeywordList = kwl;
this->m_OutputImageMetadata = &imd;
this->Modified();
}
......
......@@ -116,8 +116,7 @@ GroundSpacingImageFunction<TInputImage, TCoordRep>::GetPixelLocation(const Index
}
TransformType::Pointer transform = TransformType::New();
const itk::MetaDataDictionary& inputDict = this->GetInputImage()->GetMetaDataDictionary();
transform->SetInputDictionary(inputDict);
transform->SetOutputImageMetadata(this->GetInputImage()->GetImageMetadata());
transform->SetInputOrigin(this->GetInputImage()->GetOrigin());
transform->SetInputSpacing(this->GetInputImage()->GetSignedSpacing());
......
......@@ -101,7 +101,7 @@ void ImageToEnvelopeVectorDataFilter<TInputImage, TOutputVectorData>::Instantiat
m_Transform = InternalTransformType::New();
m_Transform->SetOutputProjectionRef(m_OutputProjectionRef);
m_Transform->SetInputProjectionRef(inputPtr->GetProjectionRef());
m_Transform->SetInputKeywordList(inputPtr->GetImageKeywordlist());
m_Transform->SetInputImageMetadata(inputPtr->GetImageMetadata());
m_Transform->InstantiateTransform();
}
......
......@@ -65,7 +65,7 @@ void PhysicalToRPCSensorModelImageFilter<TImage>::GenerateOutputInformation()
// Build the grid
// Generate GCPs from physical sensor model
RSTransformPointerType rsTransform = RSTransformType::New();
rsTransform->SetInputKeywordList(input->GetImageKeywordlist());
rsTransform->SetInputImageMetadata(input->GetImageMetadata());
rsTransform->InstantiateTransform();
// Compute the size of the grid
......
......@@ -241,35 +241,19 @@ VectorDataProjectionFilter<TInputVectorData, TOutputVectorData>::ProcessPolygonL
template <class TInputVectorData, class TOutputVectorData>
void VectorDataProjectionFilter<TInputVectorData, TOutputVectorData>::InstantiateTransform(void)
{
// otbMsgDevMacro(<< "Information to instantiate transform (VectorDataProjectionFilter): ");
// otbMsgDevMacro(<< " * Input Origin: " << m_InputOrigin);
// otbMsgDevMacro(<< " * Input Spacing: " << m_InputSpacing);
// otbMsgDevMacro(<< " * Input keyword list: "
// << ((m_InputKeywordList.GetSize() == 0)?"Empty":"Full"));
// otbMsgDevMacro(<< " * Input projection: " << m_InputProjectionRef);
// otbMsgDevMacro(<< " * Output keyword list: "
// << ((m_OutputKeywordList.GetSize() == 0)?"Empty":"Full"));
// otbMsgDevMacro(<< " * Output projection: " << m_OutputProjectionRef);
// otbMsgDevMacro(<< " * Output Origin: " << m_OutputOrigin);
// otbMsgDevMacro(<< " * Output Spacing: " << m_OutputSpacing);
m_Transform = InternalTransformType::New();
InputVectorDataPointer input = this->GetInput();
const itk::MetaDataDictionary& inputDict = input->GetMetaDataDictionary();
InputVectorDataPointer input = this->GetInput();
// TODO: ImageMetadata& inputImageMetadata = input->GetImageMetadata();
OutputVectorDataPointer output = this->GetOutput();
itk::MetaDataDictionary& outputDict = output->GetMetaDataDictionary();
// m_Transform->SetInputDictionary(input->GetMetaDataDictionary());
m_Transform->SetInputDictionary(inputDict);
m_Transform->SetOutputDictionary(output->GetMetaDataDictionary());
// TODO: m_Transform->SetInputImageMetadata(&inputImageMetadata);
// TODO: m_Transform->SetOutputImageMetadata(&(output->GetImageMetadata()));
m_Transform->SetInputProjectionRef(m_InputProjectionRef);
m_Transform->SetOutputProjectionRef(m_OutputProjectionRef);
m_Transform->SetInputKeywordList(m_InputKeywordList);
m_Transform->SetOutputKeywordList(m_OutputKeywordList);
m_Transform->SetInputSpacing(m_InputSpacing);
m_Transform->SetInputOrigin(m_InputOrigin);
m_Transform->SetOutputSpacing(m_OutputSpacing);
......
......@@ -178,8 +178,8 @@ void otb::GeometriesProjectionFilter::DoFinalizeInitialization()
// process is known
// m_Transform->SetInputProjectionRef(m_InputProjectionRef);
m_Transform->SetOutputProjectionRef(m_OutputProjectionRef);
m_Transform->SetInputKeywordList(m_InputKeywordList);
m_Transform->SetOutputKeywordList(m_OutputKeywordList);
m_Transform->SetInputImageMetadata(m_InputImageMetadata);
m_Transform->SetOutputImageMetadata(m_OutputImageMetadata);
m_Transform->SetInputSpacing(m_InputImageReference.GetSpacing());
m_Transform->SetInputOrigin(m_InputImageReference.GetOrigin());
......
......@@ -27,7 +27,8 @@
#include "otbGenericMapProjection.h"
#include "otbSpatialReference.h"
#include "otbCompositeTransform.h"
#include "otbInverseSensorModel.h"
#include "otbRPCInverseTransform.h"
#include "otbMetaDataKey.h"
int otbCompositeTransform(int argc, char* argv[])
{
......@@ -54,9 +55,9 @@ int otbCompositeTransform(int argc, char* argv[])
// UTM31N
mapProjection->SetWkt(otb::SpatialReference::FromEPSG(32631).ToWkt());
typedef otb::InverseSensorModel<double> SensorModelType;
typedef otb::RPCInverseTransform<double, 2, 2> SensorModelType;
SensorModelType::Pointer sensorModel = SensorModelType::New();
sensorModel->SetImageGeometry(reader->GetOutput()->GetImageKeywordlist());
sensorModel->SetMetadataModel(reader->GetOutput()->GetImageMetadata()[otb::MDGeom::RPC]);
if (sensorModel->IsValidSensorModel() == false)
{
......
......@@ -90,7 +90,8 @@ int otbGCPsToRPCSensorModelImageFilterCheckRpcModel(int argc, char* argv[])
// geographical coordinates.
GenericRSTransformType::Pointer grsTrasnform = GenericRSTransformType::New();
grsTrasnform->SetInputKeywordList(rpcEstimator->GetKeywordlist());
//TODO OSSIM:Update GCPsToRPCSensorModelImageFilter so it uses ImageMetdata instead of KeywordList
//grsTrasnform->SetInputKeywordList(rpcEstimator->GetKeywordlist());
otbLogMacro(Debug, << rpcEstimator->GetKeywordlist());
grsTrasnform->SetOutputProjectionRef("EPSG:4326");
......
......@@ -65,13 +65,13 @@ int otbGenericRSTransformFromImage(int itkNotUsed(argc), char* argv[])
TransformType::Pointer wgs2img = TransformType::New();
wgs2img->SetInputProjectionRef(wgsRef);
wgs2img->SetOutputProjectionRef(reader->GetOutput()->GetProjectionRef());
wgs2img->SetOutputKeywordList(reader->GetOutput()->GetImageKeywordlist());
wgs2img->SetOutputImageMetadata(reader->GetOutput()->GetImageMetadata());
wgs2img->InstantiateTransform();
// Instantiate Image->WGS transform
TransformType::Pointer img2wgs = TransformType::New();
img2wgs->SetInputProjectionRef(reader->GetOutput()->GetProjectionRef());
img2wgs->SetInputKeywordList(reader->GetOutput()->GetImageKeywordlist());
img2wgs->SetInputImageMetadata(reader->GetOutput()->GetImageMetadata());
img2wgs->SetOutputProjectionRef(wgsRef);
img2wgs->InstantiateTransform();
......@@ -126,13 +126,13 @@ int otbGenericRSTransformImageAndMNTToWGS84ConversionChecking(int itkNotUsed(arg
TransformType::Pointer wgs2img = TransformType::New();
wgs2img->SetInputProjectionRef(wgsRef);
wgs2img->SetOutputProjectionRef(reader->GetOutput()->GetProjectionRef());
wgs2img->SetOutputKeywordList(reader->GetOutput()->GetImageKeywordlist());
wgs2img->SetOutputImageMetadata(reader->GetOutput()->GetImageMetadata());
wgs2img->InstantiateTransform();
// Instantiate Image->WGS transform
TransformType::Pointer img2wgs = TransformType::New();
img2wgs->SetInputProjectionRef(reader->GetOutput()->GetProjectionRef());
img2wgs->SetInputKeywordList(reader->GetOutput()->GetImageKeywordlist());
img2wgs->SetInputImageMetadata(reader->GetOutput()->GetImageMetadata());
img2wgs->SetOutputProjectionRef(wgsRef);
img2wgs->InstantiateTransform();
......@@ -141,13 +141,13 @@ int otbGenericRSTransformImageAndMNTToWGS84ConversionChecking(int itkNotUsed(arg
Transform3DType::Pointer wgs2img3d = Transform3DType::New();
wgs2img3d->SetInputProjectionRef(wgsRef);
wgs2img3d->SetOutputProjectionRef(reader->GetOutput()->GetProjectionRef());
wgs2img3d->SetOutputKeywordList(reader->GetOutput()->GetImageKeywordlist());
wgs2img3d->SetOutputImageMetadata(reader->GetOutput()->GetImageMetadata());
wgs2img3d->InstantiateTransform();
// Instantiate Image->WGS transform 3D
Transform3DType::Pointer img2wgs3d = Transform3DType::New();
img2wgs3d->SetInputProjectionRef(reader->GetOutput()->GetProjectionRef());
img2wgs3d->SetInputKeywordList(reader->GetOutput()->GetImageKeywordlist());
img2wgs3d->SetInputImageMetadata(reader->GetOutput()->GetImageMetadata());
img2wgs3d->SetOutputProjectionRef(wgsRef);
img2wgs3d->InstantiateTransform();
......
......@@ -25,6 +25,7 @@
#include "itkEuclideanDistanceMetric.h"
#include "otbSpatialReference.h"
#include "otbGeographicalDistance.h"
#include "otbDEMHandler.h"
typedef otb::Image<unsigned short> ImageType;
typedef otb::ImageFileReader<ImageType> ReaderType;
......@@ -74,7 +75,7 @@ int otbGenericRSTransformGenericTest(int argc, char* argv[])
reader->UpdateOutputInformation();
transform->SetInputProjectionRef(reader->GetOutput()->GetProjectionRef());
transform->SetInputKeywordList(reader->GetOutput()->GetImageKeywordlist());
transform->SetInputImageMetadata(reader->GetOutput()->GetImageMetadata());
std::cout << "Input projection read from image: " << argv[6] << std::endl;
}
......@@ -110,7 +111,7 @@ int otbGenericRSTransformGenericTest(int argc, char* argv[])
reader->UpdateOutputInformation();
transform->SetOutputProjectionRef(reader->GetOutput()->GetProjectionRef());
transform->SetOutputKeywordList(reader->GetOutput()->GetImageKeywordlist());
transform->SetOutputImageMetadata(reader->GetOutput()->GetImageMetadata());
std::cout << "Output projection read from image: " << argv[8] << std::endl;
}
......
......@@ -61,7 +61,7 @@ int otbGeometriesProjectionFilterFromMapToSensor(int argc, char* argv[])
GeometriesFilterType::Pointer filter = GeometriesFilterType::New();
filter->SetInput(in_set);
filter->SetOutput(out_set);
filter->SetOutputKeywordList(imageReader->GetOutput()->GetImageKeywordlist());
filter->SetOutputImageMetadata(imageReader->GetOutput()->GetImageMetadata());
filter->SetOutputOrigin(imageReader->GetOutput()->GetOrigin());
filter->SetOutputSpacing(imageReader->GetOutput()->GetSignedSpacing());
......
......@@ -27,6 +27,7 @@
#include "otbVectorImage.h"
#include "otbImageFileReader.h"
#include "otbImageMetadata.h"
#include "otbRPCForwardTransform.h"
#include "otbRPCInverseTransform.h"
#include "otbDEMHandler.h"
......@@ -57,37 +58,37 @@ typedef otb::VectorImage<double, 2> ImageType;
typedef itk::Statistics::EuclideanDistanceMetric<ImageType::PointType> DistanceType;
typedef otb::GeographicalDistance<ImageType::PointType> GeographicalDistanceType;
int produceGCP(char* outputgcpfilename, const otb::ImageKeywordlist& kwlist, bool useForwardSensorModel = true, double z = 16.19688987731934)
int produceGCP(char* outputgcpfilename, const otb::ImageMetadata& imd, bool useForwardSensorModel = true, double z = 16.19688987731934)
{
itk::Point<double, 2> imagePoint;
itk::Point<double, 2> geoPoint;
// otbForwardSensorModel
typedef otb::RPCForwardTransform<double> ForwardSensorModelType;
typedef otb::RPCForwardTransform<double, 2, 2> ForwardSensorModelType;
ForwardSensorModelType::Pointer forwardSensorModel = ForwardSensorModelType::New();
forwardSensorModel->SetImageGeometry(kwlist);
forwardSensorModel->SetMetadataModel(imd[otb::MDGeom::RPC]);
if (forwardSensorModel->IsValidSensorModel() == false)
{
otbLogMacro(Warning, << "Invalid Model pointer m_Model == NULL!\n The ossim keywordlist is invalid!");
otbLogMacro(Warning, << "Invalid Model pointer m_Model == NULL!\n The metadata is invalid!");
return EXIT_FAILURE;
}
otb::DEMHandler::Instance()->SetDefaultHeightAboveEllipsoid(z);
// ossim classes
ossimKeywordlist ossimKwlist;
kwlist.convertToOSSIMKeywordlist(ossimKwlist);
ossimProjection* ossimSensorModel = ossimSensorModelFactory::instance()->createProjection(ossimKwlist);
if (ossimSensorModel == nullptr)
{
ossimSensorModel = ossimplugins::ossimPluginProjectionFactory::instance()->createProjection(ossimKwlist);
}
if (ossimSensorModel == nullptr) // Model validity
{
std::cerr << "Invalid sensor model (ossimSensorModel is NULL)" << std::endl;
return EXIT_FAILURE;
}
// ossimKeywordlist ossimKwlist;