MCPcopy
hub / github.com/golang/geo / ContainsPoint

Method ContainsPoint

s2/loop.go:601–629  ·  view source on GitHub ↗

ContainsPoint returns true if the loop contains the point.

(p Point)

Source from the content-addressed store, hash-verified

599
600// ContainsPoint returns true if the loop contains the point.
601func (l *Loop) ContainsPoint(p Point) bool {
602 if !l.index.IsFresh() && !l.bound.ContainsPoint(p) {
603 return false
604 }
605
606 // For small loops it is faster to just check all the crossings. We also
607 // use this method during loop initialization because InitOriginAndBound()
608 // calls Contains() before InitIndex(). Otherwise, we keep track of the
609 // number of calls to Contains() and only build the index when enough calls
610 // have been made so that we think it is worth the effort. Note that the
611 // code below is structured so that if many calls are made in parallel only
612 // one thread builds the index, while the rest continue using brute force
613 // until the index is actually available.
614
615 const maxBruteForceVertices = 32
616 // TODO(roberts): add unindexed contains calls tracking
617
618 if len(l.index.shapes) == 0 || // Index has not been initialized yet.
619 len(l.vertices) <= maxBruteForceVertices {
620 return l.bruteForceContainsPoint(p)
621 }
622
623 // Otherwise, look up the point in the index.
624 it := l.index.Iterator()
625 if !it.LocatePoint(p) {
626 return false
627 }
628 return l.iteratorContainsPoint(it, p)
629}
630
631// ContainsCell reports whether the given Cell is contained by this Loop.
632func (l *Loop) ContainsCell(target Cell) bool {

Callers 7

initOriginAndBoundMethod · 0.95
initBoundMethod · 0.95
ContainsMethod · 0.95
IntersectsMethod · 0.95
compareBoundaryMethod · 0.95
ContainsNestedMethod · 0.95

Calls 6

iteratorContainsPointMethod · 0.95
IsFreshMethod · 0.80
IteratorMethod · 0.80
LocatePointMethod · 0.80
ContainsPointMethod · 0.65

Tested by

no test coverage detected