diff --git a/Modules/Core/Metadata/include/otbGeometryMetadata.h b/Modules/Core/Metadata/include/otbGeometryMetadata.h index ccd902ecce298e49760467685d104a208386760a..bcb9b903f37a89dc4888b7da4dab170b5a96767b 100644 --- a/Modules/Core/Metadata/include/otbGeometryMetadata.h +++ b/Modules/Core/Metadata/include/otbGeometryMetadata.h @@ -116,6 +116,11 @@ struct OTBMetadata_EXPORT GCPParam */ struct OTBMetadata_EXPORT RPCParam { + // Constructors + RPCParam() = default; + RPCParam( const RPCParam & ); // CopyConstructible required for boost::any + RPCParam& operator=(RPCParam); //CopyAssignment optional for boost::any + // Offsets double LineOffset = 0.0; double SampleOffset = 0.0; diff --git a/Modules/Core/Metadata/src/otbGeometryMetadata.cxx b/Modules/Core/Metadata/src/otbGeometryMetadata.cxx index 0dadc355c40c57bf0575a36db318f76348ca54b9..dcb21155b2ad2a874c07a7ba3016ea4e1a24f2f0 100644 --- a/Modules/Core/Metadata/src/otbGeometryMetadata.cxx +++ b/Modules/Core/Metadata/src/otbGeometryMetadata.cxx @@ -77,6 +77,49 @@ std::string GCPParam::ToJSON(bool multiline) const return oss.str(); } +RPCParam::RPCParam( const RPCParam & other ) + : LineOffset(other.LineOffset), + SampleOffset(other.SampleOffset), + LatOffset(other.LatOffset), + LonOffset(other.LonOffset), + HeightOffset(other.HeightOffset), + LineScale(other.LineScale), + SampleScale(other.SampleScale), + LatScale(other.LatScale), + LonScale(other.LonScale), + HeightScale(other.HeightScale) +{ + for(int i = 0 ; i < 20 ; ++i) + { + LineNum[i] = other.LineNum[i]; + LineDen[i] = other.LineDen[i]; + SampleNum[i] = other.SampleNum[i]; + SampleDen[i] = other.SampleDen[i]; + } +} + +RPCParam& RPCParam::operator=(RPCParam other) +{ + LineOffset = other.LineOffset; + SampleOffset = other.SampleOffset; + LatOffset = other.LatOffset; + LonOffset = other.LonOffset; + HeightOffset = other.HeightOffset; + LineScale = other.LineScale; + SampleScale = other.SampleScale; + LatScale = other.LatScale; + LonScale = other.LonScale; + HeightScale = other.HeightScale; + for(int i = 0 ; i < 20 ; ++i) + { + LineNum[i] = other.LineNum[i]; + LineDen[i] = other.LineDen[i]; + SampleNum[i] = other.SampleNum[i]; + SampleDen[i] = other.SampleDen[i]; + } + return *this; +} + std::string RPCParam::ToJSON(bool multiline) const { std::ostringstream oss; diff --git a/Modules/Core/Metadata/src/otbImageMetadataInterfaceBase.cxx b/Modules/Core/Metadata/src/otbImageMetadataInterfaceBase.cxx index 7d662a217eb6c8101c25a4a53406e729e252a935..d4351f90624823e5b7794c017806374c5d056d01 100644 --- a/Modules/Core/Metadata/src/otbImageMetadataInterfaceBase.cxx +++ b/Modules/Core/Metadata/src/otbImageMetadataInterfaceBase.cxx @@ -718,7 +718,8 @@ const boost::any& ImageMetadataInterfaceBase::FetchRPC( coeffs = mds.GetAsVector("RPC/SAMP_DEN_COEFF",' ',20); std::copy(coeffs.begin(), coeffs.end(), rpcStruct.SampleDen); - m_Imd.Add(MDGeom::RPC, rpcStruct); + boost::any to_append = rpcStruct; + m_Imd.Add(MDGeom::RPC, to_append); return m_Imd[MDGeom::RPC]; } diff --git a/Modules/Core/Transform/include/otbRPCTransformBase.hxx b/Modules/Core/Transform/include/otbRPCTransformBase.hxx index d75c7d68b354f4d1add9a1180bb0fb28487cb6ee..1c04f39c664808b645909eb752346337d38f3f92 100644 --- a/Modules/Core/Transform/include/otbRPCTransformBase.hxx +++ b/Modules/Core/Transform/include/otbRPCTransformBase.hxx @@ -33,6 +33,9 @@ bool RPCTransformBase::SetMeta return false; try { + const boost::any any_rpc = imd[MDGeom::RPC]; //TODO: Segfault here. + if (any_rpc.empty()) + return false; Projection::RPCParam newParam = boost::any_cast(imd[MDGeom::RPC]); this->m_RPCParam = std::make_unique(newParam); } diff --git a/Modules/Filtering/Projection/include/otbGenericRSResampleImageFilter.hxx b/Modules/Filtering/Projection/include/otbGenericRSResampleImageFilter.hxx index 3bd2c610b09a1b1bf371c1bd52335f402f118959..b500e572aeaa37f14051c14c5248850ad8479179 100644 --- a/Modules/Filtering/Projection/include/otbGenericRSResampleImageFilter.hxx +++ b/Modules/Filtering/Projection/include/otbGenericRSResampleImageFilter.hxx @@ -198,7 +198,7 @@ void GenericRSResampleImageFilter::SetOutputParameter this->SetOutputStartIndex(src->GetLargestPossibleRegion().GetIndex()); this->SetOutputSize(src->GetLargestPossibleRegion().GetSize()); this->SetOutputProjectionRef(src->GetProjectionRef()); - this->SetOutputKeywordList(src->GetImageKeywordlist()); + this->GetOutput()->SetImageMetadata(src->GetImageKeywordlist()); } /** @@ -214,7 +214,7 @@ void GenericRSResampleImageFilter::SetOutputParameter this->SetOutputStartIndex(image->GetLargestPossibleRegion().GetIndex()); this->SetOutputSize(image->GetLargestPossibleRegion().GetSize()); this->SetOutputProjectionRef(image->GetProjectionRef()); - this->SetOutputKeywordList(image->GetImageKeywordlist()); + this->GetOutput()->SetImageMetadata(image->GetImageKeywordlist()); } /**