From 333806009e22d2c25ec5c396879e00bdeba7395f Mon Sep 17 00:00:00 2001 From: Agnes Heppich Date: Wed, 26 Dec 2018 18:01:58 -0500 Subject: [PATCH] don't parse if same index --- modules/dsn/managers/radecmanager.cpp | 18 ++++++++++++++---- modules/dsn/managers/radecmanager.h | 5 +++-- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/modules/dsn/managers/radecmanager.cpp b/modules/dsn/managers/radecmanager.cpp index 3fad0c4f65..9b99c2670e 100644 --- a/modules/dsn/managers/radecmanager.cpp +++ b/modules/dsn/managers/radecmanager.cpp @@ -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(); position.range = pos["GeoRngDn"].get(); position.lightTravelTime = pos["DLT"].get(); + 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; } diff --git a/modules/dsn/managers/radecmanager.h b/modules/dsn/managers/radecmanager.h index 7a611840b3..9714af97a1 100644 --- a/modules/dsn/managers/radecmanager.h +++ b/modules/dsn/managers/radecmanager.h @@ -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 positions; mutable std::vector minuteTimes; mutable Position position; - mutable double updateFrequency = 1; mutable double activeMinute = -1; /* Identifier for object using the translation, used for logging */