From 6df98a343518c7e58343bc20c8b5e640531e2f7f Mon Sep 17 00:00:00 2001
From: Manuel Grizonnet <manuel.grizonnet@orfeo-toolbox.org>
Date: Thu, 24 May 2012 10:43:58 +0200
Subject: [PATCH] COMP:disable polygons stiching in LargeScaleSegmentation
 application for gdal version inf to 1.8.0 and return a warning

---
 .../otbLargeScaleSegmentation.cxx             | 26 ++++++++++++-------
 1 file changed, 16 insertions(+), 10 deletions(-)

diff --git a/Applications/Segmentation/otbLargeScaleSegmentation.cxx b/Applications/Segmentation/otbLargeScaleSegmentation.cxx
index 47503dda35..3757f8b51c 100644
--- a/Applications/Segmentation/otbLargeScaleSegmentation.cxx
+++ b/Applications/Segmentation/otbLargeScaleSegmentation.cxx
@@ -293,7 +293,7 @@ private:
         otbAppLogINFO(<<"Use 8 connected neighborhood."<<std::endl);
         edisonVectorizationFilter->SetUse8Connected(use8connected);
 
-        //segmentation paramters
+        //segmentation parameters
         const unsigned int
             spatialRadius = static_cast<unsigned int> (this->GetParameterInt("filter.meanshiftedison.spatialr"));
         const unsigned int
@@ -391,15 +391,21 @@ private:
     if(IsParameterEnabled("stitch"))
       {
       otbAppLogINFO(<<"Segmentation done, stiching polygons ...");
-      FusionFilterType::Pointer fusionFilter = FusionFilterType::New();
-      fusionFilter->SetInput(GetParameterFloatVectorImage("in"));
-      fusionFilter->SetOGRDataSource(ogrDS);
-      FloatVectorImageType::SizeType streamSize;
-      streamSize.Fill(tileSize);
-      std::cout<<"Stream size: "<<streamSize<<std::endl;
-      fusionFilter->SetStreamSize(streamSize);
-      fusionFilter->SetLayerName(layerName);
-      fusionFilter->GenerateData();
+
+      #if GDAL_VERSION_NUM < 1800
+            itkWarningMacro("Stiching polygons is not supported by OGR v"
+                << GDAL_VERSION_NUM << ". Upgrade to a version >= 1.8.0, and recompile OTB.")
+      #else
+            FusionFilterType::Pointer fusionFilter = FusionFilterType::New();
+            fusionFilter->SetInput(GetParameterFloatVectorImage("in"));
+            fusionFilter->SetOGRDataSource(ogrDS);
+            FloatVectorImageType::SizeType streamSize;
+            streamSize.Fill(tileSize);
+            std::cout<<"Stream size: "<<streamSize<<std::endl;
+            fusionFilter->SetStreamSize(streamSize);
+            fusionFilter->SetLayerName(layerName);
+            fusionFilter->GenerateData();
+      #endif
       }
   }
     LabelImageType::Pointer     m_LabelImage;
-- 
GitLab