MCPcopy Create free account
hub / github.com/SatDump/SatDump / loadDatasetInViewer

Method loadDatasetInViewer

src-interface/viewer/viewer.cpp:76–122  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

74 }
75
76 void ViewerApplication::loadDatasetInViewer(std::string path)
77 {
78 ProductDataSet dataset;
79 dataset.load(path);
80
81 std::string dataset_name = dataset.satellite_name + " " + timestamp_to_string(dataset.timestamp);
82
83 int i = -1;
84 bool contains = false;
85 do
86 {
87 contains = false;
88 std::string curr_name = ((i + 1) == 0 ? dataset_name : (dataset_name + " #" + std::to_string(i + 1)));
89 for (int i = 0; i < (int)products_and_handlers.size(); i++)
90 if (products_and_handlers[i]->dataset_name == curr_name)
91 contains = true;
92 i++;
93 } while (contains);
94 dataset_name = (i == 0 ? dataset_name : (dataset_name + " #" + std::to_string(i)));
95
96 std::string pro_directory = std::filesystem::path(path).parent_path().string();
97 for (std::string pro_path : dataset.products_list)
98 {
99 try
100 {
101 if (path.find("http") == 0)
102 {
103 // Make sure the path is URL safe
104 std::ostringstream encodedUrl;
105 encodedUrl << std::hex << std::uppercase << std::setfill('0');
106 for (char &c : pro_path)
107 {
108 if (std::isalnum(c) || c == '-' || c == '_' || c == '.' || c == '~')
109 encodedUrl << c;
110 else
111 encodedUrl << '%' << std::setw(2) << static_cast<unsigned int>(static_cast<unsigned char>(c));
112 }
113 pro_path = encodedUrl.str();
114 }
115 loadProductsInViewer(pro_directory + "/" + pro_path, dataset_name);
116 }
117 catch (std::exception &e)
118 {
119 logger->error("Could not open " + pro_path + " in viewer! : %s", e.what());
120 }
121 }
122 }
123
124 void ViewerApplication::loadProductsInViewer(std::string path, std::string dataset_name)
125 {

Callers 1

processFunction · 0.80

Calls 10

timestamp_to_stringFunction · 0.85
to_stringFunction · 0.85
pathClass · 0.85
loadMethod · 0.45
sizeMethod · 0.45
stringMethod · 0.45
findMethod · 0.45
strMethod · 0.45
errorMethod · 0.45
whatMethod · 0.45

Tested by

no test coverage detected