fix random crash

This commit is contained in:
Agnes Heppich
2018-12-14 16:38:07 -05:00
parent b924ed7f0c
commit 59fc21e387

View File

@@ -81,26 +81,30 @@ namespace openspace {
bool RadecManager::radecParser(int index) const{
std::string filename;
filename = _dataFiles[index];
std::ifstream ifs(filename);
nlohmann::json j = nlohmann::json::parse(ifs);
if (index > -1 && index < _dataFiles.size()) {
filename = _dataFiles[index];
std::ifstream ifs(filename);
nlohmann::json j = nlohmann::json::parse(ifs);
int objectCounter = 0;
for (const auto& pos : j["Positions"]) {
objectCounter++;
try {
position.timeStamp = pos["TimeStamp"].get<std::string>();
position.ra = pos["RADn"].get<double>();
position.dec = pos["DecDn"].get<double>();
position.range = pos["GeoRngDn"].get<double>();
position.lightTravelTime = pos["DLT"].get<double>();
}
catch (const std::exception& e) {
LERROR(fmt::format("{}: Error in json object number {} while reading file '{}'", objectIdentifier, objectCounter, filename));
}
RadecManager::positions.push_back(position);
int objectCounter = 0;
for (const auto& pos : j["Positions"]) {
objectCounter++;
try {
position.timeStamp = pos["TimeStamp"].get<std::string>();
position.ra = pos["RADn"].get<double>();
position.dec = pos["DecDn"].get<double>();
position.range = pos["GeoRngDn"].get<double>();
position.lightTravelTime = pos["DLT"].get<double>();
}
catch (const std::exception& e) {
LERROR(fmt::format("{}: Error in json object number {} while reading file '{}'", objectIdentifier, objectCounter, filename));
}
RadecManager::positions.push_back(position);
}
return true;
}
return true;
else return false;
}
void RadecManager::updateActiveMinute(int idx) const{