Commit 34238c43 authored by Cédric Traizet's avatar Cédric Traizet

REFAC: use ImageMetadata in VectorDataProjectionFilter

parent 340cfd56
Pipeline #6296 failed with stages
in 88 minutes and 10 seconds
......@@ -92,7 +92,7 @@ int main(int argc, char* argv[])
// Information about the target projection is retrieved directly from
// the image:
vectorDataProjection->SetOutputKeywordList(imageReader->GetOutput()->GetImageKeywordlist());
vectorDataProjection->SetOutputImageMetadata(&imageReader->GetOutput()->GetImageMetadata());
vectorDataProjection->SetOutputOrigin(imageReader->GetOutput()->GetOrigin());
vectorDataProjection->SetOutputSpacing(imageReader->GetOutput()->GetSignedSpacing());
vectorDataProjection->SetOutputProjectionRef(imageReader->GetOutput()->GetProjectionRef());
......
......@@ -172,7 +172,7 @@ private:
VectorDataProjectionFilterType::Pointer vproj = VectorDataProjectionFilterType::New();
vproj->SetInput(vd);
vproj->SetInputKeywordList(GetParameterImage("in")->GetImageKeywordlist());
vproj->SetInputImageMetadata(&GetParameterImage("in")->GetImageMetadata());
// vproj->SetInputOrigin(GetParameterImage("in")->GetOrigin());
// vproj->SetInputSpacing(GetParameterImage("in")->GetSignedSpacing());
......
......@@ -176,7 +176,7 @@ private:
// Reproject VectorData in image projection
m_Vproj = VectorDataProjectionFilterType::New();
m_Vproj->SetInput(m_Connected->GetFilter()->GetOutputVectorData());
m_Vproj->SetInputKeywordList(inputImage->GetImageKeywordlist());
m_Vproj->SetInputImageMetadata(&inputImage->GetImageMetadata());
// m_Vproj->SetInputOrigin(inputImage->GetOrigin());
// m_Vproj->SetInputSpacing(inputImage->GetSignedSpacing());
......
......@@ -148,7 +148,7 @@ private:
m_VectorDataProj = VectorDataProjectionFilterType::New();
m_VectorDataProj->SetInput(vd);
m_VectorDataProj->SetInputProjectionRef(vd->GetProjectionRef());
m_VectorDataProj->SetOutputKeywordList(inImage->GetImageKeywordlist());
m_VectorDataProj->SetOutputImageMetadata(&inImage->GetImageMetadata());
m_VectorDataProj->SetOutputProjectionRef(inImage->GetProjectionRef());
// Set up the transform
......@@ -174,7 +174,7 @@ private:
m_ReverseVectorDataProj = VectorDataProjectionFilterType::New();
m_ReverseVectorDataProj->SetInput(m_TransformFilter->GetOutput());
m_ReverseVectorDataProj->SetOutputProjectionRef(vd->GetProjectionRef());
m_ReverseVectorDataProj->SetInputKeywordList(inImage->GetImageKeywordlist());
m_ReverseVectorDataProj->SetInputImageMetadata(&inImage->GetImageMetadata());
m_ReverseVectorDataProj->SetInputProjectionRef(inImage->GetProjectionRef());
// Set the output image
......
......@@ -176,7 +176,7 @@ void VectorDataIntoImageProjectionFilter<TInputVectorData, TInputImage>::Generat
if (m_InputImage->GetProjectionRef().empty() || boost::algorithm::istarts_with(m_InputImage->GetProjectionRef(), "LOCAL_CS"))
{
m_VdProjFilter->SetOutputKeywordList(m_InputImage->GetImageKeywordlist());
m_VdProjFilter->SetOutputImageMetadata(&m_InputImage->GetImageMetadata());
}
else
{
......
......@@ -127,20 +127,6 @@ public:
itkSetStringMacro(OutputProjectionRef);
itkGetStringMacro(OutputProjectionRef);
itkGetMacro(InputKeywordList, ImageKeywordlist);
void SetInputKeywordList(const ImageKeywordlist& kwl)
{
this->m_InputKeywordList = kwl;
this->Modified();
}
itkGetMacro(OutputKeywordList, ImageKeywordlist);
void SetOutputKeywordList(const ImageKeywordlist& kwl)
{
this->m_OutputKeywordList = kwl;
this->Modified();
}
/** Set the origin of the vector data.
* \sa GetOrigin() */
itkSetMacro(InputOrigin, OriginType);
......@@ -173,6 +159,29 @@ public:
itkGetConstReferenceMacro(OutputSpacing, SpacingType);
/**\name ImageMetadata accessors and mutators */
//@{
const ImageMetadata* GetInputImageMetadata() const
{
return m_InputImageMetadata;
}
void SetInputImageMetadata(const ImageMetadata* imd)
{
m_InputImageMetadata = imd;
this->Modified();
}
const ImageMetadata* GetOutputImageMetadata() const
{
return m_OutputImageMetadata;
}
void SetOutputImageMetadata(const ImageMetadata* imd)
{
m_OutputImageMetadata = imd;
this->Modified();
}
//@}
protected:
VectorDataProjectionFilter();
~VectorDataProjectionFilter() override
......@@ -196,8 +205,8 @@ private:
InternalTransformPointerType m_Transform;
std::string m_InputProjectionRef;
std::string m_OutputProjectionRef;
ImageKeywordlist m_InputKeywordList;
ImageKeywordlist m_OutputKeywordList;
const ImageMetadata* m_InputImageMetadata = nullptr;
const ImageMetadata* m_OutputImageMetadata = nullptr;
SpacingType m_InputSpacing;
OriginType m_InputOrigin;
......
......@@ -37,8 +37,6 @@ VectorDataProjectionFilter<TInputVectorData, TOutputVectorData>::VectorDataProje
{
m_InputProjectionRef.clear();
m_OutputProjectionRef.clear();
m_InputKeywordList.Clear();
m_OutputKeywordList.Clear();
m_InputSpacing.Fill(1);
m_InputOrigin.Fill(0);
m_OutputSpacing.Fill(1);
......@@ -244,13 +242,18 @@ void VectorDataProjectionFilter<TInputVectorData, TOutputVectorData>::Instantiat
m_Transform = InternalTransformType::New();
InputVectorDataPointer input = this->GetInput();
// TODO: ImageMetadata& inputImageMetadata = input->GetImageMetadata();
const itk::MetaDataDictionary& inputDict = input->GetMetaDataDictionary();
OutputVectorDataPointer output = this->GetOutput();
itk::MetaDataDictionary& outputDict = output->GetMetaDataDictionary();
// TODO: m_Transform->SetInputImageMetadata(&inputImageMetadata);
// TODO: m_Transform->SetOutputImageMetadata(&(output->GetImageMetadata()));
m_Transform->SetInputImageMetadata(m_InputImageMetadata);
m_Transform->SetOutputImageMetadata(m_OutputImageMetadata);
if (m_InputProjectionRef.empty())
{
itk::ExposeMetaData<std::string>(inputDict, MetaDataKey::ProjectionRefKey, m_InputProjectionRef);
}
m_Transform->SetInputProjectionRef(m_InputProjectionRef);
m_Transform->SetOutputProjectionRef(m_OutputProjectionRef);
......@@ -266,11 +269,6 @@ void VectorDataProjectionFilter<TInputVectorData, TOutputVectorData>::Instantiat
m_OutputProjectionRef = m_Transform->GetOutputProjectionRef();
// If the projection information for the output is provided, propagate it
if (m_OutputKeywordList.GetSize() != 0)
{
itk::EncapsulateMetaData<ImageKeywordlist>(outputDict, MetaDataKey::OSSIMKeywordlistKey, m_OutputKeywordList);
}
if (!m_OutputProjectionRef.empty())
{
itk::EncapsulateMetaData<std::string>(outputDict, MetaDataKey::ProjectionRefKey, m_OutputProjectionRef);
......
......@@ -221,7 +221,7 @@ int otbVectorDataIntoImageProjectionFilterCompareImplTest(int itkNotUsed(argc),
vproj = VectorDataProjectionFilterType::New();
vproj->SetInput(vdextract->GetOutput());
vproj->SetInputProjectionRef(vdReader->GetOutput()->GetProjectionRef());
vproj->SetOutputKeywordList(reader->GetOutput()->GetImageKeywordlist());
vproj->SetOutputImageMetadata(&reader->GetOutput()->GetImageMetadata());
vproj->SetOutputProjectionRef(reader->GetOutput()->GetProjectionRef());
vproj->SetOutputOrigin(reader->GetOutput()->GetOrigin());
vproj->SetOutputSpacing(reader->GetOutput()->GetSignedSpacing());
......
......@@ -58,7 +58,7 @@ int otbVectorDataProjectionFilterFromMapToSensor(int argc, char* argv[])
vectorDataProjection->SetInput(reader->GetOutput());
vectorDataProjection->SetOutputKeywordList(imageReader->GetOutput()->GetImageKeywordlist());
vectorDataProjection->SetOutputImageMetadata(&imageReader->GetOutput()->GetImageMetadata());
vectorDataProjection->SetOutputOrigin(imageReader->GetOutput()->GetOrigin());
vectorDataProjection->SetOutputSpacing(imageReader->GetOutput()->GetSignedSpacing());
......
......@@ -56,7 +56,7 @@ int otbVectorDataTransformFilter(int itkNotUsed(argc), char* argv[])
VDProjectionFilterType::Pointer vdproj = VDProjectionFilterType::New();
vdproj->SetInput(vdreader->GetOutput());
vdproj->SetInputProjectionRef(vdreader->GetOutput()->GetProjectionRef());
vdproj->SetOutputKeywordList(reader->GetOutput()->GetImageKeywordlist());
vdproj->SetOutputImageMetadata(&reader->GetOutput()->GetImageMetadata());
vdproj->SetOutputProjectionRef(reader->GetOutput()->GetProjectionRef());
// Test the translation using the ApplyTransformTo
......@@ -78,7 +78,7 @@ int otbVectorDataTransformFilter(int itkNotUsed(argc), char* argv[])
VDProjectionFilterType::Pointer reverseVdProj = VDProjectionFilterType::New();
reverseVdProj->SetInput(transformFilter->GetOutput());
reverseVdProj->SetOutputProjectionRef(vdreader->GetOutput()->GetProjectionRef());
reverseVdProj->SetInputKeywordList(reader->GetOutput()->GetImageKeywordlist());
reverseVdProj->SetInputImageMetadata(&reader->GetOutput()->GetImageMetadata());
reverseVdProj->SetInputProjectionRef(reader->GetOutput()->GetProjectionRef());
// Write the vectordata
......
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