Skip to content
Snippets Groups Projects
Commit b9121977 authored by Julien Osman's avatar Julien Osman
Browse files

ENH: Add GeomMetadataSupplier::FetchRPC

parent 716e91b9
No related branches found
No related tags found
No related merge requests found
......@@ -39,3 +39,19 @@ adjustment_0.adj_param_4.lock_flag : 0
adjustment_0.adj_param_4.parameter : 0
adjustment_0.adj_param_4.sigma : 0.1
adjustment_0.adj_param_4.units : degrees
{"LineOffset": "14522",
"SampleOffset": "13779",
"LatOffset": "43.5668",
"LonOffset": "1.4635",
"HeightOffset": "242",
"LineScale": "14767",
"SampleScale": "13799",
"LatScale": "0.0881",
"LonScale": "0.1095",
"HeightScale": "500",
"LineNum": [ "-0.00139825", "0.00153793", "-0.986303", "0.0160753", "3.45261e-05", "-1.10444e-06", "0.00025058", "-0.000783885", "0.00210043", "-5.89713e-06", "-8.42682e-07", "5.24613e-08", "2.93096e-05", "0", "-8.65437e-06", "-4.4754e-05", "-1.0574e-05", "4.18275e-07", "-4.687e-06", "1.93054e-07", ],
"LineDen": [ "1", "3.82226e-05", "0.000565666", "0.00027757", "1.71173e-05", "-4.27783e-07", "-2.03092e-06", "6.16391e-06", "-2.06465e-05", "1.08768e-05", "4.17567e-08", "5.94172e-08", "-4.37271e-06", "0", "3.06573e-08", "0.00043593", "7.99703e-08", "0", "-1.43435e-05", "2.29249e-08", ],
"SampleNum": [ "-0.00263535", "1.00384", "0.0034115", "0.000261524", "-0.00232656", "0.000620898", "-0.000415032", "0.00128362", "-0.00119353", "7.47621e-06", "2.39993e-06", "-2.14036e-05", "-4.92957e-05", "-1.14876e-05", "8.27706e-05", "-7.63615e-05", "-2.79215e-07", "3.04261e-07", "7.00103e-06", "-2.55119e-08", ],
"SampleDen": [ "1", "0.00136456", "0.00234838", "-0.000621177", "-5.99001e-05", "1.56209e-06", "-1.88818e-06", "-4.23341e-06", "3.14449e-05", "-1.20077e-05", "-1.56497e-07", "-7.45329e-08", "1.97967e-06", "0", "-1.26249e-07", "-1.4791e-06", "-5.68974e-08", "3.27442e-08", "1.06612e-07", "1.69648e-08", ],
}
......@@ -23,9 +23,11 @@
#include <fstream>
#include <boost/algorithm/string.hpp>
#include <boost/any.hpp>
#include "OTBMetadataExport.h"
#include "otbMetadataSupplierInterface.h"
#include "otbImageMetadata.h"
namespace otb
......@@ -61,6 +63,13 @@ public:
int GetNbBands() const override;
/**
* @brief Fill the ImageMetadata with the data from the geom file
*
* @param imd The ImageMetadata to fill
*/
const boost::any& FetchRPC(ImageMetadata & imd);
/**
* @brief Writes the content of the Geom file into a string
*
......
......@@ -18,7 +18,12 @@
* limitations under the License.
*/
#include <iomanip>
#include <iostream>
#include "otbGeomMetadataSupplier.h"
#include "otbMetaDataKey.h"
#include "otbGeometryMetadata.h"
namespace otb
{
......@@ -50,6 +55,56 @@ int GeomMetadataSupplier::GetNbBands() const
return 0;
}
const boost::any& GeomMetadataSupplier::FetchRPC(ImageMetadata & imd)
{
Projection::RPCParam rpcStruct;
rpcStruct.LineOffset = this->GetAs<double>("line_off");
rpcStruct.SampleOffset = this->GetAs<double>("samp_off");
rpcStruct.LatOffset = this->GetAs<double>("lat_off");
rpcStruct.LonOffset = this->GetAs<double>("long_off");
rpcStruct.HeightOffset = this->GetAs<double>("height_off");
rpcStruct.LineScale = this->GetAs<double>("line_scale");
rpcStruct.SampleScale = this->GetAs<double>("samp_scale");
rpcStruct.LatScale = this->GetAs<double>("lat_scale");
rpcStruct.LonScale = this->GetAs<double>("long_scale");
rpcStruct.HeightScale = this->GetAs<double>("height_scale");
std::vector<double> coeffs;
int loop = 0;
std::stringstream path;
for (auto & coeff : rpcStruct.LineNum)
{
path.str("");
path << "line_num_coeff_" << std::setfill('0') << std::setw(2) << loop++;
coeff = this->GetAs<double>(path.str());
}
loop = 0;
for (auto & coeff : rpcStruct.LineDen)
{
path.str("");
path << "line_den_coeff_" << std::setfill('0') << std::setw(2) << loop++;
coeff = this->GetAs<double>(path.str());
}
loop = 0;
for (auto & coeff : rpcStruct.SampleNum)
{
path.str("");
path << "samp_num_coeff_" << std::setfill('0') << std::setw(2) << loop++;
coeff = this->GetAs<double>(path.str());
}
loop = 0;
for (auto & coeff : rpcStruct.SampleDen)
{
path.str("");
path << "samp_den_coeff_" << std::setfill('0') << std::setw(2) << loop++;
coeff = this->GetAs<double>(path.str());
}
imd.Add(MDGeom::RPC, rpcStruct);
return imd[MDGeom::RPC];
}
std::string GeomMetadataSupplier::PrintSelf()
{
std::ostringstream oss;
......
......@@ -58,6 +58,12 @@ int otbGeomMetadataSupplierTest(int itkNotUsed(argc), char* argv[])
}
}
file << '\n';
otb::ImageMetadata imd;
mds.FetchRPC(imd);
file << boost::any_cast<otb::Projection::RPCParam>(imd[otb::MDGeom::RPC]).ToJSON(true) << '\n';
file.close();
return EXIT_SUCCESS;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment