| 141 | |
| 142 | |
| 143 | point_count_t TerrasolidReader::read(PointViewPtr view, point_count_t count) |
| 144 | { |
| 145 | count = (std::min)(count, getNumPoints() - m_index); |
| 146 | |
| 147 | std::vector<char> buf(m_size * count); |
| 148 | m_istream->get(buf); |
| 149 | LeExtractor extractor(buf.data(), buf.size()); |
| 150 | |
| 151 | // See https://www.terrasolid.com/download/tscan.pdf |
| 152 | // This spec is awful, but it's something. |
| 153 | // The scaling adjustments are different than what we used to do and |
| 154 | // seem wrong (scaling the offset is odd), but that's what the document |
| 155 | // says. |
| 156 | // Also modified the fetch of time/color based on header flag (rather |
| 157 | // than just not write the data into the buffer). |
| 158 | PointId nextId = view->size(); |
| 159 | while (!eof()) |
| 160 | { |
| 161 | if (m_format == TERRASOLID_Format_1) |
| 162 | { |
| 163 | uint8_t classification, flight_line, echo_int, x, y, z; |
| 164 | |
| 165 | extractor >> classification >> flight_line >> echo_int >> x >> y >> |
| 166 | z; |
| 167 | |
| 168 | view->setField(Dimension::Id::Classification, nextId, |
| 169 | classification); |
| 170 | view->setField(Dimension::Id::PointSourceId, nextId, flight_line); |
| 171 | switch (echo_int) |
| 172 | { |
| 173 | case 0: // only echo |
| 174 | view->setField(Dimension::Id::ReturnNumber, nextId, 1); |
| 175 | view->setField(Dimension::Id::NumberOfReturns, nextId, 1); |
| 176 | break; |
| 177 | case 1: // first of many echos |
| 178 | view->setField(Dimension::Id::ReturnNumber, nextId, 1); |
| 179 | break; |
| 180 | default: // intermediate echo or last of many echos |
| 181 | break; |
| 182 | } |
| 183 | view->setField(Dimension::Id::X, nextId, |
| 184 | (x - m_header->OrgX) / m_header->Units); |
| 185 | view->setField(Dimension::Id::Y, nextId, |
| 186 | (y - m_header->OrgY) / m_header->Units); |
| 187 | view->setField(Dimension::Id::Z, nextId, |
| 188 | (z - m_header->OrgZ) / m_header->Units); |
| 189 | } |
| 190 | |
| 191 | if (m_format == TERRASOLID_Format_2) |
| 192 | { |
| 193 | int32_t x, y, z; |
| 194 | uint8_t classification, echo_int, flag, mark; |
| 195 | uint16_t flight_line, intensity; |
| 196 | |
| 197 | extractor >> x >> y >> z >> classification >> echo_int >> flag >> |
| 198 | mark >> flight_line >> intensity; |
| 199 | |
| 200 | view->setField(Dimension::Id::X, nextId, |