Class S2ShapeIndexRegion
java.lang.Object
com.google.common.geometry.S2ShapeIndexRegion
- All Implemented Interfaces:
S2Region
@GwtCompatible(serializable=false)
public class S2ShapeIndexRegion
extends Object
implements S2Region
This class wraps an S2ShapeIndex object with the additional methods needed to implement the
S2Region API, in order to allow S2RegionCoverer to compute S2CellId coverings of arbitrary
collections of geometry.
Example usage:
S2CellUnion getCovering(S2ShapeIndex index) {
S2RegionCoverer coverer = new S2RegionCoverer();
coverer.setMaxCells(20);
return coverer.getCovering(new S2ShapeIndexRegion(index));
}
This class uses a number of temporary mutable objects to keep allocation down, and so is not thread-safe. To use it in parallel, each thread should construct its own instance (this is not expensive).
-
Constructor Summary
ConstructorsConstructorDescriptionS2ShapeIndexRegion(S2ShapeIndex index) Creates a new region with the given index, and asemi-openvertex model.S2ShapeIndexRegion(S2ShapeIndex index, S2ContainsPointQuery.S2VertexModel model) Creates a new region with the given index, and a givenS2ContainsPointQuery.S2VertexModel. -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns true if 'target' is contained by any single shape.booleanReturns true if the given point is contained by any two-dimensional shape (i.e., polygon).Return a bounding spherical cap.voidgetCellUnionBound(List<S2CellId> cellIds) Clears the given list of cells and adds the cell union of this index.Return a bounding latitude-longitude rectangle.booleanmayIntersect(S2Cell target) Returns true if any shape intersects "target".
-
Constructor Details
-
S2ShapeIndexRegion
Creates a new region with the given index, and asemi-openvertex model. -
S2ShapeIndexRegion
Creates a new region with the given index, and a givenS2ContainsPointQuery.S2VertexModel.
-
-
Method Details
-
getCapBound
Description copied from interface:S2RegionReturn a bounding spherical cap.- Specified by:
getCapBoundin interfaceS2Region
-
getRectBound
Description copied from interface:S2RegionReturn a bounding latitude-longitude rectangle.- Specified by:
getRectBoundin interfaceS2Region
-
getCellUnionBound
-
contains
-
contains
Returns true if 'target' is contained by any single shape. If the cell is covered by a union of different shapes then it may return false.This implementation is conservative but not exact; if a shape just barely contains the given cell then it may return false. The maximum error is less than 10 * DBL_EPSILON radians (or about 15 nanometers).
-
mayIntersect
Returns true if any shape intersects "target".This implementation is conservative but not exact; if a shape is just barely disjoint from the given cell then it may return true. The maximum error is less than 10 * DBL_EPSILON radians (or about 15 nanometers).
- Specified by:
mayIntersectin interfaceS2Region
-