MCPcopy Create free account
hub / github.com/PDAL/PDAL / passesSpatialFilter

Method passesSpatialFilter

io/CopcReader.cpp:754–797  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

752
753
754bool 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
800bool CopcReader::hasSpatialFilter() const

Callers

nothing calls this directly

Calls 7

disjointMethod · 0.80
reprojectBoundsViaCornerFunction · 0.70
boundsMethod · 0.45
validMethod · 0.45
overlapsMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected