Merge branch 'thesis/2018/dsn' of github.com:OpenSpace/OpenSpace into thesis/2018/dsn

This commit is contained in:
Lovisa Hassler
2018-12-13 19:07:33 -05:00
3 changed files with 32 additions and 17 deletions
+24 -14
View File
@@ -53,14 +53,19 @@ namespace openspace {
glm::vec3 RadecManager::getPosForTime(double time) const {
if (!correctHour(time)) {
int idx = DataFileHelper::findFileIndexForCurrentTime(time, timeDoubles);
updateRadecData(idx);
}
if(!correctMinute(time)) {
//Compensate for light travel time to the spacecraft
int idx = DataFileHelper::findFileIndexForCurrentTime(time + position.lightTravelTime, minuteTimes);
getPositionInVector(idx);
int idx = DataFileHelper::findFileIndexForCurrentTime(time, minuteTimes);
updateActiveMinute(idx);
double lighttimeCompensation = positions[idx].lightTravelTime;
int compensatedIdx = DataFileHelper::findFileIndexForCurrentTime(time + lighttimeCompensation, minuteTimes);
getPositionInVector(compensatedIdx);
}
return glm::vec3(position.ra, position.dec, position.range);
}
@@ -89,26 +94,30 @@ namespace openspace {
}
return true;
}
RadecManager::Position RadecManager::getPositionInVector(int index) const{
void RadecManager::updateActiveMinute(int idx) const{
minuteTimes.clear();
minuteTimes.reserve(0);
for (int i = 0; i < RadecManager::positions.size(); i++) {
minuteTimes.push_back(Time::convertTime(positions[i].timeStamp));
}
activeMinute = minuteTimes[idx];
}
RadecManager::Position RadecManager::getPositionInVector(int compensatedIndex) const{
try{
activeMinute = minuteTimes[index];
position.timeStamp = positions[index].timeStamp;
position.ra = positions[index].ra;
position.dec = positions[index].dec;
position.range = positions[index].range;
position.timeStamp = positions[compensatedIndex].timeStamp;
position.ra = positions[compensatedIndex].ra;
position.dec = positions[compensatedIndex].dec;
position.range = positions[compensatedIndex].range;
}
catch (const std::exception& e) {
LERROR(fmt::format("{}: Error when reading data from active minute, index {}",objectIdentifier, index));
LERROR(fmt::format("{}: Error when reading data from active minute, index {}",objectIdentifier, compensatedIndex));
}
return position;
}
@@ -122,6 +131,7 @@ namespace openspace {
positions.reserve(10);
filename = _dataFiles[index];
std::string startTimeString = DataFileHelper::getHourFromFileName(filename);
const double triggerTime = Time::convertTime(startTimeString);
@@ -129,7 +139,7 @@ namespace openspace {
_checkFileEndTime = triggerTime + 3600;
//Light travel time in hours determines where to search for the correct position
int lightTravelHours = ceil(position.lightTravelTime / 3600);
int lightTravelHours = ceil(positions[index].lightTravelTime / 3600);
if (lightTravelHours > 1)
index = index + lightTravelHours;
+4 -1
View File
@@ -48,6 +48,7 @@ namespace openspace {
mutable std::vector<Position> positions;
mutable std::vector<double> minuteTimes;
mutable Position position;
mutable double activeMinute;
/* Identifier for object using the translation, used for logging */
std::string objectIdentifier;
@@ -65,8 +66,10 @@ namespace openspace {
glm::vec3 getPosForTime(double time) const;
/* parses positioningdata from a file given an index in our preloaded filename vector */
bool radecParser(int index) const;
/*Updates what minute the last ra dec positioning data has looked for*/
void updateActiveMinute(int idx) const;
/*Find the correct minute in the vector of loaded positions*/
RadecManager::Position getPositionInVector(int index) const;
RadecManager::Position getPositionInVector(int idx) const;
/*Check if current hour in open space is already loaded*/
bool correctHour(double time) const;
/*Check if current minute in open space is already loaded*/
+4 -2
View File
@@ -88,9 +88,11 @@ RadecTranslation::RadecTranslation(const ghoul::Dictionary& dictionary)
std::unique_ptr<ghoul::Dictionary> dictionaryPtr = std::make_unique<ghoul::Dictionary>(dictionary);
_dataStart = Time::convertTime(dictionaryPtr->value<std::string>(keyDataStart));
_dataEnd = double(Time::convertTime(dictionaryPtr->value<std::string>(keyDataEnd)));
_dataEnd = Time::convertTime(dictionaryPtr->value<std::string>(keyDataEnd));
extractData(dictionaryPtr);
}
void RadecTranslation::extractData(std::unique_ptr<ghoul::Dictionary> &dictionary){
@@ -142,7 +144,7 @@ glm::dvec3 RadecTranslation::position(const UpdateData& data) const{
}
else {
glm::dvec3 pos = radecManager.getPosForTime(data.time.j2000Seconds());
_position = radecToCartesianCoordinates(pos);
_position = radecToCartesianCoordinates(pos);
return _position;
}
}