diff --git a/include/extractor/raster_source.hpp b/include/extractor/raster_source.hpp index 633c0c661..f85144a55 100755 --- a/include/extractor/raster_source.hpp +++ b/include/extractor/raster_source.hpp @@ -126,7 +126,14 @@ class RasterSource class RasterContainer { public: - RasterContainer() = default; + RasterContainer() { ++count; } + ~RasterContainer() { + --count; + if (0 == count) { + LoadedSources.clear(); + LoadedSourcePaths.clear(); + } + } int LoadRasterSource(const std::string &path_string, double xmin, @@ -143,6 +150,7 @@ class RasterContainer private: static std::vector LoadedSources; static std::unordered_map LoadedSourcePaths; + static int count; }; } } diff --git a/src/extractor/raster_source.cpp b/src/extractor/raster_source.cpp index befae77b7..8c62cc8b2 100755 --- a/src/extractor/raster_source.cpp +++ b/src/extractor/raster_source.cpp @@ -81,6 +81,7 @@ RasterDatum RasterSource::GetRasterInterpolate(const int lon, const int lat) con // static member of Raster Container std::vector RasterContainer::LoadedSources; std::unordered_map RasterContainer::LoadedSourcePaths; +int RasterContainer::count = 0; // Load raster source into memory int RasterContainer::LoadRasterSource(const std::string &path_string,