Skip to content

Commit

Permalink
correct padding per series instead
Browse files Browse the repository at this point in the history
  • Loading branch information
tremblap committed Mar 7, 2024
1 parent b0c466c commit 15180b1
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions include/data/FluidJSON.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,18 +142,13 @@ void to_json(nlohmann::json &j, const FluidDataSeries<std::string, T, 1> &ds) {
auto ids = ds.getIds();
auto data = ds.getData();
j["cols"] = ds.pointSize();
index maxlength = 0;
for (index r = 0; r < ds.size(); r++) {
auto length = data[r].rows();
maxlength = std::max(maxlength, length);
}
index stringlen = std::ceil(std::log10(maxlength-1));
std::stringstream timestring;
for (index r = 0; r < ds.size(); r++) {
auto series = data[r];
index stringlen = std::ceil(std::log10(series.rows() - 1));
for (index s = 0; s < series.rows(); s++) {
timestring.str("");
timestring.clear();
timestring.str("");
timestring.clear();
timestring << std::setw(stringlen) << std::setfill('0') << s;
j["data"][ids[r]][timestring.str()] = data[r].row(s);
}
Expand Down

0 comments on commit 15180b1

Please sign in to comment.