/***************************************************************************************** * * * OpenSpace * * * * Copyright (c) 2014-2018 * * * * 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 { using json = nlohmann::json; } // namespace 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 = static_cast(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(col.size()); for(int x=0; x DataProcessorJson::processData(std::string data, properties::SelectionProperty& optionProp, glm::size3_t& dimensions) { if (!data.empty()) { json j = json::parse(data); json variables = j["variables"]; std::vector selectedOptions = optionProp.value(); // int numSelected = selectedOptions.size(); const std::vector& options = optionProp.options(); int numOptions = static_cast(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.f }; json row = variables[options[option].description]; rowsize = static_cast(row.size()); for(int y=0; y(col.size()); for(int x=0; x(); } } //namespace openspace