don't parse if same index

This commit is contained in:
Agnes Heppich
2018-12-26 18:01:58 -05:00
parent a47e0985e6
commit 333806009e
2 changed files with 17 additions and 6 deletions
+14 -4
View File
@@ -57,12 +57,19 @@ namespace openspace {
}
glm::vec3 RadecManager::getPosForTime(double time) const {
if (!correctFileInterval(time)) {
int idx = DataFileHelper::findFileIndexForCurrentTime(time, timeDoubles);
updateRadecData(idx);
int index = DataFileHelper::findFileIndexForCurrentTime(time, minuteTimes);
updateActiveMinute(index);
//If index is same as previous, don't parse the data again
if(idx != prevIndex){
prevIndex = idx;
updateRadecData(idx);
int index = DataFileHelper::findFileIndexForCurrentTime(time, minuteTimes);
updateActiveMinute(index);
}
}
if (positions.size() && !correctUpdateInterval(time)) {
@@ -95,11 +102,14 @@ namespace openspace {
position.dec = pos["DecDn"].get<double>();
position.range = pos["GeoRngDn"].get<double>();
position.lightTravelTime = pos["DLT"].get<double>();
position.lightTravelHours = ceil(position.lightTravelTime / 3600);
}
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;
}
+3 -2
View File
@@ -43,12 +43,13 @@ namespace openspace {
mutable double dec;
mutable double range;
mutable double lightTravelTime; //Downlink light time travel time in seconds
mutable int lightTravelHours;
};
mutable int prevIndex;
mutable std::vector<Position> positions;
mutable std::vector<double> minuteTimes;
mutable Position position;
mutable double updateFrequency = 1;
mutable double activeMinute = -1;
/* Identifier for object using the translation, used for logging */