| 891 | |
| 892 | |
| 893 | point_count_t EptReader::read(PointViewPtr view, point_count_t count) |
| 894 | { |
| 895 | #ifndef PDAL_HAVE_ZSTD |
| 896 | if (m_p->info->dataType() == ept::EptInfo::DataType::Zstandard) |
| 897 | throwError("Cannot read Zstandard dataType: " |
| 898 | "PDAL must be configured with WITH_ZSTD=On"); |
| 899 | #endif |
| 900 | |
| 901 | point_count_t numRead = 0; |
| 902 | |
| 903 | if (m_p->hierarchy->size()) |
| 904 | { |
| 905 | // Pop tiles until there are no more, or wait for them to appear. |
| 906 | // Exit when we've handled all the tiles or we've read enough points. |
| 907 | do |
| 908 | { |
| 909 | std::unique_lock<std::mutex> l(m_p->mutex); |
| 910 | if (m_p->contents.size()) |
| 911 | { |
| 912 | ept::TileContents tile = std::move(m_p->contents.front()); |
| 913 | m_p->contents.pop(); |
| 914 | l.unlock(); |
| 915 | checkTile(tile); |
| 916 | process(view, tile, count - numRead); |
| 917 | numRead += tile.size(); |
| 918 | m_tileCount--; |
| 919 | } |
| 920 | else if (m_tileCount) |
| 921 | m_p->contentsCv.wait(l); |
| 922 | } while (m_tileCount && numRead <= count); |
| 923 | } |
| 924 | |
| 925 | // Wait for any running threads to finish and don't start any others. |
| 926 | // Only relevant if we hit the count limit before reading all the tiles. |
| 927 | m_p->pool->stop(); |
| 928 | |
| 929 | // If we're using the addon writer, transfer the info and hierarchy |
| 930 | // to that stage. |
| 931 | if (m_nodeIdDim != Dimension::Id::Unknown) |
| 932 | { |
| 933 | ept::ArtifactPtr artifact |
| 934 | (new ept::Artifact(std::move(m_p->info), std::move(m_p->hierarchy), |
| 935 | std::move(m_p->connector), m_p->hierarchyStep)); |
| 936 | m_artifactMgr->put("ept", artifact); |
| 937 | } |
| 938 | |
| 939 | return numRead; |
| 940 | } |
| 941 | |
| 942 | |
| 943 | // Put the contents of a tile into the destination point view. |