This code runs in a single thread, so doesn't need locking.
| 826 | |
| 827 | // This code runs in a single thread, so doesn't need locking. |
| 828 | bool CopcReader::processPoint(const char *inbuf, PointRef& dst) |
| 829 | { |
| 830 | using namespace Dimension; |
| 831 | |
| 832 | // Extract XYZ to check if we want this point at all. |
| 833 | LeExtractor in(inbuf, m_p->header.pointSize); |
| 834 | |
| 835 | int32_t ix, iy, iz; |
| 836 | in >> ix >> iy >> iz; |
| 837 | |
| 838 | double x = m_p->scaling.m_xXform.fromScaled(ix); |
| 839 | double y = m_p->scaling.m_yXform.fromScaled(iy); |
| 840 | double z = m_p->scaling.m_zXform.fromScaled(iz); |
| 841 | |
| 842 | auto passesBoundsFilter = [this](double x, double y, double z) |
| 843 | { |
| 844 | if (!m_p->clip.box.valid()) |
| 845 | return true; |
| 846 | m_p->clip.xform.transform(x, y, z); |
| 847 | return m_p->clip.box.contains(x, y, z); |
| 848 | }; |
| 849 | |
| 850 | auto passesPolyFilter = [this](double xo, double yo, double zo) |
| 851 | { |
| 852 | if (m_p->polys.empty()) |
| 853 | return true; |
| 854 | |
| 855 | for (PolyXform& ps : m_p->polys) |
| 856 | { |
| 857 | double x = xo; |
| 858 | double y = yo; |
| 859 | double z = zo; |
| 860 | |
| 861 | ps.xform.transform(x, y, z); |
| 862 | if (ps.poly.contains(x, y)) |
| 863 | return true; |
| 864 | } |
| 865 | return false; |
| 866 | }; |
| 867 | |
| 868 | // If there is a spatial filter, make sure it passes. |
| 869 | if (hasSpatialFilter()) |
| 870 | if (!passesBoundsFilter(x, y, z) || !passesPolyFilter(x, y, z)) |
| 871 | return false; |
| 872 | |
| 873 | m_p->loader.load(dst, inbuf, m_p->header.pointSize); |
| 874 | |
| 875 | return true; |
| 876 | } |
| 877 | |
| 878 | |
| 879 | point_count_t CopcReader::read(PointViewPtr view, point_count_t count) |