| 934 | |
| 935 | |
| 936 | bool CopcReader::processOne(PointRef& point) |
| 937 | { |
| 938 | top: |
| 939 | // If we've processed all the tiles, return false to indicate that |
| 940 | // we're done. |
| 941 | if (m_p->tileCount == 0) |
| 942 | return false; |
| 943 | |
| 944 | // If there is no active tile, grab one off the queue and ask for |
| 945 | // another if there are more. If none are available, wait. |
| 946 | if (!m_p->currentTile) |
| 947 | { |
| 948 | do |
| 949 | { |
| 950 | std::unique_lock<std::mutex> l(m_p->mutex); |
| 951 | if (m_p->contents.size()) |
| 952 | { |
| 953 | m_p->currentTile.reset(new copc::Tile(std::move(m_p->contents.front()))); |
| 954 | m_p->contents.pop(); |
| 955 | break; |
| 956 | } |
| 957 | else |
| 958 | m_p->contentsCv.wait(l); |
| 959 | } while (true); |
| 960 | m_p->consumedCv.notify_one(); |
| 961 | checkTile(*m_p->currentTile); |
| 962 | m_p->tilePointNum = 0; |
| 963 | } |
| 964 | |
| 965 | const char *p = m_p->currentTile->dataPtr() + (m_p->tilePointNum * m_p->header.pointSize); |
| 966 | bool ok = processPoint(p, point); |
| 967 | m_p->tilePointNum++; |
| 968 | |
| 969 | // If we've processed all the points in the current tile, pop it. |
| 970 | if ((size_t)m_p->tilePointNum == m_p->currentTile->size()) |
| 971 | { |
| 972 | m_p->tilePointNum = 0; |
| 973 | m_p->currentTile.reset(); |
| 974 | --m_p->tileCount; |
| 975 | } |
| 976 | |
| 977 | // If we didn't pass a point, try again. |
| 978 | if (!ok) |
| 979 | goto top; |
| 980 | |
| 981 | return true; |
| 982 | } |
| 983 | |
| 984 | |
| 985 | void CopcReader::done(PointTableRef) |