Package com.google.common.geometry
Class S2ContainsPointQuery
java.lang.Object
com.google.common.geometry.S2ContainsPointQuery
A query for whether one or more shapes in an
S2ShapeIndex 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 to S2ContainsPointQuery.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 ClassesModifier and TypeClassDescription(package private) static interfaceA visitor that receives each edge that has some query point p as an endpoint.static final classThe options for building an S2ContainsPointQuery.static enumA rule for whether shapes are considered to contain their vertices.(package private) static interfaceA visitor that receives each shape that contains a query point, returning true to continue receiving shapes or false to terminate early. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final S2Iterator<S2ShapeIndex.Cell> private final S2ContainsPointQuery.Options -
Constructor Summary
ConstructorsConstructorDescriptionS2ContainsPointQuery(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
Modifier and TypeMethodDescriptionbooleanReturns true if any shape in the given iterator containspunder the specifiedS2ContainsPointQuery.S2VertexModel.A convenience function that returns all the shapes that containp.options()Returns the options used to build this query.booleanshapeContains(S2Shape shape, S2Point p) Returns true if the given shape containspunder the specifiedS2ContainsPointQuery.S2VertexModel.(package private) booleanVisits each shape that containspunder the specifiedS2ContainsPointQuery.S2VertexModelexactly once, and returns true, or terminates early and returns false if any invocation ofreturns false.invalid reference
ShapeVisitor#apply(S2Shape)(package private) booleanvisitIncidentEdges(S2Point p, S2ContainsPointQuery.EdgeVisitor visitor, S2Shape.MutableEdge tmp) Visits each edge in the index that is incident topexactly once, and returns true, or terminates early and returns false ifvisitorreturns false.
-
Field Details
-
options
-
it
-
-
Constructor Details
-
S2ContainsPointQuery
Constructs a semi-open contains-point query from the given iterator. -
S2ContainsPointQuery
Constructs a contains-point query from the given iterator, with the specified options.
-
-
Method Details
-
options
Returns the options used to build this query. -
contains
Returns true if any shape in the given iterator containspunder the specifiedS2ContainsPointQuery.S2VertexModel. -
shapeContains
Returns true if the given shape containspunder the specifiedS2ContainsPointQuery.S2VertexModel. -
visitContainingShapes
Visits each shape that containspunder the specifiedS2ContainsPointQuery.S2VertexModelexactly once, and returns true, or terminates early and returns false if any invocation ofreturns false.invalid reference
ShapeVisitor#apply(S2Shape) -
getContainingShapes
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 topexactly once, and returns true, or terminates early and returns false ifvisitorreturns false. An "incident edge" is one wherepis one of the edge endpoints. The visitor requires the edge endpoints, and so this method requires a temporary mutable edge to store edges in.
-