Commit f249b182 authored by Julien Osman's avatar Julien Osman
Browse files

WIP: Fix reading RPC from GEOM for Pleiades

parent b7e593a6
Pipeline #11125 passed with stages
in 107 minutes and 58 seconds
# column row longitude latitude elevation
10 10 1.3619678304742049 43.685679307528154 255.0
60 10 1.362269915752421 43.68568138233786 255.0
110 10 1.3625720040752514 43.68568345638775 255.0
160 10 1.3628740954430656 43.68568552967785 255.0
210 10 1.3631761898562327 43.685687602208176 255.0
260 10 1.3634782873151208 43.68568967397878 255.0
10 60 1.3619690059603062 43.68545371966921 255.0
60 60 1.362271090845755 43.685455793356994 255.0
110 60 1.3625731787760083 43.68545786628494 255.0
160 60 1.3628752697514357 43.685459938453086 255.0
210 60 1.3631773637724058 43.68546200986146 255.0
260 60 1.3634794608392868 43.685464080510094 255.0
10 110 1.3619701802586466 43.68522813138672 255.0
60 110 1.362272264751236 43.685230203952486 255.0
110 110 1.3625743522888205 43.68523227575841 255.0
160 110 1.36287644287177 43.68523434680452 255.0
210 110 1.363178536500452 43.68523641709085 255.0
260 110 1.3634806331752352 43.685238486617436 255.0
10 160 1.3619713533675186 43.685002542681254 255.0
60 160 1.3622734374671568 43.68500461412492 255.0
110 160 1.3625755246119815 43.685006684808734 255.0
160 160 1.3628776148023616 43.68500875473273 255.0
210 160 1.3631797080386652 43.68501082389693 255.0
260 160 1.3634818043212602 43.68501289230138 255.0
10 210 1.3619725252852164 43.68477695355337 255.0
60 210 1.362274608991812 43.68477902387485 255.0
110 210 1.3625766957437855 43.68478109343648 255.0
160 210 1.3628787855415057 43.684783162238276 255.0
210 210 1.3631808783853407 43.684785230280276 255.0
260 210 1.3634829742756576 43.68478729756251 255.0
10 260 1.361973696010035 43.684551364003646 255.0
60 260 1.3622757793234972 43.68455343320287 255.0
110 260 1.362577865682529 43.68455550164222 255.0
160 260 1.362879955087499 43.68455756932174 255.0
210 260 1.363182047538775 43.684559636241445 255.0
260 260 1.3634841430367244 43.68456170240138 255.0
10 10 1.361964797875297 43.68568154265233 255
10 60 1.3619659733772 43.68545595480884 255
10 110 1.361967147691359 43.68523036654181 255
10 160 1.361968320816069 43.68500477785178 255
10 210 1.361969492749621 43.68477918873934 255
10 260 1.361970663490313 43.68455359920505 255
60 10 1.362266883126997 43.68568361748085 255
60 60 1.362268058236132 43.68545802851544 255
60 110 1.362269232157431 43.68523243912639 255
60 160 1.362270404889188 43.68500684931427 255
60 210 1.362271576429697 43.68478125907965 255
60 260 1.362272746777254 43.6845556684231 255
110 10 1.362568971423306 43.68568569154957 255
110 60 1.362570146139862 43.68546010146221 255
110 110 1.362571319668492 43.68523451095113 255
110 160 1.362572492007488 43.68500892001691 255
110 210 1.362573663155145 43.6847833286601 255
110 260 1.362574833109759 43.68455773688128 255
160 10 1.362871062764593 43.68568776485848 255
160 60 1.362872237088761 43.68546217364918 255
160 110 1.362873410224912 43.68523658201607 255
160 160 1.362874582171338 43.68501098995972 255
160 210 1.362875752926334 43.68478539748072 255
160 260 1.362876922488197 43.68455980457963 255
210 10 1.363173157151227 43.68568983740764 255
210 60 1.363174331083198 43.68546424507637 255
210 110 1.363175503827059 43.68523865232122 255
210 160 1.363176675381105 43.68501305914275 255
210 210 1.363177845743632 43.68478746554155 255
210 260 1.363179014912935 43.68456187151816 255
260 10 1.363475254583577 43.68569190919705 255
260 60 1.363476428123539 43.68546631574382 255
260 110 1.363477600475302 43.68524072186663 255
260 160 1.363478771637159 43.68501512756603 255
260 210 1.363479941607406 43.6847895328426 255
260 260 1.363481110384341 43.68456393769691 255
......@@ -70,7 +70,7 @@ public:
*
* @param imd The ImageMetadata to fill
*/
bool FetchRPC(ImageMetadata & imd);
bool FetchRPC(ImageMetadata & imd, const double lineOffset=0, const double sampleOffset=0);
/**
* @brief Fill the ImageMetadata with the GCP from the geom file
......
......@@ -93,7 +93,9 @@ int GeomMetadataSupplier::GetNbBands() const
return 1;
}
bool GeomMetadataSupplier::FetchRPC(ImageMetadata & imd)
bool GeomMetadataSupplier::FetchRPC(ImageMetadata & imd,
const double lineOffset,
const double sampleOffset)
{
bool hasValue;
GetMetadataValue("polynomial_format", hasValue);
......@@ -101,8 +103,8 @@ bool GeomMetadataSupplier::FetchRPC(ImageMetadata & imd)
return false;
Projection::RPCParam rpcStruct;
rpcStruct.LineOffset = this->GetAs<double>("line_off");
rpcStruct.SampleOffset = this->GetAs<double>("samp_off");
rpcStruct.LineOffset = this->GetAs<double>("line_off") + lineOffset;
rpcStruct.SampleOffset = this->GetAs<double>("samp_off") + sampleOffset;
rpcStruct.LatOffset = this->GetAs<double>("lat_off");
rpcStruct.LonOffset = this->GetAs<double>("long_off");
rpcStruct.HeightOffset = this->GetAs<double>("height_off");
......
......@@ -106,6 +106,8 @@ otb_add_test(NAME trTvRPCTransformTest_pl_hnord_geom COMMAND otbTransformTestDri
${INPUTDATA}/pleiades/pleiades-1.gcp2 # GCP
0.02 # GeoTol
0.1 # ImgTol
0.5 # lineOffset
0.5 # sampleOffset
)
otb_add_test(NAME trTvRPCTransformTest_pl_hnord_product COMMAND otbTransformTestDriver
......
......@@ -41,7 +41,7 @@ using GenericRSTransformType = otb::GenericRSTransform<double, 3, 3>;
using DistanceType = itk::Statistics::EuclideanDistanceMetric<PointType>;
using GeographicalDistanceType = otb::GeographicalDistance<PointType>;
int otbRPCTransformTest(int itkNotUsed(argc), char* argv[])
int otbRPCTransformTest(int argc, char* argv[])
{
bool success = true;
PointType imagePoint;
......@@ -52,6 +52,13 @@ int otbRPCTransformTest(int itkNotUsed(argc), char* argv[])
std::string gcpFileName(argv[2]);
double geoTol(atof(argv[3]));
double imgTol(atof(argv[4]));
double lineOffset(0);
double sampleOffset(0);
if(argc == 7)
{
lineOffset = atof(argv[5]);
sampleOffset = atof(argv[6]);
}
// Tools
auto imgDistance = DistanceType::New();
......@@ -69,7 +76,7 @@ int otbRPCTransformTest(int itkNotUsed(argc), char* argv[])
for (int loop = 0 ; loop < geomSupplier.GetNbBands() ; ++loop)
imd.Bands.emplace_back();
otb::ImageMetadataInterfaceFactory::CreateIMI(imd, geomSupplier);
geomSupplier.FetchRPC(imd);
geomSupplier.FetchRPC(imd, lineOffset, sampleOffset);
}
else
{
......
......@@ -611,6 +611,8 @@ otb_add_test(NAME ioTvGDALRPCTransformerTest_pl_hnord_geom
${INPUTDATA}/pleiades/pleiades-1.gcp2 # GCP
0.02 # GeoTol
0.1 # ImgTol
0.5 # lineOffset
0.5 # sampleOffset
)
otb_add_test(NAME ioTvGDALRPCTransformerTest_pl_hnord_product
......
......@@ -36,7 +36,7 @@ typedef std::vector<itk::Point<double, 3>> pointsContainerType;
typedef itk::Statistics::EuclideanDistanceMetric<otb::GDALRPCTransformer::PointType> DistanceType;
typedef otb::GeographicalDistance<otb::GDALRPCTransformer::PointType> GeographicalDistanceType;
int otbGDALRPCTransformerTest2(int itkNotUsed(argc), char* argv[])
int otbGDALRPCTransformerTest2(int argc, char* argv[])
{
bool success = true;
otb::GDALRPCTransformer::PointType imagePoint;
......@@ -47,6 +47,14 @@ int otbGDALRPCTransformerTest2(int itkNotUsed(argc), char* argv[])
std::string gcpFileName(argv[2]);
double geoTol(atof(argv[3]));
double imgTol(atof(argv[4]));
double lineOffset(0);
double sampleOffset(0);
if(argc == 7)
{
lineOffset = atof(argv[5]);
sampleOffset = atof(argv[6]);
}
// Tools
auto distance = DistanceType::New();
......@@ -60,7 +68,7 @@ int otbGDALRPCTransformerTest2(int itkNotUsed(argc), char* argv[])
for (int loop = 0 ; loop < geomSupplier.GetNbBands() ; ++loop)
imd.Bands.emplace_back();
otb::ImageMetadataInterfaceFactory::CreateIMI(imd, geomSupplier);
geomSupplier.FetchRPC(imd);
geomSupplier.FetchRPC(imd, lineOffset, sampleOffset);
}
else
{
......
......@@ -403,7 +403,10 @@ void ImageFileReader<TOutputImage, ConvertPixelTraits>::GenerateOutputInformatio
{
GeomMetadataSupplier geomSupplier(m_FilenameHelper->GetExtGEOMFileName(), m_FileName);
ImageMetadataInterfaceFactory::CreateIMI(imd, geomSupplier);
geomSupplier.FetchRPC(imd);
if(imd.Has(MDStr::Mission) && (imd[MDStr::Mission] == "Pléiades"))
geomSupplier.FetchRPC(imd, 0.5, 0.5);
else
geomSupplier.FetchRPC(imd);
geomSupplier.FetchGCP(imd);
otbLogMacro(Info, << "Loading metadata from external geom file " << m_FilenameHelper->GetExtGEOMFileName());
}
......
Supports Markdown
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