/***************************************************************************************** * * * OpenSpace * * * * Copyright (c) 2014-2015 * * * * Permission is hereby granted, free of charge, to any person obtaining a copy of this * * software and associated documentation files (the "Software"), to deal in the Software * * without restriction, including without limitation the rights to use, copy, modify, * * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to * * permit persons to whom the Software is furnished to do so, subject to the following * * conditions: * * * * The above copyright notice and this permission notice shall be included in all copies * * or substantial portions of the Software. * * * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ #include #include #include #include namespace { const std::string _loggerCat = "DataProcessorJson"; using json = nlohmann::json; } namespace openspace{ DataProcessorJson::DataProcessorJson() :DataProcessor() {} DataProcessorJson::~DataProcessorJson(){} std::vector DataProcessorJson::readMetadata(std::string data, glm::size3_t& dimensions){ std::vector options = std::vector(); if(!data.empty()){ json j = json::parse(data); json variables = j["variables"]; for(json::iterator it = variables.begin(); it != variables.end(); ++it){ std::string option = it.key(); if(option == "ep"){ json row = it.value(); json col = row.at(0); dimensions = glm::size3_t(col.size(), row.size(), 1); } if(_coordinateVariables.find(option) == _coordinateVariables.end()){ options.push_back(option); } } } return options; } void DataProcessorJson::addDataValues(std::string data, properties::SelectionProperty& dataOptions){ int numOptions = dataOptions.options().size(); initializeVectors(numOptions); if(!data.empty()){ json j = json::parse(data); json variables = j["variables"]; std::vector sum(numOptions, 0.0f); std::vector> optionValues(numOptions, std::vector()); auto options = dataOptions.options(); float value; for(int i=0; i DataProcessorJson::processData(std::string data, properties::SelectionProperty& dataOptions, glm::size3_t& dimensions){ if(!data.empty()){ json j = json::parse(data); json variables = j["variables"]; std::vector selectedOptions = dataOptions.value(); int numSelected = selectedOptions.size(); auto options = dataOptions.options(); int numOptions = options.size(); float value; int rowsize, colsize, i; std::vector dataOptions(numOptions, nullptr); for(int option : selectedOptions){ dataOptions[option] = new float[dimensions.x*dimensions.y]{0.0f}; json row = variables[options[option].description]; rowsize = row.size(); for(int y=0; y(); } }//namespace openspace