diff --git a/Data/Baseline/OTB/Images/prTvOrthoRectification_pleiades-1_DEMGTIFF.tif b/Data/Baseline/OTB/Images/prTvOrthoRectification_pleiades-1_DEMGTIFF.tif index 9ff1368571bae53cdd4158736c14989f493a1574..82d2b2abfd76bde0dd30a5676d8dee6a5f430b77 100644 --- a/Data/Baseline/OTB/Images/prTvOrthoRectification_pleiades-1_DEMGTIFF.tif +++ b/Data/Baseline/OTB/Images/prTvOrthoRectification_pleiades-1_DEMGTIFF.tif @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2200368da4dd12399e3df5c476891bf552d240d35be343c41c650d059b12ba00 -size 9589024 +oid sha256:06e9ec7f39f6289d72f7bd9d7ff258a5ee264f6695e21bedeac32da30396f920 +size 8014228 diff --git a/Data/Baseline/OTB/Images/prTvOrthoRectification_pleiades-1_DEMSRTM.tif b/Data/Baseline/OTB/Images/prTvOrthoRectification_pleiades-1_DEMSRTM.tif index e7e2a17eb68791d32d20a2c3f26330187fef6339..23e5b75be23c4e3fbd3007d674ee820dcc29caaf 100644 --- a/Data/Baseline/OTB/Images/prTvOrthoRectification_pleiades-1_DEMSRTM.tif +++ b/Data/Baseline/OTB/Images/prTvOrthoRectification_pleiades-1_DEMSRTM.tif @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:32cc257b2f2ea4bacba7b420cc6a3d8031f99831f6a9350fe5a51f5df449f5ca -size 9587130 +oid sha256:fefb90eed77369bd63d6de4922ed04ae5810d36a09bf322ff041e6a70340ae5a +size 8014228 diff --git a/Data/Baseline/OTB/Images/prTvOrthoRectification_pleiades-1_noDEM.tif b/Data/Baseline/OTB/Images/prTvOrthoRectification_pleiades-1_noDEM.tif index e8fdbf1b91d30976c94330de3a5e351239691f67..759fafcb3afc13634b7b9e8ab9374bb1c41a9734 100644 --- a/Data/Baseline/OTB/Images/prTvOrthoRectification_pleiades-1_noDEM.tif +++ b/Data/Baseline/OTB/Images/prTvOrthoRectification_pleiades-1_noDEM.tif @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b2b3e7d8702bca56b16ca6e5f89522451354a718588b0f65a09f9449fc5e7a8c -size 9586558 +oid sha256:d44b0600974780121bfe07db87863bc841266076f9e1b4b1e1f10c2acb19fe80 +size 8014228 diff --git a/Data/Input/pleiades/pleiades-1.gcp2 b/Data/Input/pleiades/pleiades-1.gcp2 index 8337a2d25b5e770001d72dac0f7067b739bd4130..edd595c82e219ad8a9a18ecbafb1bd51b443833d 100644 --- a/Data/Input/pleiades/pleiades-1.gcp2 +++ b/Data/Input/pleiades/pleiades-1.gcp2 @@ -1,37 +1,36 @@ -# 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 diff --git a/Modules/Core/Metadata/include/otbGeomMetadataSupplier.h b/Modules/Core/Metadata/include/otbGeomMetadataSupplier.h index 8b8e1223b5eb390c8bc01528a2368e437787da1e..3168f36ceb2df5c9a06ad3f355a0980189481888 100644 --- a/Modules/Core/Metadata/include/otbGeomMetadataSupplier.h +++ b/Modules/Core/Metadata/include/otbGeomMetadataSupplier.h @@ -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 diff --git a/Modules/Core/Metadata/src/otbGeomMetadataSupplier.cxx b/Modules/Core/Metadata/src/otbGeomMetadataSupplier.cxx index 670c4caefbfd9802b0fb5b77d19a15066d2ab45f..796d3d4793bd0cbf87653491e0517a910c20a373 100644 --- a/Modules/Core/Metadata/src/otbGeomMetadataSupplier.cxx +++ b/Modules/Core/Metadata/src/otbGeomMetadataSupplier.cxx @@ -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("line_off"); - rpcStruct.SampleOffset = this->GetAs("samp_off"); + rpcStruct.LineOffset = this->GetAs("line_off") + lineOffset; + rpcStruct.SampleOffset = this->GetAs("samp_off") + sampleOffset; rpcStruct.LatOffset = this->GetAs("lat_off"); rpcStruct.LonOffset = this->GetAs("long_off"); rpcStruct.HeightOffset = this->GetAs("height_off"); diff --git a/Modules/Core/Metadata/src/otbPleiadesImageMetadataInterface.cxx b/Modules/Core/Metadata/src/otbPleiadesImageMetadataInterface.cxx index d03db7f6fc3d64275f3b594f670f902adbc8e7b2..36cda9a1f2ce7b86f1273f0d01e6dda515f7d200 100644 --- a/Modules/Core/Metadata/src/otbPleiadesImageMetadataInterface.cxx +++ b/Modules/Core/Metadata/src/otbPleiadesImageMetadataInterface.cxx @@ -594,7 +594,7 @@ void PleiadesImageMetadataInterface::Parse(ImageMetadata &imd) // fill RPC model if (imd[MDStr::GeometricLevel] == "SENSOR") { - FetchRPC(imd, -0.5, -0.5); + FetchRPC(imd); } } // Product read by the DIMAP GDAL driver @@ -613,7 +613,7 @@ void PleiadesImageMetadataInterface::Parse(ImageMetadata &imd) // fill RPC model if (imd[MDStr::GeometricLevel] == "SENSOR") { - FetchRPC(imd, -0.5, -0.5); + FetchRPC(imd); } } // Geom case diff --git a/Modules/Core/Transform/test/CMakeLists.txt b/Modules/Core/Transform/test/CMakeLists.txt index 307be335e6feca3725addcbe77e43adae33ada17..0df4ed292f23ddeffae91f1653112e681470a7c5 100644 --- a/Modules/Core/Transform/test/CMakeLists.txt +++ b/Modules/Core/Transform/test/CMakeLists.txt @@ -100,14 +100,21 @@ otb_add_test(NAME trTvRPCTransformTest_worldview2 COMMAND otbTransformTestDriver 0.1 # ImgTol ) +#For issue 2293, the baseline pleaides-1.geom had a shift of 0.5 pixels +#in the geom generated with OTB 7.4, the baseline was wrong. To keep the compatibility, we added this shift in the tests otb_add_test(NAME trTvRPCTransformTest_pl_hnord_geom COMMAND otbTransformTestDriver otbRPCTransformTest ${INPUTDATA}/pleiades/pleiades-1.geom # Geom ${INPUTDATA}/pleiades/pleiades-1.gcp2 # GCP 0.02 # GeoTol 0.1 # ImgTol + 0.5 # lineOffset + 0.5 # sampleOffset ) +#For issue 2293, we had to regenerate the baseline pleiades-1.gcp2 because there was a shift +#in the gcps that was fixed by the MR 918 +#To regenerate the gcps, see the wiki on the gitlab otb_add_test(NAME trTvRPCTransformTest_pl_hnord_product COMMAND otbTransformTestDriver otbRPCTransformTest LARGEINPUT{PLEIADES/TLSE_JP2_DIMAPv2_PRIMARY_PMS_lossless_12bits/IMGPHR_201222215194743808/IMG_PHR1A_PMS_201201151100183_SEN_IPU_20120222_0901-001_R1C1.JP2} # Product diff --git a/Modules/Core/Transform/test/otbRPCTransformTest.cxx b/Modules/Core/Transform/test/otbRPCTransformTest.cxx index f259fa1bab4276e5d61e804fb63bd1a518674d65..97634445f788b09a5c325dab52177abf99f864ec 100644 --- a/Modules/Core/Transform/test/otbRPCTransformTest.cxx +++ b/Modules/Core/Transform/test/otbRPCTransformTest.cxx @@ -41,7 +41,7 @@ using GenericRSTransformType = otb::GenericRSTransform; using DistanceType = itk::Statistics::EuclideanDistanceMetric; using GeographicalDistanceType = otb::GeographicalDistance; -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 { diff --git a/Modules/IO/IOGDAL/test/CMakeLists.txt b/Modules/IO/IOGDAL/test/CMakeLists.txt index a9e1763c746140689a2ee87e2f8f0a0a3f8a195e..27014d08506f1113751c373826ce6574a9cdcfb5 100644 --- a/Modules/IO/IOGDAL/test/CMakeLists.txt +++ b/Modules/IO/IOGDAL/test/CMakeLists.txt @@ -604,6 +604,8 @@ otb_add_test(NAME ioTvGDALRPCTransformerTest_worldview2 0.1 # ImgTol ) +#For issue 2293, we had to regenerate the baseline pleaides-1.geom because there was a shift +#in the geom generated with OTB 7.4, the baseline was wrong. To keep the compatibility, we added this shift in the tests otb_add_test(NAME ioTvGDALRPCTransformerTest_pl_hnord_geom COMMAND otbIOGDALTestDriver otbGDALRPCTransformerTest2 @@ -611,8 +613,13 @@ 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 ) +#For issue 2293, we had to regenerate the baseline pleiades-1.gcp2 because there was a shift +#in the gcps that was fixed by the MR 918 +#To regenerate the gcps, see the wiki on the gitlab otb_add_test(NAME ioTvGDALRPCTransformerTest_pl_hnord_product COMMAND otbIOGDALTestDriver otbGDALRPCTransformerTest2 diff --git a/Modules/IO/IOGDAL/test/otbGDALRPCTransformerTest2.cxx b/Modules/IO/IOGDAL/test/otbGDALRPCTransformerTest2.cxx index d8e0d3204338f43443a3b3580d978f4b08ca7342..ef4c4a89f589d3647134f82b5ecf453ccf16fc9d 100644 --- a/Modules/IO/IOGDAL/test/otbGDALRPCTransformerTest2.cxx +++ b/Modules/IO/IOGDAL/test/otbGDALRPCTransformerTest2.cxx @@ -36,7 +36,7 @@ typedef std::vector> pointsContainerType; typedef itk::Statistics::EuclideanDistanceMetric DistanceType; typedef otb::GeographicalDistance 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 { diff --git a/Modules/IO/ImageIO/include/otbImageFileReader.hxx b/Modules/IO/ImageIO/include/otbImageFileReader.hxx index 75f880c30d1e7bdf48c0befac84de49252ee0d1d..378f8ad7dac45d868b971643f94271c41380cdf1 100644 --- a/Modules/IO/ImageIO/include/otbImageFileReader.hxx +++ b/Modules/IO/ImageIO/include/otbImageFileReader.hxx @@ -403,7 +403,10 @@ void ImageFileReader::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()); }