From 5113894ca44ff3becef6a75c331ebaaff6d43dbc Mon Sep 17 00:00:00 2001 From: Andreas Engberg Date: Wed, 4 Feb 2026 12:02:23 +0100 Subject: [PATCH] Fix loading multiple instruments + cleanup --- .../parkersolarprobe/solarbrowsing.asset | 8 +- .../rendering/renderablesolarimagery.cpp | 13 +- .../renderablesolarimageryprojection.cpp | 4 +- .../util/spacecraftimagerymanager.cpp | 304 +++++++++--------- .../util/spacecraftimagerymanager.h | 16 +- modules/solarbrowsing/util/structs.h | 5 +- 6 files changed, 182 insertions(+), 168 deletions(-) diff --git a/data/assets/scene/solarsystem/missions/parkersolarprobe/solarbrowsing.asset b/data/assets/scene/solarsystem/missions/parkersolarprobe/solarbrowsing.asset index ca20c8c029..d8935fffe1 100644 --- a/data/assets/scene/solarsystem/missions/parkersolarprobe/solarbrowsing.asset +++ b/data/assets/scene/solarsystem/missions/parkersolarprobe/solarbrowsing.asset @@ -74,8 +74,8 @@ local StereoImagery = { Renderable = { -- Resolution of imagery, will be moved to metadata later Type = "RenderableSolarImagery", - RootPath = asset.resource("solarbrowsing/imagedata/stereo-a_euvi-171"), - TransferfunctionPath = asset.resource("solarbrowsing/colortables") + RootDir = asset.resource("solarbrowsing/imagedata/stereo"), + TransferfunctionDir = asset.resource("solarbrowsing/colortables") }, GUI = { Name = "EUV-I-A Imagery", @@ -89,8 +89,8 @@ local SdoImagery = { Renderable = { -- Resolution of imagery, will be moved to metadata later Type = "RenderableSolarImagery", - RootPath = asset.resource("solarbrowsing/imagedata/sdo_aia-171"), - TransferfunctionPath = asset.resource("solarbrowsing/colortables") + RootDir = asset.resource("solarbrowsing/imagedata/sdo"), + TransferfunctionDir = asset.resource("solarbrowsing/colortables") }, GUI = { Name = "SDO Imagery", diff --git a/modules/solarbrowsing/rendering/renderablesolarimagery.cpp b/modules/solarbrowsing/rendering/renderablesolarimagery.cpp index af5b878bc8..dc9d625c9b 100644 --- a/modules/solarbrowsing/rendering/renderablesolarimagery.cpp +++ b/modules/solarbrowsing/rendering/renderablesolarimagery.cpp @@ -95,9 +95,9 @@ namespace { }; struct [[codegen::Dictionary(RenderableSolarImagery)]] Parameters { - std::string rootPath; + std::filesystem::path rootDir [[codegen::directory()]]; - std::string transferfunctionPath; + std::filesystem::path transferfunctionDir [[codegen::directory()]]; std::optional startInstrument; @@ -130,19 +130,16 @@ RenderableSolarImagery::RenderableSolarImagery(const ghoul::Dictionary& dictiona { const Parameters p = codegen::bake(dictionary); - std::string rootPath = p.rootPath; - SolarBrowsingModule* solarbrowsingModule = global::moduleEngine->module(); SpacecraftImageryManager& spacecraftImageryManager = solarbrowsingModule->spacecraftImageryManager(); - std::string transferfunctionPath = p.transferfunctionPath; - spacecraftImageryManager.loadTransferFunctions(transferfunctionPath, _tfMap); + spacecraftImageryManager.loadTransferFunctions(p.transferfunctionDir, _tfMap); - spacecraftImageryManager.loadImageMetadata(rootPath, _imageMetadataMap); + spacecraftImageryManager.loadImageMetadata(p.rootDir, _imageMetadataMap); // Add GUI names unsigned int guiNameCount = 0; @@ -287,7 +284,7 @@ void RenderableSolarImagery::updateTextureGPU(bool asyncUpload, bool resChanged) _currentImage = &(keyframe->data); _decodeBuffer.resize(_imageSize * _imageSize * sizeof(IMG_PRECISION)); - decode(_decodeBuffer.data(), keyframe->data.filename); + decode(_decodeBuffer.data(), keyframe->data.filePath.string()); } else { if (_currentImage == nullptr) { diff --git a/modules/solarbrowsing/rendering/renderablesolarimageryprojection.cpp b/modules/solarbrowsing/rendering/renderablesolarimageryprojection.cpp index 8edeca6e35..fd9dbdddfc 100644 --- a/modules/solarbrowsing/rendering/renderablesolarimageryprojection.cpp +++ b/modules/solarbrowsing/rendering/renderablesolarimageryprojection.cpp @@ -121,13 +121,13 @@ bool RenderableSolarImageryProjection::isReady() const { return _shader != nullptr; } -void RenderableSolarImageryProjection::update(const UpdateData& data) { +void RenderableSolarImageryProjection::update(const UpdateData&) { if (_shader->isDirty()) { _shader->rebuildFromFile(); } } -void RenderableSolarImageryProjection::render(const RenderData& data, RendererTasks& rendererTask) { +void RenderableSolarImageryProjection::render(const RenderData& data, RendererTasks&) { glm::dmat4 modelTransform = calcModelTransform(data); glm::dmat4 modelViewTransform = data.camera.combinedViewMatrix() * modelTransform; diff --git a/modules/solarbrowsing/util/spacecraftimagerymanager.cpp b/modules/solarbrowsing/util/spacecraftimagerymanager.cpp index 46cc34ad0b..f9f86f9e24 100644 --- a/modules/solarbrowsing/util/spacecraftimagerymanager.cpp +++ b/modules/solarbrowsing/util/spacecraftimagerymanager.cpp @@ -26,6 +26,7 @@ #include #include +#include #include #include #include @@ -33,8 +34,6 @@ #include #include #include -#include -#include #include #include #include @@ -73,17 +72,16 @@ std::string SpacecraftImageryManager::ISO8601(std::string& datetime) { return datetime; } -void SpacecraftImageryManager::loadTransferFunctions(const std::string& path, +void SpacecraftImageryManager::loadTransferFunctions(const std::filesystem::path& dir, std::unordered_map>& _tfMap) { - std::filesystem::path sequenceDir(path); - if (!std::filesystem::is_directory(sequenceDir)) { - LERROR(std::format("Could not load directory '{}'", sequenceDir.string())); + if (!std::filesystem::is_directory(dir)) { + LERROR(std::format("Could not load directory '{}'", dir.string())); } std::vector sequencePaths = ghoul::filesystem::walkDirectory( - sequenceDir, + dir, ghoul::filesystem::Recursive::Yes, ghoul::filesystem::Sorted::Yes ); @@ -96,21 +94,19 @@ void SpacecraftImageryManager::loadTransferFunctions(const std::string& path, } } -bool SpacecraftImageryManager::loadMetadataFromDisk(const std::string& rootPath, +bool SpacecraftImageryManager::loadMetadataFromDisk(const std::filesystem::path& rootDir, std::unordered_map>& _imageMetadataMap) { - - std::filesystem::path sequenceDir(rootPath); - - if (!std::filesystem::is_directory(sequenceDir)) { - LERROR(std::format("Could not load directory '{}'", sequenceDir.string())); + if (!std::filesystem::is_directory(rootDir)) { + throw ghoul::RuntimeError(std::format( + "Could not load directory '{}'", rootDir.string() + )); } bool metadataLoaded = false; - std::vector sequencePaths = ghoul::filesystem::walkDirectory( - sequenceDir, + rootDir, ghoul::filesystem::Recursive::No, ghoul::filesystem::Sorted::No ); @@ -118,19 +114,19 @@ bool SpacecraftImageryManager::loadMetadataFromDisk(const std::string& rootPath, for (const std::filesystem::path& seqPath : sequencePaths) { const std::string extension = seqPath.extension().string(); const std::string base = seqPath.filename().string(); - const std::size_t foundCachedImageData = base.find("_cached"); + const size_t foundCachedImageData = base.find("_cached"); if (extension != ".txt" || foundCachedImageData == std::string::npos) { continue; } - const std::string::size_type separator = base.rfind("_"); + const size_t separator = base.rfind("_"); const std::string instrument = base.substr(0, separator); LDEBUG(std::format("Loading instrument: {}", instrument)); metadataLoaded = true; std::ifstream myfile(seqPath); if (!myfile.is_open()) { - LERROR("Failed to open metadata file"); + LERROR(std::format("Failed to open metadata file '{}'", seqPath)); return false; } @@ -145,7 +141,9 @@ bool SpacecraftImageryManager::loadMetadataFromDisk(const std::string& rootPath, std::getline(myfile, date); if (date.empty()) { - LERROR("Failed to open state metadata: date"); + LERROR(std::format( + "Failed to read metadata state: date, file: '{}'", seqPath + )); return false; } @@ -156,23 +154,29 @@ bool SpacecraftImageryManager::loadMetadataFromDisk(const std::string& rootPath, myfile >> relPath; if (myfile.bad()) { - LERROR("Failed to open state metadata: relPath"); + LERROR(std::format( + "Failed to read metadata state: relPath, file: '{}'", seqPath + )); return false; } - im.filename = rootPath + "/" + relPath; + im.filePath = rootDir / relPath; myfile >> im.fullResolution; if (myfile.bad()) { - LERROR("Failed to open state metadata: fullResolution"); + LERROR(std::format( + "Failed to read metadata state: fullResolution, file: '{}'", seqPath + )); return false; } myfile >> im.scale; if (myfile.bad()) { - LERROR("Failed to open state metadata: scale"); + LERROR(std::format( + "Failed to read metadata state: scale, file: '{}'", seqPath + )); return false; } @@ -182,7 +186,9 @@ bool SpacecraftImageryManager::loadMetadataFromDisk(const std::string& rootPath, myfile >> im.isCoronaGraph; if (myfile.bad()) { - LERROR("Failed to open state metadata: isCoronaGraph"); + LERROR(std::format( + "Failed to read metadata state : isCoronaGraph, file : '{}'", seqPath + )); return false; } @@ -193,33 +199,44 @@ bool SpacecraftImageryManager::loadMetadataFromDisk(const std::string& rootPath, return metadataLoaded; } -void SpacecraftImageryManager::saveMetadataToDisk(const std::string& rootPath, +void SpacecraftImageryManager::saveMetadataToDisk(const std::filesystem::path& rootPath, std::unordered_map>& _imageMetadataMap) { using K = std::string; using V = Timeline; for (const std::pair& instrument : _imageMetadataMap) { - std::ofstream ofs(rootPath + "/" + instrument.first + "_cached" + ".txt"); + const std::filesystem::path cacheFile = + rootPath / std::format("{}_cached.txt", instrument.first); + + std::ofstream ofs(cacheFile); if (!ofs.is_open()) { - LERROR("Failed to open file"); + LERROR(std::format("Failed to open file '{}'", cacheFile)); + continue; } + const Timeline& sequence = instrument.second; - ofs << sequence.nKeyframes() << "\n"; + ofs << sequence.nKeyframes() << '\n'; + for (const Keyframe& metadata : sequence.keyframes()) { - ofs << SpiceManager::ref().dateFromEphemerisTime( - metadata.timestamp - ) << "\n"; - const ImageMetadata& im = metadata.data; + const std::string date = SpiceManager::ref().dateFromEphemerisTime( + metadata.timestamp + ); - std::filesystem::path filePath(im.filename); - std::filesystem::path fileName = filePath.filename(); + const ImageMetadata& im = metadata.data; + const std::filesystem::path relativePath = std::filesystem::relative( + im.filePath, + rootPath + ); - ofs << fileName.string() << "\n"; - ofs << im.fullResolution << "\n"; - ofs << im.scale << "\n"; - ofs << im.centerPixel.x << "\n"; - ofs << im.centerPixel.y << "\n"; - ofs << im.isCoronaGraph << "\n"; + ofs << std::format("{}\n{}\n{}\n{}\n{}\n{}\n{}\n", + date, + relativePath.generic_string(), + im.fullResolution, + im.scale, + im.centerPixel.x, + im.centerPixel.y, + static_cast(im.isCoronaGraph) // Output bool as 0/1 + ); } ofs.close(); } @@ -230,17 +247,17 @@ void SpacecraftImageryManager::saveMetadataToDisk(const std::string& rootPath, // XML data. There is an issue here: // (https://github.com/uclouvain/openjpeg/issues/929) ImageMetadata SpacecraftImageryManager::parseJ2kMetadata( - const ghoul::filesystem::File& file) + const std::filesystem::path& filePath) { ImageMetadata im; - im.filename = file.path().string(); + im.filePath = filePath; - std::ifstream stream(file.path(), std::ios::binary | std::ios::ate); + std::ifstream stream(filePath, std::ios::binary | std::ios::ate); std::streamsize size = stream.tellg(); stream.seekg(0, std::ios::beg); std::vector buffer(size); if (!stream.read(buffer.data(), size)) { - LERROR(std::format("Failed to read data from '{}' ", file.path())); + LERROR(std::format("Failed to read data from '{}' ", filePath)); return im; } std::string_view bufferView(buffer.data(), size); @@ -269,14 +286,14 @@ ImageMetadata SpacecraftImageryManager::parseJ2kMetadata( std::optional metaData = extractInnerXml(bufferView, "meta"); if (!metaData.has_value()) { - LERROR(std::format("Could not find metadata in {}", file.path())); + LERROR(std::format("Could not find metadata in {}", filePath)); return im; } std::optional telescop = extractInnerXml(metaData.value(), "TELESCOP"); if (!telescop.has_value()) { - LERROR(std::format("Could not find TELESCOP tag {}", file.path())); + LERROR(std::format("Could not find TELESCOP tag {}", filePath)); return im; } @@ -286,7 +303,7 @@ ImageMetadata SpacecraftImageryManager::parseJ2kMetadata( im.fullResolution = std::stoi(std::string(naxis.value())); } else { - LERROR(std::format("Could not find NAXIS1 tag {}", file.path())); + LERROR(std::format("Could not find NAXIS1 tag {}", filePath)); return im; } @@ -299,7 +316,7 @@ ImageMetadata SpacecraftImageryManager::parseJ2kMetadata( centerPixel.x = std::stof(std::string(centerPixelX.value())); } else { - LERROR(std::format("Could not find CRPIX1 tag {}", file.path())); + LERROR(std::format("Could not find CRPIX1 tag {}", filePath)); return im; } @@ -309,7 +326,7 @@ ImageMetadata SpacecraftImageryManager::parseJ2kMetadata( centerPixel.y = std::stof(std::string(centerPixelY.value())); } else { - LERROR(std::format("Could not find CRPIX2 tag {}", file.path())); + LERROR(std::format("Could not find CRPIX2 tag {}", filePath)); return im; } @@ -325,7 +342,7 @@ ImageMetadata SpacecraftImageryManager::parseJ2kMetadata( im.isCoronaGraph = true; } else { - LERROR(std::format("Could not find NAXIS1 tag {}", file.path())); + LERROR(std::format("Could not find NAXIS1 tag {}", filePath)); return im; } } @@ -334,11 +351,11 @@ ImageMetadata SpacecraftImageryManager::parseJ2kMetadata( std::optional cDelt1 = extractInnerXml(bufferView, "CDELT1"); if (!rsunObs.has_value()) { - LERROR(std::format("Could not find RSUN_OBS tag {}", file.path())); + LERROR(std::format("Could not find RSUN_OBS tag {}", filePath)); return im; } if (!cDelt1.has_value()) { - LERROR(std::format("Could not find CDELT1 tag {}", file.path())); + LERROR(std::format("Could not find CDELT1 tag {}", filePath)); return im; } @@ -351,11 +368,11 @@ ImageMetadata SpacecraftImageryManager::parseJ2kMetadata( std::optional rsun = extractInnerXml(bufferView, "RSUN"); std::optional cDelt1 = extractInnerXml(bufferView, "CDELT1"); if (!rsun.has_value()) { - LERROR(std::format("Could not find RSUN_OBS tag {}", file.path())); + LERROR(std::format("Could not find RSUN_OBS tag {}", filePath)); return im; } if (!cDelt1.has_value()) { - LERROR(std::format("Could not find CDELT1 tag {}", file.path())); + LERROR(std::format("Could not find CDELT1 tag {}", filePath)); return im; } @@ -372,7 +389,7 @@ ImageMetadata SpacecraftImageryManager::parseJ2kMetadata( } else { LWARNING(std::format( - "Could not find DETECTOR tag {}", file.path() + "Could not find DETECTOR tag {}", filePath )); } } @@ -388,111 +405,111 @@ ImageMetadata SpacecraftImageryManager::parseJsonMetadata( const ghoul::filesystem::File& file) { ImageMetadata im; - im.filename = file.path().string(); - const std::string filename = std::string(file.path().string() + ".json"); + //im.filename = file.path().string(); + //const std::string filename = std::string(file.path().string() + ".json"); - if (!std::filesystem::exists(filename)) { - LERROR(std::format("'{}' has no specified json metadata", file.path())); - // TODO: Hardcoded values, when there are no json files. - return im; - } + //if (!std::filesystem::exists(filename)) { + // LERROR(std::format("'{}' has no specified json metadata", file.path())); + // // TODO: Hardcoded values, when there are no json files. + // return im; + //} - // Parse JSON metadata - using json = nlohmann::json; + //// Parse JSON metadata + //using json = nlohmann::json; - std::ifstream i(filename); - if (i.fail()) { - LERROR(std::format("Error opening file '{}'", filename)); - } + //std::ifstream i(filename); + //if (i.fail()) { + // LERROR(std::format("Error opening file '{}'", filename)); + //} - json j; - i >> j; - const json data = j["meta"]["fits"]; + //json j; + //i >> j; + //const json data = j["meta"]["fits"]; - if (data.is_null()) { - LERROR(std::format("Error in metadata '{}'", filename)); - } + //if (data.is_null()) { + // LERROR(std::format("Error in metadata '{}'", filename)); + //} - json value = data["TELESCOP"]; - if (value.is_null() && !value.is_string()) { - LERROR("Metadata did contain information about type of spacecraft"); - return im; - } - // TODO: value might not exist - std::string spacecraftType = value; + //json value = data["TELESCOP"]; + //if (value.is_null() && !value.is_string()) { + // LERROR("Metadata did contain information about type of spacecraft"); + // return im; + //} + //// TODO: value might not exist + //std::string spacecraftType = value; - value = data["NAXIS1"]; - if (value.is_null()) { - LERROR("Metadata did not contain information about resolution"); - } + //value = data["NAXIS1"]; + //if (value.is_null()) { + // LERROR("Metadata did not contain information about resolution"); + //} - const std::string sFullResolution = value; - im.fullResolution = std::stoi(sFullResolution); - // Special case of sdo - RSUN is given in pixels - // For SOHO the radius of the sun is not specified - we instead use platescl - if (spacecraftType == "SOHO") { - const std::string sScale = data["PLATESCL"]; - const float plateScale = stof(sScale); - im.scale = 1.f / (plateScale / 2.f); - im.isCoronaGraph = true; - } else { - float sunRadiusPixels = 0.f; - // SDO has RSUN specified in pixels - if (spacecraftType == "SDO") { - value = data["RSUN_OBS"]; - if (value.is_null()) { - LERROR("SDO Metadata: RSUN_OBS missing!"); - } - std::string sSunRadiusArcsec = value; - value = data["CDELT1"]; - if (value.is_null()) { - LERROR("SDO Metadata: CDELT1 missing!"); - } - std::string sCdelt1 = value; - const float cdelt1 = stof(sCdelt1); - const float sunRadiusArcsec = stof(sSunRadiusArcsec); - sunRadiusPixels = sunRadiusArcsec / cdelt1; - im.isCoronaGraph = false; - } else { - // STEREO has RSUN specified in arcsecs - need to divide by factor - std::string sCdelt1 = data["CDELT1"]; - const float cdelt1 = stof(sCdelt1); - std::string sSunRadiusArcsec = data["RSUN"]; - const float sunRadiusArcsec = stof(sSunRadiusArcsec); - sunRadiusPixels = sunRadiusArcsec / cdelt1; + //const std::string sFullResolution = value; + //im.fullResolution = std::stoi(sFullResolution); + //// Special case of sdo - RSUN is given in pixels + //// For SOHO the radius of the sun is not specified - we instead use platescl + //if (spacecraftType == "SOHO") { + // const std::string sScale = data["PLATESCL"]; + // const float plateScale = stof(sScale); + // im.scale = 1.f / (plateScale / 2.f); + // im.isCoronaGraph = true; + //} else { + // float sunRadiusPixels = 0.f; + // // SDO has RSUN specified in pixels + // if (spacecraftType == "SDO") { + // value = data["RSUN_OBS"]; + // if (value.is_null()) { + // LERROR("SDO Metadata: RSUN_OBS missing!"); + // } + // std::string sSunRadiusArcsec = value; + // value = data["CDELT1"]; + // if (value.is_null()) { + // LERROR("SDO Metadata: CDELT1 missing!"); + // } + // std::string sCdelt1 = value; + // const float cdelt1 = stof(sCdelt1); + // const float sunRadiusArcsec = stof(sSunRadiusArcsec); + // sunRadiusPixels = sunRadiusArcsec / cdelt1; + // im.isCoronaGraph = false; + // } else { + // // STEREO has RSUN specified in arcsecs - need to divide by factor + // std::string sCdelt1 = data["CDELT1"]; + // const float cdelt1 = stof(sCdelt1); + // std::string sSunRadiusArcsec = data["RSUN"]; + // const float sunRadiusArcsec = stof(sSunRadiusArcsec); + // sunRadiusPixels = sunRadiusArcsec / cdelt1; - value = data["DETECTOR"]; - if (value.is_null()) { - LERROR("No observer specified in Stereo"); - } + // value = data["DETECTOR"]; + // if (value.is_null()) { + // LERROR("No observer specified in Stereo"); + // } - std::string sObserver = value; - if (sObserver == "COR1" || sObserver == "COR2") { - im.isCoronaGraph = true; - } else { - im.isCoronaGraph = false; - } - } - float scale = sunRadiusPixels / (im.fullResolution / 2.f); - im.scale = scale; - } + // std::string sObserver = value; + // if (sObserver == "COR1" || sObserver == "COR2") { + // im.isCoronaGraph = true; + // } else { + // im.isCoronaGraph = false; + // } + // } + // float scale = sunRadiusPixels / (im.fullResolution / 2.f); + // im.scale = scale; + //} - const std::string sCenterPixelX = data["CRPIX1"]; - const std::string sCenterPixelY = data["CRPIX2"]; + //const std::string sCenterPixelX = data["CRPIX1"]; + //const std::string sCenterPixelY = data["CRPIX2"]; - const float centerPixelX = stof(sCenterPixelX); - const float centerPixelY = stof(sCenterPixelY); - const float halfRes = im.fullResolution / 2.f; + //const float centerPixelX = stof(sCenterPixelX); + //const float centerPixelY = stof(sCenterPixelY); + //const float halfRes = im.fullResolution / 2.f; - const float offsetX = ((halfRes - centerPixelX) / halfRes) * SUN_RADIUS; - const float offsetY = ((halfRes - centerPixelY) / halfRes) * SUN_RADIUS; + //const float offsetX = ((halfRes - centerPixelX) / halfRes) * SUN_RADIUS; + //const float offsetY = ((halfRes - centerPixelY) / halfRes) * SUN_RADIUS; - im.centerPixel = glm::vec2(offsetX, offsetY); + //im.centerPixel = glm::vec2(offsetX, offsetY); return im; } -void SpacecraftImageryManager::loadImageMetadata(const std::string& path, +void SpacecraftImageryManager::loadImageMetadata(const std::filesystem::path& path, std::unordered_map>& _imageMetadataMap) { std::unordered_map> result; @@ -543,7 +560,6 @@ void SpacecraftImageryManager::loadImageMetadata(const std::string& path, std::cout << '\n'; auto exec = [&](const std::filesystem::path& seqPath) { - ghoul::filesystem::File currentFile(seqPath); std::string fileName = seqPath.filename().string(); size_t posSatelliteInfoStart = fileName.rfind("__") + 2; std::string satelliteInfo = fileName.substr(posSatelliteInfoStart); @@ -572,7 +588,7 @@ void SpacecraftImageryManager::loadImageMetadata(const std::string& path, tokens[2] + "T" + tokens[4] + ":" + tokens[5] + ":" + tokens[6] + "." + tokens[7]; - ImageMetadata im = parseJ2kMetadata(currentFile); + ImageMetadata im = parseJ2kMetadata(seqPath); spiceAndPushMutex.lock(); result[instrumentName].addKeyframe( global::timeManager->time().convertTime(time), diff --git a/modules/solarbrowsing/util/spacecraftimagerymanager.h b/modules/solarbrowsing/util/spacecraftimagerymanager.h index 7050bd6c05..f6bda560cc 100644 --- a/modules/solarbrowsing/util/spacecraftimagerymanager.h +++ b/modules/solarbrowsing/util/spacecraftimagerymanager.h @@ -25,13 +25,13 @@ #ifndef __OPENSPACE_MODULE_SOLARBROWSING___SPACECRAFTIMAGERYMANAGER___H__ #define __OPENSPACE_MODULE_SOLARBROWSING___SPACECRAFTIMAGERYMANAGER___H__ +#include +#include +#include #include #include #include #include -#include -#include -#include #define IMG_PRECISION unsigned char @@ -49,21 +49,21 @@ class TransferFunction; // anything particular) class SpacecraftImageryManager { public: - void loadTransferFunctions(const std::string& path, + void loadTransferFunctions(const std::filesystem::path& dir, std::unordered_map>& _tfMap); - void loadImageMetadata(const std::string& path, + void loadImageMetadata(const std::filesystem::path& path, std::unordered_map>& _imageMetadataMap); private: - ImageMetadata parseJ2kMetadata(const ghoul::filesystem::File& file); + ImageMetadata parseJ2kMetadata(const std::filesystem::path& filePath); ImageMetadata parseJsonMetadata(const ghoul::filesystem::File& file); std::string ISO8601(std::string& datetime); - bool loadMetadataFromDisk(const std::string& rootPath, + bool loadMetadataFromDisk(const std::filesystem::path& rootDir, std::unordered_map>& _imageMetadataMap); - void saveMetadataToDisk(const std::string& rootPath, + void saveMetadataToDisk(const std::filesystem::path& rootPath, std::unordered_map>& _imageMetadataMap); }; diff --git a/modules/solarbrowsing/util/structs.h b/modules/solarbrowsing/util/structs.h index a2b5723af4..a1cd399474 100644 --- a/modules/solarbrowsing/util/structs.h +++ b/modules/solarbrowsing/util/structs.h @@ -25,6 +25,7 @@ #ifndef __OPENSPACE_MODULE_SOLARBROWSING___STRUCTS___H__ #define __OPENSPACE_MODULE_SOLARBROWSING___STRUCTS___H__ +#include #include #include #include @@ -34,7 +35,7 @@ namespace openspace { // Assume everything in arcsec to minimize metadata struct ImageMetadata { - std::string filename; + std::filesystem::path filePath; int fullResolution; float scale; glm::vec2 centerPixel; @@ -54,6 +55,6 @@ struct DecodeData { bool verboseMode; }; -} +} // namespace openspace #endif // __OPENSPACE_MODULE_SOLARBROWSING___STRUCTS___H__