From 6923637706d9b2a98d69423e148330a39744f47d Mon Sep 17 00:00:00 2001 From: Remi Cresson <remi.cresson@irstea.fr> Date: Mon, 7 Mar 2022 17:15:59 +0100 Subject: [PATCH] FIX: throw an exception when the output image(s) cannot be written because of all samples rejected --- app/otbPatchesExtraction.cxx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/otbPatchesExtraction.cxx b/app/otbPatchesExtraction.cxx index 7b0ce456..a3da71f3 100644 --- a/app/otbPatchesExtraction.cxx +++ b/app/otbPatchesExtraction.cxx @@ -220,9 +220,16 @@ public: otbAppLogINFO("Number of samples rejected : " << sampler->GetNumberOfRejectedSamples()); // Save patches image - for (unsigned int i = 0 ; i < m_Bundles.size() ; i++) + if (sampler->GetNumberOfAcceptedSamples()>0) { - SetParameterOutputImage(m_Bundles[i].m_KeyOut, sampler->GetOutputPatchImages()[i]); + for (unsigned int i = 0 ; i < m_Bundles.size() ; i++) + { + SetParameterOutputImage(m_Bundles[i].m_KeyOut, sampler->GetOutputPatchImages()[i]); + } + } + else + { + otbAppLogFATAL("No patch to sample. Please check that your vector data falls inside your images, and no-data values."); } -- GitLab