diff --git a/Code/Projections/otbGeometriesProjectionFilter.cxx b/Code/Projections/otbGeometriesProjectionFilter.cxx index d3297b54f812571c61ecbd41c9990b5147e7223f..b006e9bd73ac8531b0cd6dbf21ca8f806e864073 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 f77fb231320ab5e9c6a347a288a5f023341bdf06..aa273319e4332d834aa645c9a62cc353a44aadce 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 7bb9e7bb4c2f741c2c0fc42618d4dd898352c23e..00adaf9e675332d54f5e1caf61ee69e3b711e1b0 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 c366f352497bf6396ac3dc889bab7828d1751c76..8b2348a07742511d1185fcf0d68ad1904c0b9cad 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) */ //@{