Commit 8bed959f4f51867f3bd318d6b9d8e488dc1df938

Authored by Benjamin Renard
1 parent 954b4c5b

Trim data value in downloaded JSON and VOTable files (related to #6566)

src/ParamOutputImpl/Download/FileWriterASCIIAbstract.cc
... ... @@ -546,7 +546,7 @@ bool FileWriterASCIIAbstract::writeFloatData(std::string paramId, int varIndex,
546 546 crtFile->setf(std::ios::right, std::ios::adjustfield);
547 547 crtFile->precision(3);
548 548 }
549   - else {
  549 + else if (!trimData()) {
550 550 crtFile->width(12);
551 551 }
552 552 if (isNAN(data))
... ...
src/ParamOutputImpl/Download/FileWriterASCIIAbstract.hh
... ... @@ -169,6 +169,11 @@ public:
169 169 virtual std::string getDataValueSeparator(void) = 0;
170 170  
171 171 /*
  172 + * @brief Abstract method used to know if data must be trimmed
  173 + */
  174 + virtual bool trimData(void) = 0;
  175 +
  176 + /*
172 177 * @overload FileWriter::createNewFile - Create a new ASCII file
173 178 */
174 179 virtual bool createNewFile(std::string filePath);
... ...
src/ParamOutputImpl/Download/FileWriterASCIIJson.cc
... ... @@ -271,6 +271,11 @@ std::string FileWriterASCIIJson::getDataValueSeparator(void)
271 271 return ", ";
272 272 }
273 273  
  274 +bool FileWriterASCIIJson::trimData(void)
  275 +{
  276 + return true;
  277 +}
  278 +
274 279 } /* namespace FileWriter */
275 280 } /* namespace Download */
276 281 } /* namespace ParamOutputImpl */
... ...
src/ParamOutputImpl/Download/FileWriterASCIIJson.hh
... ... @@ -145,6 +145,11 @@ public:
145 145 */
146 146 virtual std::string getDataValueSeparator(void);
147 147  
  148 + /*
  149 + * @overload FileWriterASCIIAbstract::trimData method used to know if data must be trimmed
  150 + */
  151 + virtual bool trimData(void);
  152 +
148 153 private:
149 154 /*
150 155 * @brief List of boolean to know if a first element is already write in a group for json format
... ...
src/ParamOutputImpl/Download/FileWriterASCIITabular.cc
... ... @@ -204,6 +204,11 @@ std::string FileWriterASCIITabular::getDataValueSeparator(void)
204 204 return "";
205 205 }
206 206  
  207 +bool FileWriterASCIITabular::trimData(void)
  208 +{
  209 + return false;
  210 +}
  211 +
207 212 } /* namespace FileWriter */
208 213 } /* namespace Download */
209 214 } /* namespace ParamOutputImpl */
... ...
src/ParamOutputImpl/Download/FileWriterASCIITabular.hh
... ... @@ -144,6 +144,11 @@ public:
144 144 * @overload FileWriterASCIIAbstract::getDataValueSeparator method to get data value separator for tabular format
145 145 */
146 146 virtual std::string getDataValueSeparator(void);
  147 +
  148 + /*
  149 + * @overload FileWriterASCIIAbstract::trimData method used to know if data must be trimmed
  150 + */
  151 + virtual bool trimData(void);
147 152 };
148 153  
149 154 } /* namespace FileWriter */
... ...
src/ParamOutputImpl/Download/FileWriterASCIIVOTable.cc
... ... @@ -232,6 +232,11 @@ std::string FileWriterASCIIVOTable::getDataValueSeparator(void)
232 232 return " ";
233 233 }
234 234  
  235 +bool FileWriterASCIIVOTable::trimData(void)
  236 +{
  237 + return true;
  238 +}
  239 +
235 240 bool FileWriterASCIIVOTable::writeTimeData(std::string paramId, double data, OutputFormatTime /*timeFormat*/, bool isFirstParam)
236 241 {
237 242 //force ISO format for time field
... ...
src/ParamOutputImpl/Download/FileWriterASCIIVOTable.hh
... ... @@ -149,6 +149,11 @@ public:
149 149 * @overload FileWriterASCIIAbstract::getDataValueSeparator method to get data value separator for votable format
150 150 */
151 151 virtual std::string getDataValueSeparator(void);
  152 +
  153 + /*
  154 + * @overload FileWriterASCIIAbstract::trimData method used to know if data must be trimmed
  155 + */
  156 + virtual bool trimData(void);
152 157  
153 158 /*
154 159 * @overload FileWriterASCIIAbstract::writeTimeData - Write a time data in the ASCII file - Fot VOTable, only ISO time is available
... ...