mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-19 02:10:26 -06:00
fixed conflicts
This commit is contained in:
@@ -23,7 +23,7 @@ local fieldlines = {
|
||||
ColorTableRanges = {
|
||||
{ -0.6, 0.6 },
|
||||
},
|
||||
LoadAtRuntime = false,
|
||||
LoadAtRuntime = true,
|
||||
ScaleToMeters = 1.0,
|
||||
SecondsBefore = 24*60*60,
|
||||
SecondsAfter = 24*60*60,
|
||||
|
||||
@@ -23,7 +23,7 @@ local fieldlines = {
|
||||
ColorTableRanges = {
|
||||
{ -0.6, 0.6 },
|
||||
},
|
||||
LoadAtRuntime = false,
|
||||
LoadAtRuntime = true,
|
||||
ScaleToMeters = 1.0,
|
||||
SecondsBefore = 24*60*60,
|
||||
SecondsAfter = 24*60*60,
|
||||
|
||||
@@ -23,7 +23,7 @@ local fieldlines = {
|
||||
ColorTableRanges = {
|
||||
{ -0.6, 0.6 },
|
||||
},
|
||||
LoadAtRuntime = false,
|
||||
LoadAtRuntime = true,
|
||||
ScaleToMeters = 1.0,
|
||||
SecondsBefore = 24*60*60,
|
||||
SecondsAfter = 24*60*60,
|
||||
@@ -31,7 +31,7 @@ local fieldlines = {
|
||||
Color = {
|
||||
Uniform = {0.725, 0.1, 0, 1}
|
||||
},
|
||||
ColoringMethod = "Quantity",
|
||||
ColoringMethod = "Quantity"
|
||||
},
|
||||
GUI = {
|
||||
Path = "/Solar System/Heliosphere",
|
||||
|
||||
@@ -23,7 +23,7 @@ local fieldlines = {
|
||||
ColorTableRanges = {
|
||||
{ -0.6, 0.6 },
|
||||
},
|
||||
LoadAtRuntime = false,
|
||||
LoadAtRuntime = true,
|
||||
ScaleToMeters = 1.0,
|
||||
SecondsBefore = 24*60*60,
|
||||
SecondsAfter = 24*60*60,
|
||||
|
||||
@@ -19,7 +19,7 @@ local fieldlines = {
|
||||
{ 0, 1000000 },
|
||||
{ 100, 2000 }
|
||||
},
|
||||
LoadAtRuntime = false,
|
||||
LoadAtRuntime = true,
|
||||
ScaleToMeters = 1.0,
|
||||
SecondsBefore = 24*60*60,
|
||||
SecondsAfter = 24*60*60,
|
||||
|
||||
@@ -23,7 +23,7 @@ local fieldlines = {
|
||||
ColorTableRanges = {
|
||||
{ -0.6, 0.6 },
|
||||
},
|
||||
LoadAtRuntime = false,
|
||||
LoadAtRuntime = true,
|
||||
ScaleToMeters = 1.0,
|
||||
SecondsBefore = 24*60*60,
|
||||
SecondsAfter = 24*60*60,
|
||||
|
||||
@@ -23,7 +23,7 @@ local fieldlines = {
|
||||
ColorTableRanges = {
|
||||
{ -0.02, 0.02 },
|
||||
},
|
||||
LoadAtRuntime = false,
|
||||
LoadAtRuntime = true,
|
||||
ScaleToMeters = 1.0,
|
||||
SecondsBefore = 24*60*60,
|
||||
SecondsAfter = 24*60*60,
|
||||
|
||||
@@ -23,7 +23,7 @@ local fieldlines = {
|
||||
ColorTableRanges = {
|
||||
{ -0.02, 0.02 },
|
||||
},
|
||||
LoadAtRuntime = false,
|
||||
LoadAtRuntime = true,
|
||||
ScaleToMeters = 1.0,
|
||||
SecondsBefore = 24*60*60,
|
||||
SecondsAfter = 24*60*60,
|
||||
|
||||
@@ -19,7 +19,7 @@ local fieldlines = {
|
||||
{ 0, 1000000 },
|
||||
{ 100, 2000 }
|
||||
},
|
||||
LoadAtRuntime = false,
|
||||
LoadAtRuntime = true,
|
||||
ScaleToMeters = 1.0,
|
||||
SecondsBefore = 24*60*60,
|
||||
SecondsAfter = 24*60*60,
|
||||
|
||||
@@ -23,7 +23,7 @@ local fieldlines = {
|
||||
ColorTableRanges = {
|
||||
{ -0.02, 0.02 },
|
||||
},
|
||||
LoadAtRuntime = false,
|
||||
LoadAtRuntime = true,
|
||||
ScaleToMeters = 1.0,
|
||||
SecondsBefore = 24*60*60,
|
||||
SecondsAfter = 24*60*60,
|
||||
|
||||
@@ -1196,11 +1196,8 @@ void RenderableFieldlinesSequence::update(const UpdateData& data) {
|
||||
computeSequenceEndTime();
|
||||
}
|
||||
|
||||
|
||||
const bool isInInterval = (currentTime >= _startTimes[0]) &&
|
||||
(currentTime < _sequenceEndTime);
|
||||
|
||||
|
||||
|
||||
// Check if current time in OpenSpace is within sequence interval
|
||||
if (isInInterval) {
|
||||
|
||||
@@ -40,45 +40,44 @@ namespace {
|
||||
|
||||
namespace openspace{
|
||||
|
||||
WebFieldlinesManager::WebFieldlinesManager(std::string identifier, std::string fieldLineModelType):
|
||||
_flsType(fieldLineModelType)
|
||||
{
|
||||
_syncDir = initializeSyncDirectory(identifier);
|
||||
|
||||
std::string testTime;
|
||||
triggerTimeInt2String(610056000, testTime);
|
||||
|
||||
int testInt;
|
||||
triggerTimeString2Int(testTime, testInt);
|
||||
WebFieldlinesManager::WebFieldlinesManager(std::string syncDir){
|
||||
|
||||
// change to parameter
|
||||
_syncDir = "/Users/shuy/Offline-dokument/OpenSpace/Spaceweather/OpenSpace/data/assets/testwsa/fl_pfss_io_25";
|
||||
_flsType = "PfssIo";
|
||||
_downloadMargin = 3;
|
||||
_timeTriggerDelta = 7200;
|
||||
|
||||
getAvailableTriggertimes();
|
||||
|
||||
setInitialSet(global::timeManager.time().j2000Seconds());
|
||||
|
||||
LERROR("WebFieldlinesManager initialized");
|
||||
|
||||
|
||||
}
|
||||
|
||||
// For testing purposes
|
||||
void WebFieldlinesManager::downloadFieldlines(std::vector<std::string>& _sourceFile, std::vector<double>& _startTimes, size_t& _nStates){
|
||||
// dowload files specified in _filestodownload
|
||||
// I'm thinking we can replace the parameters with pointers to the lists that will be
|
||||
// initialized in the constuctor instead
|
||||
void WebFieldlinesManager::downloadFieldlines(std::vector<std::string>& _sourceFiles, std::vector<double>& _startTimes, size_t& _nStates){
|
||||
LERROR("starting download");
|
||||
for (auto& tt : _availableTriggertimes){
|
||||
for (int index : _filesToDownload){
|
||||
|
||||
downloadOsfls(tt);
|
||||
|
||||
//add the timetrigger at the right place in the list
|
||||
std::string sub = tt.substr(6, 23);
|
||||
int temp;
|
||||
triggerTimeString2Int(sub,temp);
|
||||
double timetriggernumber = temp;
|
||||
|
||||
int i = 0;
|
||||
while(timetriggernumber > _startTimes[i]){
|
||||
|
||||
if( i == _startTimes.size()) break;
|
||||
std::string filename = _availableTriggertimes[index].second;
|
||||
double timetrigger = _availableTriggertimes[index].first;
|
||||
|
||||
// download fieldlines file
|
||||
std::string destPath = downloadOsfls(filename);
|
||||
|
||||
//add the timetrigger at the right place in the list
|
||||
int i = 0;
|
||||
while(timetrigger > _startTimes[i]){
|
||||
if( i == static_cast<int>(_nStates)) break;
|
||||
else i++;
|
||||
|
||||
}
|
||||
_sourceFile.insert(_sourceFile.begin() + i, _syncDir + '/' + tt.substr(6));
|
||||
_startTimes.insert(_startTimes.begin() + i, timetriggernumber);
|
||||
_sourceFiles.insert(_sourceFiles.begin() + i, destPath);
|
||||
_startTimes.insert(_startTimes.begin() + i, timetrigger);
|
||||
_nStates += 1;
|
||||
}
|
||||
}
|
||||
@@ -109,11 +108,25 @@ namespace openspace{
|
||||
|
||||
// --------------------------- PRIVATE FUNCTIONS --------------------------- //
|
||||
|
||||
void WebFieldlinesManager::update(){
|
||||
|
||||
// this function aint done
|
||||
void WebFieldlinesManager::update(std::vector<double> startTimes, int activeTriggerTimeIndex){
|
||||
// check how many are left until fieldlinessequence runs out - add direction information later
|
||||
double nextTheroticalTimeTrigger;
|
||||
double eps = 100;
|
||||
if(activeTriggerTimeIndex == startTimes.size()-1){
|
||||
// if it's at the last index, definetily start some downloading
|
||||
return;
|
||||
}
|
||||
for (int i = activeTriggerTimeIndex; i < startTimes.size(); i++){
|
||||
nextTheroticalTimeTrigger = startTimes[i] +_timeTriggerDelta;
|
||||
if(startTimes[i + 1] > (nextTheroticalTimeTrigger + eps)){
|
||||
// do some downloading
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void WebFieldlinesManager::downloadOsfls(std::string triggertime){
|
||||
std::string WebFieldlinesManager::downloadOsfls(std::string triggertime){
|
||||
std::string url = "http://localhost:3000/WSA/" + triggertime;
|
||||
std::string destinationpath = absPath(_syncDir + '/' + triggertime.substr(6));
|
||||
AsyncHttpFileDownload ashd = AsyncHttpFileDownload(url, destinationpath, HttpFileDownload::Overwrite::Yes);
|
||||
@@ -127,6 +140,7 @@ namespace openspace{
|
||||
if(ashd.hasFailed() == true ){
|
||||
LERROR("failed: " + destinationpath);
|
||||
}
|
||||
return destinationpath;
|
||||
}
|
||||
|
||||
// Make sure that the sync directory exists
|
||||
@@ -152,23 +166,41 @@ namespace openspace{
|
||||
opt.requestTimeoutSeconds = 0;
|
||||
mmryDld.download(opt);
|
||||
|
||||
// Put the results in a string and remove [ ]
|
||||
// Put the results in a string
|
||||
std::string s;
|
||||
std::transform(mmryDld.downloadedData().begin(), mmryDld.downloadedData().end(), std::back_inserter(s),
|
||||
[](char c) {
|
||||
return c;
|
||||
});
|
||||
parseTriggerTimesList(s);
|
||||
|
||||
// sort ascending by trigger time
|
||||
std::sort(_availableTriggertimes.begin(), _availableTriggertimes.end());
|
||||
}
|
||||
|
||||
void WebFieldlinesManager::setInitialSet(double openSpaceTime){
|
||||
|
||||
int openspaceindex = -1;
|
||||
do openspaceindex++;
|
||||
while (openSpaceTime > _availableTriggertimes[openspaceindex].first);
|
||||
|
||||
int startInd = openspaceindex - _downloadMargin;
|
||||
int endInd = openspaceindex + _downloadMargin;
|
||||
|
||||
if(startInd < 0) startInd = 0;
|
||||
if(endInd >= _availableTriggertimes.size())
|
||||
endInd = _availableTriggertimes.size()-1;
|
||||
|
||||
for(int i = startInd; i <= endInd; i++)
|
||||
_filesToDownload.push_back(i);
|
||||
}
|
||||
|
||||
// TODO
|
||||
void WebFieldlinesManager::downloadInitialSequence(std::vector<double> triggertimes){
|
||||
|
||||
}
|
||||
|
||||
// TODO
|
||||
void WebFieldlinesManager::updateStartTimes(){
|
||||
|
||||
}
|
||||
@@ -177,25 +209,27 @@ namespace openspace{
|
||||
// Turn into stringstream to parse the comma-delimited string into vector
|
||||
std::stringstream ss(s);
|
||||
char c;
|
||||
std::string substr;
|
||||
std::string sub;
|
||||
while(ss >> c)
|
||||
{
|
||||
if (c == '[' || c == ']' || c == '"' ) continue;
|
||||
else if (c == ','){
|
||||
_availableTriggertimes.push_back(substr);
|
||||
substr.clear();
|
||||
double tt = triggerTimeString2Int(sub.substr(6, 23));
|
||||
_availableTriggertimes.push_back(std::make_pair(tt, sub));
|
||||
sub.clear();
|
||||
}
|
||||
else substr += c;
|
||||
else sub += c;
|
||||
}
|
||||
_availableTriggertimes.push_back(substr);
|
||||
double tt = triggerTimeString2Int(sub.substr(6, 23));
|
||||
_availableTriggertimes.push_back(std::make_pair(tt, sub));
|
||||
}
|
||||
|
||||
void WebFieldlinesManager::triggerTimeString2Int(std::string s, int& i){
|
||||
int WebFieldlinesManager::triggerTimeString2Int(std::string s){
|
||||
s.replace(13, 1, ":");
|
||||
s.replace(16, 1, ":");
|
||||
Time time = Time();
|
||||
time.setTime(s);
|
||||
i = static_cast<int> (time.j2000Seconds() - 69.185013294);
|
||||
return static_cast<int> (time.j2000Seconds() - 69.185013294);
|
||||
}
|
||||
|
||||
void WebFieldlinesManager::triggerTimeInt2String(int i, std::string& s){
|
||||
|
||||
@@ -32,13 +32,12 @@ namespace openspace {
|
||||
|
||||
class WebFieldlinesManager{
|
||||
public:
|
||||
WebFieldlinesManager() = default;
|
||||
|
||||
// Constructor
|
||||
WebFieldlinesManager(std::string identifier, std::string fieldLineModelType);
|
||||
|
||||
// For testing purposes
|
||||
void downloadFieldlines(std::vector<std::string>& _sourceFile, std::vector<double>& _startTimes, size_t& _nStates);
|
||||
WebFieldlinesManager() = default;
|
||||
WebFieldlinesManager(std::string syncDir);
|
||||
|
||||
// download files specified in _filestodownload
|
||||
void downloadFieldlines(std::vector<std::string>& _sourceFiles, std::vector<double>& _startTimes, size_t& _nStates);
|
||||
|
||||
//---------------- OPERATORS ------------------------- //
|
||||
|
||||
@@ -52,28 +51,33 @@ public:
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
// Directory for saving this specific typ of field line, named by the identifier
|
||||
std::string _syncDir;
|
||||
|
||||
// What model is this field line derived from, may come to be the same as the identifier
|
||||
std::string _flsType;
|
||||
|
||||
int _downloadMargin;
|
||||
|
||||
// How long between the timesteps?
|
||||
double _timeTriggerDelta;
|
||||
|
||||
// List of all triggertimes(field lines states) available for download
|
||||
// ***turn into ints later***
|
||||
std::vector<std::string> _availableTriggertimes;
|
||||
std::vector<std::pair<double, std::string>> _availableTriggertimes;
|
||||
|
||||
// Indices for what fieldlines to download
|
||||
std::vector<int> _filesToDownload;
|
||||
|
||||
// Function to run in FieldLinesSequence's update loop
|
||||
void update();
|
||||
void update(std::vector<double> startTimes, int activeTriggerTimeIndex);
|
||||
|
||||
// Download one file, given what model type and triggertime in J2000
|
||||
// ***turn into ints later***
|
||||
void downloadOsfls(std::string triggertime);
|
||||
|
||||
// Checks if there is a sync directory for one specific set of field lines
|
||||
// If not creates one and returns the string to that directory
|
||||
std::string initializeSyncDirectory(std::string identifier);
|
||||
std::string downloadOsfls(std::string triggertime);
|
||||
|
||||
std::string initializeSyncDirectory(std::string identifier);
|
||||
|
||||
// Get list of all triggertimes(field lines states) available form the server
|
||||
void getAvailableTriggertimes();
|
||||
|
||||
@@ -91,8 +95,8 @@ private:
|
||||
// Parse the data from http request
|
||||
void parseTriggerTimesList(std::string s);
|
||||
|
||||
// some temporary functions to translate the filenames to ints
|
||||
void triggerTimeString2Int(std::string s, int& d);
|
||||
// some temporary functions to translate the filenames to ints (doubles?)
|
||||
int triggerTimeString2Int(std::string s);
|
||||
void triggerTimeInt2String(int d, std::string& s);
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user