| 113 | |
| 114 | |
| 115 | point_count_t IcebridgeReader::read(PointViewPtr view, point_count_t count) |
| 116 | { |
| 117 | //All data we read for icebridge is currently 4 bytes wide, so |
| 118 | // just allocate once and forget it. |
| 119 | //This could be a huge allocation. Perhaps we should do something |
| 120 | // in the icebridge handler? |
| 121 | |
| 122 | PointId startId = view->size(); |
| 123 | point_count_t remaining = m_hdf5Handler.getNumPoints() - m_index; |
| 124 | count = (std::min)(count, remaining); |
| 125 | |
| 126 | std::vector<uint8_t> rawData(count * sizeof(float)); |
| 127 | |
| 128 | //Not loving the position-linked data, but fine for now. |
| 129 | Dimension::IdList dims = dimensions(); |
| 130 | auto di = dims.begin(); |
| 131 | for (auto ci = hdf5Columns.begin(); ci != hdf5Columns.end(); ++ci, ++di) |
| 132 | { |
| 133 | PointId nextId = startId; |
| 134 | PointId idx = m_index; |
| 135 | const hdf5::Hdf5ColumnData& column = *ci; |
| 136 | |
| 137 | try |
| 138 | { |
| 139 | m_hdf5Handler.getColumnEntries(rawData.data(), column.name, count, |
| 140 | m_index); |
| 141 | void *p = (void *)rawData.data(); |
| 142 | |
| 143 | // This is ugly but avoids a test in a tight loop. |
| 144 | if (column.predType == H5::PredType::NATIVE_FLOAT) |
| 145 | { |
| 146 | // Offset time is in ms but icebridge stores in seconds. |
| 147 | if (*di == Dimension::Id::OffsetTime) |
| 148 | { |
| 149 | float *fval = (float *)p; |
| 150 | for (PointId i = 0; i < count; ++i) |
| 151 | { |
| 152 | view->setField(*di, nextId++, *fval * 1000); |
| 153 | fval++; |
| 154 | } |
| 155 | } |
| 156 | else if (*di == Dimension::Id::X) |
| 157 | { |
| 158 | float *fval = (float *)p; |
| 159 | for (PointId i = 0; i < count; ++i) |
| 160 | { |
| 161 | double dval = (double)(*fval); |
| 162 | // Longitude is 0-360. Convert |
| 163 | dval = Utils::normalizeLongitude(dval); |
| 164 | view->setField(*di, nextId++, dval); |
| 165 | fval++; |
| 166 | } |
| 167 | |
| 168 | } |
| 169 | else |
| 170 | { |
| 171 | float *fval = (float *)p; |
| 172 | for (PointId i = 0; i < count; ++i) |
no test coverage detected