Commit 17c1c8b1 authored by Julien Osman's avatar Julien Osman

REFAC: Export the Geom Metadata through GDALImageIO

parent bdeaff2b
Pipeline #4963 failed with stages
in 85 minutes and 15 seconds
......@@ -237,10 +237,8 @@ void ImageMetadataBase::ToKeywordlist(Keywordlist& kwl) const
oss.str("");
if (kv.first == MDGeom::RPC)
{
// To be completed by ImageIO
oss << std::string("<RPCParam>");
// TODO: replace this std::string by a correct serialization of the RPCParam when implemented
// Projection::RPCParam rpcStruct = boost::any_cast<Projection::RPCParam>(kv.second);
// cast_string << rpcStruct;
}
else if (kv.first == MDGeom::ProjectionEPSG)
{
......@@ -248,10 +246,8 @@ void ImageMetadataBase::ToKeywordlist(Keywordlist& kwl) const
}
else if (kv.first == MDGeom::GCP)
{
// To be completed by ImageIO
oss << std::string("<GCPParam>");
// TODO: replace this std::string by a correct serialization of the GCPParam when implemented
// Projection::GCPParam gcpStruct = boost::any_cast<Projection::GCPParam>(kv.second);
// cast_string << gcpStruct;
}
else if (kv.first == MDGeom::SensorGeometry)
{
......
......@@ -78,6 +78,7 @@ public:
size_t GetPixelBytes() const;
Projection::GCPParam GetGCPParam() const;
void SetGCPParam(Projection::GCPParam gcpParam);
protected:
GDALDatasetWrapper();
......
......@@ -168,4 +168,24 @@ Projection::GCPParam GDALDatasetWrapper::GetGCPParam() const
return gcpParam;
}
void GDALDatasetWrapper::SetGCPParam(Projection::GCPParam gcpParam)
{
int nGCPCount = gcpParam.GCPs.size();
GDAL_GCP gcps[nGCPCount];
GDAL_GCP *gcpIt = gcps;
for (auto otbGcpIt = gcpParam.GCPs.cbegin() ; otbGcpIt != gcpParam.GCPs.cend() ; ++otbGcpIt, gcpIt++)
{
GDAL_GCP gdalGcp;
gdalGcp.pszId = const_cast<char*>(otbGcpIt->m_Id.c_str());
gdalGcp.pszInfo = const_cast<char*>(otbGcpIt->m_Info.c_str());
gdalGcp.dfGCPPixel = otbGcpIt->m_GCPCol;
gdalGcp.dfGCPLine = otbGcpIt->m_GCPRow;
gdalGcp.dfGCPX = otbGcpIt->m_GCPX;
gdalGcp.dfGCPY = otbGcpIt->m_GCPY;
gdalGcp.dfGCPZ = otbGcpIt->m_GCPZ;
*gcpIt = gdalGcp;
}
m_Dataset->SetGCPs(nGCPCount, gcps, gcpParam.GCPProjection.c_str());
}
} // end namespace otb
......@@ -1872,6 +1872,32 @@ void GDALImageIO::KeywordlistToMetadata(ImageMetadataBase::Keywordlist kwl, int
{
SetMetadataValue("MDGeomNames[MDGeom::SensorGeometry].", kv.second.c_str(), band);
}
else if (kv.first == MetaData::MDGeomNames.left.at(MDGeom::RPC))
{
// RPC Models are exported directly from the ImageMetadata.
Projection::RPCParam rpcStruct = boost::any_cast<Projection::RPCParam>(m_Imd[MDGeom::RPC]);
this->SetAs("RPC/LINE_OFF", rpcStruct.LineOffset);
this->SetAs("RPC/SAMP_OFF", rpcStruct.SampleOffset);
this->SetAs("RPC/LAT_OFF", rpcStruct.LatOffset);
this->SetAs("RPC/LONG_OFF", rpcStruct.LonOffset);
this->SetAs("RPC/HEIGHT_OFF", rpcStruct.HeightOffset);
this->SetAs("RPC/LINE_SCALE", rpcStruct.LineScale);
this->SetAs("RPC/SAMP_SCALE", rpcStruct.SampleScale);
this->SetAs("RPC/LAT_SCALE", rpcStruct.LatScale);
this->SetAs("RPC/LONG_SCALE", rpcStruct.LonScale);
this->SetAs("RPC/HEIGHT_SCALE", rpcStruct.HeightScale);
this->SetAsVector("RPC/LINE_NUM_COEFF", std::vector<double> (rpcStruct.LineNum, rpcStruct.LineNum + 20 / sizeof(double)), ' ');
this->SetAsVector("RPC/LINE_DEN_COEFF", std::vector<double> (rpcStruct.LineDen, rpcStruct.LineDen + 20 / sizeof(double)), ' ');
this->SetAsVector("RPC/SAMP_NUM_COEFF", std::vector<double> (rpcStruct.SampleNum, rpcStruct.SampleNum + 20 / sizeof(double)), ' ');
this->SetAsVector("RPC/SAMP_DEN_COEFF", std::vector<double> (rpcStruct.SampleDen, rpcStruct.SampleDen + 20 / sizeof(double)), ' ');
}
else if (kv.first == MetaData::MDGeomNames.left.at(MDGeom::GCP))
{
// GCPs are exported directly from the ImageMetadata.
this->m_Dataset->SetGCPParam(boost::any_cast<Projection::GCPParam>(m_Imd[MDGeom::GCP]));
}
SetMetadataValue(kv.first.c_str(), kv.second.c_str(), band);
}
}
......
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