Package com.google.common.geometry
Class S2ContainsPointQuery
- java.lang.Object
-
- com.google.common.geometry.S2ContainsPointQuery
-
@GwtCompatible public class S2ContainsPointQuery extends java.lang.Object
A query for whether one or more shapes in anS2ShapeIndex
contain a given S2Point.The S2ShapeIndex may contain any number of points, polylines, and/or polygons (possibly overlapping). Shape boundaries are modeled with a constructor parameter,
S2ContainsPointQuery.S2VertexModel
, which defaults toS2ContainsPointQuery.S2VertexModel.SEMI_OPEN
. This may be customized to control whether or not shapes are considered to contain their vertices.This class is not thread-safe. To use it in parallel, each thread should construct its own instance (this is not expensive). However, note that if you need to do a large number of point containment tests, it is more efficient to re-use the S2ContainsPointQuery object rather than constructing a new one each time.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static interface
S2ContainsPointQuery.EdgeVisitor
A visitor that receives each edge that has some query point p as an endpoint.static class
S2ContainsPointQuery.Options
The options for building an S2ContainsPointQuery.static class
S2ContainsPointQuery.S2VertexModel
A rule for whether shapes are considered to contain their vertices.(package private) static interface
S2ContainsPointQuery.ShapeVisitor
A visitor that receives each shape that contains a query point, returning true to continue receiving shapes or false to terminate early.
-
Field Summary
Fields Modifier and Type Field Description private S2Iterator<S2ShapeIndex.Cell>
it
private S2ContainsPointQuery.Options
options
-
Constructor Summary
Constructors Constructor Description S2ContainsPointQuery(S2ShapeIndex index)
Constructs a semi-open contains-point query from the given iterator.S2ContainsPointQuery(S2ShapeIndex index, S2ContainsPointQuery.Options options)
Constructs a contains-point query from the given iterator, with the specified options.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
contains(S2Point p)
Returns true if any shape in the given iterator containsp
under the specifiedS2ContainsPointQuery.S2VertexModel
.java.lang.Iterable<S2Shape>
getContainingShapes(S2Point p)
A convenience function that returns all the shapes that containp
.S2ContainsPointQuery.Options
options()
Returns the options used to build this query.boolean
shapeContains(S2Shape shape, S2Point p)
Returns true if the given shape containsp
under the specifiedS2ContainsPointQuery.S2VertexModel
.(package private) boolean
visitContainingShapes(S2Point p, S2ContainsPointQuery.ShapeVisitor visitor)
Visits each shape that containsp
under the specifiedS2ContainsPointQuery.S2VertexModel
exactly once, and returns true, or terminates early and returns false if any invocation ofShapeVisitor#apply(S2Shape)
returns false.(package private) boolean
visitIncidentEdges(S2Point p, S2ContainsPointQuery.EdgeVisitor visitor, S2Shape.MutableEdge tmp)
Visits each edge in the index that is incident top
exactly once, and returns true, or terminates early and returns false ifvisitor
returns false.
-
-
-
Field Detail
-
options
private final S2ContainsPointQuery.Options options
-
it
private final S2Iterator<S2ShapeIndex.Cell> it
-
-
Constructor Detail
-
S2ContainsPointQuery
public S2ContainsPointQuery(S2ShapeIndex index)
Constructs a semi-open contains-point query from the given iterator.
-
S2ContainsPointQuery
public S2ContainsPointQuery(S2ShapeIndex index, S2ContainsPointQuery.Options options)
Constructs a contains-point query from the given iterator, with the specified options.
-
-
Method Detail
-
options
public S2ContainsPointQuery.Options options()
Returns the options used to build this query.
-
contains
public boolean contains(S2Point p)
Returns true if any shape in the given iterator containsp
under the specifiedS2ContainsPointQuery.S2VertexModel
.
-
shapeContains
public boolean shapeContains(S2Shape shape, S2Point p)
Returns true if the given shape containsp
under the specifiedS2ContainsPointQuery.S2VertexModel
.
-
visitContainingShapes
boolean visitContainingShapes(S2Point p, S2ContainsPointQuery.ShapeVisitor visitor)
Visits each shape that containsp
under the specifiedS2ContainsPointQuery.S2VertexModel
exactly once, and returns true, or terminates early and returns false if any invocation ofShapeVisitor#apply(S2Shape)
returns false.
-
getContainingShapes
public java.lang.Iterable<S2Shape> getContainingShapes(S2Point p)
A convenience function that returns all the shapes that containp
.
-
visitIncidentEdges
boolean visitIncidentEdges(S2Point p, S2ContainsPointQuery.EdgeVisitor visitor, S2Shape.MutableEdge tmp)
Visits each edge in the index that is incident top
exactly once, and returns true, or terminates early and returns false ifvisitor
returns false. An "incident edge" is one wherep
is one of the edge endpoints. The visitor requires the edge endpoints, and so this method requires a temporary mutable edge to store edges in.
-
-