Skip to content
Snippets Groups Projects
Commit 71e7d249 authored by Arnaud Jaen's avatar Arnaud Jaen
Browse files

TEST: Add a SQL request to REPACK the shapefile after stitching. This removes...

TEST: Add a SQL request to REPACK the shapefile after stitching. This removes the shapes marked as deleted in the dbf file.
parent ccbb64af
No related branches found
No related tags found
No related merge requests found
...@@ -30,12 +30,12 @@ int otbOGRLayerStreamStitchingFilter(int argc, char * argv[]) ...@@ -30,12 +30,12 @@ int otbOGRLayerStreamStitchingFilter(int argc, char * argv[])
std::cerr << " inputImage inputOGR outputOGR streamingSize" << std::endl; std::cerr << " inputImage inputOGR outputOGR streamingSize" << std::endl;
return EXIT_FAILURE; return EXIT_FAILURE;
} }
const char * infname = argv[1]; const char * infname = argv[1];
const char * inOGRfname = argv[2]; const char * inOGRfname = argv[2];
const char * tmpOGRfname = argv[3]; const char * tmpOGRfname = argv[3];
unsigned int size = atoi(argv[4]); unsigned int size = atoi(argv[4]);
/** Typedefs */ /** Typedefs */
const unsigned int Dimension = 2; const unsigned int Dimension = 2;
typedef float PixelType; typedef float PixelType;
...@@ -43,13 +43,13 @@ int otbOGRLayerStreamStitchingFilter(int argc, char * argv[]) ...@@ -43,13 +43,13 @@ int otbOGRLayerStreamStitchingFilter(int argc, char * argv[])
typedef otb::OGRLayerStreamStitchingFilter<ImageType> FilterType; typedef otb::OGRLayerStreamStitchingFilter<ImageType> FilterType;
typedef otb::ImageFileReader<ImageType> ReaderType; typedef otb::ImageFileReader<ImageType> ReaderType;
ReaderType::Pointer reader = ReaderType::New(); ReaderType::Pointer reader = ReaderType::New();
FilterType::Pointer filter = FilterType::New(); FilterType::Pointer filter = FilterType::New();
//first copy the input OGR file as it will be updated with the fusionned polygons //first copy the input OGR file as it will be updated with the fusionned polygons
itksys::SystemTools::CopyAFile(inOGRfname,tmpOGRfname,true); itksys::SystemTools::CopyAFile(inOGRfname,tmpOGRfname,true);
//Get the base name of the .shp file //Get the base name of the .shp file
std::string inPathName = itksys::SystemTools::GetFilenamePath(inOGRfname); std::string inPathName = itksys::SystemTools::GetFilenamePath(inOGRfname);
std::string inBaseName = itksys::SystemTools::GetFilenameWithoutExtension(inOGRfname); std::string inBaseName = itksys::SystemTools::GetFilenameWithoutExtension(inOGRfname);
...@@ -69,19 +69,24 @@ int otbOGRLayerStreamStitchingFilter(int argc, char * argv[]) ...@@ -69,19 +69,24 @@ int otbOGRLayerStreamStitchingFilter(int argc, char * argv[])
itksys::SystemTools::CopyAFile(in.c_str(),out.c_str(),true); itksys::SystemTools::CopyAFile(in.c_str(),out.c_str(),true);
const std::string layerName = outBaseName; const std::string layerName = outBaseName;
reader->SetFileName(infname); reader->SetFileName(infname);
reader->UpdateOutputInformation(); reader->UpdateOutputInformation();
ImageType::SizeType streamSize; ImageType::SizeType streamSize;
streamSize.Fill(size); streamSize.Fill(size);
otb::ogr::DataSource::Pointer ogrDS = otb::ogr::DataSource::New(tmpOGRfname, otb::ogr::DataSource::Modes::Update_LayerUpdate); otb::ogr::DataSource::Pointer ogrDS = otb::ogr::DataSource::New(tmpOGRfname, otb::ogr::DataSource::Modes::Update_LayerUpdate);
filter->SetInput(reader->GetOutput()); filter->SetInput(reader->GetOutput());
filter->SetOGRLayer(ogrDS->GetLayer(layerName)); filter->SetOGRLayer(ogrDS->GetLayer(layerName));
filter->SetStreamSize(streamSize); filter->SetStreamSize(streamSize);
filter->GenerateData(); filter->GenerateData();
//REPACK the layer to remove features marked as deleted in the Shapefile.
std::string sql("REPACK ");
sql = sql + layerName;
ogrDS->ExecuteSQL(sql , NULL, NULL);
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment