Commit e45643e3 authored by Julien Osman's avatar Julien Osman
Browse files

WIP: Add possibility to use "in-memory dataset" for multi-tile DEM

parent c6a9027c
......@@ -33,7 +33,7 @@ namespace otb
* This class is the single configuration and access point for
* elevation handling in images projections and localization
* functions. Since this class is a singleton, there is no New() method. The
* DEMHandler::Instance() method should be used instead.
* DEMHandler::GetInstance() method should be used instead.
*
* Please be aware that a proper instantiation and parameter setting
* of this class is advised before any call to geometric filters or
......@@ -141,6 +141,9 @@ public:
/** Clear the DEM list and close all DEM datasets */
void ClearDEMs();
/** Path to the in-memory vrt */
const std::string DEM_DATASET_PATH = "/vsimem/otb_dem_dataset.vrt";
protected:
DEMHandler();
......
......@@ -181,6 +181,7 @@ DEMHandler::~DEMHandler()
}
ClearDEMs();
VSIUnlink(DEM_DATASET_PATH.c_str());
}
void DEMHandler::OpenDEMFile(const std::string& path)
......@@ -195,6 +196,10 @@ void DEMHandler::OpenDEMDirectory(const std::string& DEMDirectory)
// TODO : RemoveOSSIM
OssimDEMHandler::Instance()->OpenDEMDirectory(DEMDirectory);
// Free the previous in-memory dataset (if any)
if (!m_DatasetList.empty())
VSIUnlink(DEM_DATASET_PATH.c_str());
auto demFiles = DEMDetails::GetFilesInDirectory(DEMDirectory);
for (const auto & file : demFiles)
{
......@@ -227,8 +232,11 @@ void DEMHandler::OpenDEMDirectory(const std::string& DEMDirectory)
vrtDatasetList[i] = m_DatasetList[i]->GetDataSet();
}
m_Dataset = static_cast<GDALDataset *> (GDALBuildVRT(nullptr, vrtSize, vrtDatasetList.data(),
nullptr, nullptr, nullptr));
auto close_me = GDALBuildVRT(DEM_DATASET_PATH.c_str(), vrtSize, vrtDatasetList.data(),
nullptr, nullptr, nullptr);
// Need to close the dataset, so it is flushed into memory.
GDALClose(close_me);
m_Dataset = static_cast<GDALDataset*>(GDALOpen(DEM_DATASET_PATH.c_str(), GA_ReadOnly));
m_DEMDirectories.push_back(DEMDirectory);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment