| 752 | |
| 753 | |
| 754 | bool CopcReader::passesSpatialFilter(const copc::Key& key) const |
| 755 | { |
| 756 | const BOX3D& tileBounds = key.bounds(m_p->rootNodeExtent); |
| 757 | |
| 758 | auto boxOverlaps = [this, &tileBounds]() -> bool |
| 759 | { |
| 760 | if (!m_p->clip.box.valid()) |
| 761 | return true; |
| 762 | |
| 763 | if (m_p->llToBcbfTransform.valid()) |
| 764 | { |
| 765 | return reprojectBoundsBcbfToLonLat(m_p->clip.box, m_p->llToBcbfTransform) |
| 766 | .overlaps(tileBounds); |
| 767 | } |
| 768 | |
| 769 | return reprojectBoundsViaCorner(tileBounds, m_p->clip.xform) |
| 770 | .overlaps(m_p->clip.box); |
| 771 | }; |
| 772 | |
| 773 | // Check the box of the key against our query polygon(s). If it doesn't overlap, |
| 774 | // we can skip |
| 775 | auto polysOverlap = [this, &tileBounds]() -> bool |
| 776 | { |
| 777 | if (m_p->polys.empty()) |
| 778 | return true; |
| 779 | |
| 780 | for (auto& ps : m_p->polys) |
| 781 | { |
| 782 | if (!ps.poly.disjoint(reprojectBoundsViaCorner(tileBounds, ps.xform))) |
| 783 | return true; |
| 784 | } |
| 785 | return false; |
| 786 | }; |
| 787 | |
| 788 | // If there's no spatial filter, we always overlap. |
| 789 | if (!hasSpatialFilter()) |
| 790 | return true; |
| 791 | |
| 792 | // This lock is here because if a bunch of threads are using the transform |
| 793 | // at the same time, it seems to get corrupted. There may be other instances |
| 794 | // that need to be locked. |
| 795 | std::lock_guard<std::mutex> lock(m_p->mutex); |
| 796 | return boxOverlaps() && polysOverlap(); |
| 797 | } |
| 798 | |
| 799 | |
| 800 | bool CopcReader::hasSpatialFilter() const |
nothing calls this directly
no test coverage detected