Last change
on this file since 1265 was
1251,
checked in by oabramkina, 7 years ago
|
Fixing a bug in case of activated missing values. If nan values are replaced by default values or vice versa data package (or data) is copied.
|
File size:
1.2 KB
|
Rev | Line | |
---|
[638] | 1 | #include "file_writer_filter.hpp" |
---|
| 2 | #include "exception.hpp" |
---|
| 3 | #include "field.hpp" |
---|
[1158] | 4 | #include "utils.hpp" |
---|
[638] | 5 | |
---|
| 6 | namespace xios |
---|
| 7 | { |
---|
[639] | 8 | CFileWriterFilter::CFileWriterFilter(CGarbageCollector& gc, CField* field) |
---|
| 9 | : CInputPin(gc, 1) |
---|
[638] | 10 | , field(field) |
---|
| 11 | { |
---|
| 12 | if (!field) |
---|
| 13 | ERROR("CFileWriterFilter::CFileWriterFilter(CField* field)", |
---|
| 14 | "The field cannot be null."); |
---|
| 15 | } |
---|
| 16 | |
---|
| 17 | void CFileWriterFilter::onInputReady(std::vector<CDataPacketPtr> data) |
---|
| 18 | { |
---|
[1201] | 19 | const bool detectMissingValue = (!field->detect_missing_value.isEmpty() |
---|
| 20 | && !field->default_value.isEmpty() |
---|
| 21 | && field->detect_missing_value == true); |
---|
[1251] | 22 | |
---|
| 23 | CArray<double, 1> dataArray = (detectMissingValue) ? data[0]->data.copy() : data[0]->data; |
---|
| 24 | |
---|
[1201] | 25 | if (detectMissingValue) |
---|
[1158] | 26 | { |
---|
[1201] | 27 | const double missingValue = field->default_value; |
---|
[1251] | 28 | const size_t nbData = dataArray.numElements(); |
---|
[1158] | 29 | for (size_t idx = 0; idx < nbData; ++idx) |
---|
| 30 | { |
---|
[1251] | 31 | if (NumTraits<double>::isnan(dataArray(idx))) |
---|
| 32 | dataArray(idx) = missingValue; |
---|
[1158] | 33 | } |
---|
[1201] | 34 | } |
---|
[1158] | 35 | |
---|
[1251] | 36 | field->sendUpdateData(dataArray); |
---|
[638] | 37 | } |
---|
[1158] | 38 | |
---|
| 39 | bool CFileWriterFilter::isDataExpected(const CDate& date) const |
---|
| 40 | { |
---|
| 41 | return true; |
---|
| 42 | } |
---|
[638] | 43 | } // namespace xios |
---|
Note: See
TracBrowser
for help on using the repository browser.