From af79f209d59d5f4003685c43d9c9b733093ed6dd Mon Sep 17 00:00:00 2001 From: Luc Hermitte <luc.hermitte@c-s.fr> Date: Wed, 20 Jun 2012 19:13:12 +0200 Subject: [PATCH] ENH: OTB-151/GeometriesProjectionFilter -- the filter now relies on kwlist and projection ref. No more metadatadict --- .../otbGeometriesProjectionFilter.cxx | 34 +++++++------------ .../otbGeometriesProjectionFilter.h | 10 +++--- .../OGRAdapters/otbGeometriesSet.cxx | 2 ++ .../OGRAdapters/otbGeometriesSet.h | 2 ++ 4 files changed, 22 insertions(+), 26 deletions(-) diff --git a/Code/Projections/otbGeometriesProjectionFilter.cxx b/Code/Projections/otbGeometriesProjectionFilter.cxx index d3297b54f8..b006e9bd73 100644 --- a/Code/Projections/otbGeometriesProjectionFilter.cxx +++ b/Code/Projections/otbGeometriesProjectionFilter.cxx @@ -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) { diff --git a/Code/Projections/otbGeometriesProjectionFilter.h b/Code/Projections/otbGeometriesProjectionFilter.h index f77fb23132..aa273319e4 100644 --- a/Code/Projections/otbGeometriesProjectionFilter.h +++ b/Code/Projections/otbGeometriesProjectionFilter.h @@ -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; diff --git a/Code/UtilitiesAdapters/OGRAdapters/otbGeometriesSet.cxx b/Code/UtilitiesAdapters/OGRAdapters/otbGeometriesSet.cxx index 7bb9e7bb4c..00adaf9e67 100644 --- a/Code/UtilitiesAdapters/OGRAdapters/otbGeometriesSet.cxx +++ b/Code/UtilitiesAdapters/OGRAdapters/otbGeometriesSet.cxx @@ -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 diff --git a/Code/UtilitiesAdapters/OGRAdapters/otbGeometriesSet.h b/Code/UtilitiesAdapters/OGRAdapters/otbGeometriesSet.h index c366f35249..8b2348a077 100644 --- a/Code/UtilitiesAdapters/OGRAdapters/otbGeometriesSet.h +++ b/Code/UtilitiesAdapters/OGRAdapters/otbGeometriesSet.h @@ -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) */ //@{ -- GitLab