Commit af79f209 authored by Luc Hermitte's avatar Luc Hermitte

ENH: OTB-151/GeometriesProjectionFilter -- the filter now relies on kwlist and...

ENH: OTB-151/GeometriesProjectionFilter -- the filter now relies on kwlist and projection ref. No more metadatadict
parent d93c8680
......@@ -205,16 +205,9 @@ void otb::GeometriesProjectionFilter::DoFinalizeInitialisation()
{
m_Transform = InternalTransformType::New();
InputGeometriesType::ConstPointer input = this->GetInput();
const itk::MetaDataDictionary& inputDict = input->GetMetaDataDictionary();
OutputGeometriesType::Pointer output = this->GetOutput();
itk::MetaDataDictionary& outputDict = output->GetMetaDataDictionary();
// m_Transform->SetInputDictionary(input->GetMetaDataDictionary());
m_Transform->SetInputDictionary(inputDict);
m_Transform->SetOutputDictionary(output->GetMetaDataDictionary());
m_Transform->SetInputProjectionRef(m_InputProjectionRef);
// The InputProjectionRef can only be set once per layer, once the layer to
// process is known
// m_Transform->SetInputProjectionRef(m_InputProjectionRef);
m_Transform->SetOutputProjectionRef(m_OutputProjectionRef);
m_Transform->SetInputKeywordList(m_InputKeywordList);
m_Transform->SetOutputKeywordList(m_OutputKeywordList);
......@@ -227,7 +220,9 @@ void otb::GeometriesProjectionFilter::DoFinalizeInitialisation()
m_Transform->SetOutputSpacing(OutputImageReference.GetSpacing());
m_Transform->SetOutputOrigin(OutputImageReference.GetOrigin());
m_Transform->InstanciateTransform();
// As the InputProjectionRef can't be known yet, InstanciateTransform() will
// be called from DoProcessLayer
// m_Transform->InstanciateTransform();
m_TransformationFunctor->SetOnePointTransformation(m_Transform);
......@@ -236,16 +231,8 @@ void otb::GeometriesProjectionFilter::DoFinalizeInitialisation()
// only the m_Transform will know
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);
}
// InputGeometriesType::ConstPointer input = this->GetInput();
OutputGeometriesType::Pointer output = this->GetOutput();
output->SetImageReference(OutputImageReference);
}
......@@ -268,6 +255,11 @@ OGRSpatialReference* otb::GeometriesProjectionFilter::DoDefineNewLayerSpatialRef
/*virtual*/
void otb::GeometriesProjectionFilter::DoProcessLayer(ogr::Layer const& source, ogr::Layer & destination) const
{
// Finish the initialization phase as somethings depends on the current layer
// to process.
m_Transform->SetInputProjectionRef(source.GetProjectionRef());
m_Transform->InstanciateTransform();
// std::cout << "GPF::DoProcessLayer: L("<<source.GetName()<<") -> L("<<destination.GetName()<<") ...\n";
if (source != destination)
{
......
......@@ -148,11 +148,12 @@ public:
}
//@}
/**\name Projection references accessors and mutators */
/**\name Projection references accessors and mutators
* Projection references accessors and mutators.
* As the Input Projection Reference comes from the Input Geometries set, it
* can't be set independently.
*/
//@{
itkSetStringMacro(InputProjectionRef);
itkGetStringMacro(InputProjectionRef);
itkSetStringMacro(OutputProjectionRef);
itkGetStringMacro(OutputProjectionRef);
//@}
......@@ -175,7 +176,6 @@ private:
InternalTransformPointerType m_Transform;
//@}
std::string m_InputProjectionRef; // in WKT format!
std::string m_OutputProjectionRef; // in WKT format!
ImageKeywordlist m_InputKeywordList;
ImageKeywordlist m_OutputKeywordList;
......
......@@ -152,6 +152,7 @@ void otb::GeometriesSet::PrintSelf(std::ostream& os, itk::Indent indent) const
this->apply(Printer(os, indent));
}
#if 0
/*===========================================================================*/
/*=========================[ GetMetaDataDictionary ]=========================*/
/*===========================================================================*/
......@@ -176,3 +177,4 @@ itk::MetaDataDictionary const& otb::GeometriesSet::GetMetaDataDictionary() const
{
return const_cast <GeometriesSet *>(this)->GetMetaDataDictionary();
}
#endif
......@@ -113,11 +113,13 @@ public:
*/
bool IsSet() const;
#if 0
/**\name Meta data dictionary */
//@{
itk::MetaDataDictionary & GetMetaDataDictionary();
itk::MetaDataDictionary const& GetMetaDataDictionary() const;
//@}
#endif
/**\name Image reference (spacing + origin) */
//@{
......
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