| 54 | |
| 55 | |
| 56 | point_count_t MyReader::read(PointViewPtr view, point_count_t count) |
| 57 | { |
| 58 | PointLayoutPtr layout = view->layout(); |
| 59 | PointId nextId = view->size(); |
| 60 | PointId idx = m_index; |
| 61 | point_count_t numRead = 0; |
| 62 | |
| 63 | m_stream.reset(new ILeStream(m_filename)); |
| 64 | |
| 65 | size_t HEADERSIZE(1); |
| 66 | size_t skip_lines((std::max)(HEADERSIZE, (size_t)m_index)); |
| 67 | size_t line_no(1); |
| 68 | for (std::string line; std::getline(*m_stream->stream(), line); line_no++) |
| 69 | { |
| 70 | if (line_no <= skip_lines) |
| 71 | { |
| 72 | continue; |
| 73 | } |
| 74 | |
| 75 | // MyReader format: X::Y::Z::Data |
| 76 | StringList s = Utils::split2(line, ':'); |
| 77 | |
| 78 | unsigned long u64(0); |
| 79 | if (s.size() != 4) |
| 80 | { |
| 81 | std::stringstream oss; |
| 82 | oss << "Unable to split proper number of fields. Expected 4, got " |
| 83 | << s.size(); |
| 84 | throw pdal_error(oss.str()); |
| 85 | } |
| 86 | |
| 87 | std::string name("X"); |
| 88 | view->setField(Dimension::Id::X, nextId, convert<double>(s, name, 0)); |
| 89 | |
| 90 | name = "Y"; |
| 91 | view->setField(Dimension::Id::Y, nextId, convert<double>(s, name, 1)); |
| 92 | |
| 93 | name = "Z"; |
| 94 | double z = convert<double>(s, name, 2) * m_scale_z; |
| 95 | view->setField(Dimension::Id::Z, nextId, z); |
| 96 | |
| 97 | name = "MyData"; |
| 98 | view->setField(layout->findProprietaryDim(name), |
| 99 | nextId, |
| 100 | convert<unsigned int>(s, name, 3)); |
| 101 | |
| 102 | nextId++; |
| 103 | if (m_cb) |
| 104 | m_cb(*view, nextId); |
| 105 | } |
| 106 | m_index = nextId; |
| 107 | numRead = nextId; |
| 108 | |
| 109 | return numRead; |
| 110 | } |
| 111 | |
| 112 | void MyReader::done(PointTableRef) |
| 113 | { |
nothing calls this directly
no test coverage detected