From 492432a4fc8d89a038ce7e0ee1bb5fdac5742c46 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?C=C3=A9dric=20Traizet?= <cedric.traizet@c-s.fr>
Date: Wed, 30 Sep 2020 15:36:17 +0200
Subject: [PATCH] BUG: update the GenericRSResampleImageFilter test to check
 that the output projection is correct

---
 .../test/otbGenericRSResampleImageFilter.cxx    | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/Modules/Filtering/Projection/test/otbGenericRSResampleImageFilter.cxx b/Modules/Filtering/Projection/test/otbGenericRSResampleImageFilter.cxx
index 13fbd123fc..e5dddaee19 100644
--- a/Modules/Filtering/Projection/test/otbGenericRSResampleImageFilter.cxx
+++ b/Modules/Filtering/Projection/test/otbGenericRSResampleImageFilter.cxx
@@ -113,10 +113,9 @@ int otbGenericRSResampleImageFilter(int argc, char* argv[])
   origin[1] = strtod(argv[4], nullptr); // Origin northing
   orthoRectifFilter->SetOutputOrigin(origin);
 
-  std::string wkt =
-      otb::SpatialReference::FromUTM(atoi(argv[9]), atoi(argv[10]) ? otb::SpatialReference::hemisphere::north : otb::SpatialReference::hemisphere::south)
-          .ToWkt();
-  orthoRectifFilter->SetOutputProjectionRef(wkt);
+  auto inputSpatialRef = otb::SpatialReference::FromUTM(atoi(argv[9]), atoi(argv[10]) ? otb::SpatialReference::hemisphere::north : otb::SpatialReference::hemisphere::south);
+
+  orthoRectifFilter->SetOutputProjectionRef(inputSpatialRef.ToWkt());
 
   // Displacement Field spacing
   VectorImageType::SpacingType gridSpacing;
@@ -138,5 +137,15 @@ int otbGenericRSResampleImageFilter(int argc, char* argv[])
   writer->SetNumberOfDivisionsTiledStreaming(4);
   writer->Update();
 
+  auto outputProjectionRef = orthoRectifFilter->GetOutput()->GetProjectionRef();
+  if (outputProjectionRef.empty() ||
+    otb::SpatialReference::FromDescription(outputProjectionRef) != inputSpatialRef)
+  {
+    std::cout << "Input and output projection don't match. "
+              << "The output projection is: "
+              << outputProjectionRef
+              << std::endl;
+    return EXIT_FAILURE;
+  }
   return EXIT_SUCCESS;
 }
-- 
GitLab