Package com.google.common.geometry
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
Constructors Constructor Description S2ShapeIndexRegion(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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancontains(S2Cell target)Returns true if 'target' is contained by any single shape.booleancontains(S2Point p)Returns true if the given point is contained by any two-dimensional shape (i.e., polygon).S2CapgetCapBound()Return a bounding spherical cap.voidgetCellUnionBound(List<S2CellId> cellIds)Clears the given list of cells and adds the cell union of this index.S2LatLngRectgetRectBound()Return a bounding latitude-longitude rectangle.booleanmayIntersect(S2Cell target)Returns true if any shape intersects "target".
-
-
-
Constructor Detail
-
S2ShapeIndexRegion
public S2ShapeIndexRegion(S2ShapeIndex index)
Creates a new region with the given index, and asemi-openvertex model.
-
S2ShapeIndexRegion
public S2ShapeIndexRegion(S2ShapeIndex index, S2ContainsPointQuery.S2VertexModel model)
Creates a new region with the given index, and a givenS2ContainsPointQuery.S2VertexModel.
-
-
Method Detail
-
getCapBound
public S2Cap getCapBound()
Description copied from interface:S2RegionReturn a bounding spherical cap.- Specified by:
getCapBoundin interfaceS2Region
-
getRectBound
public S2LatLngRect getRectBound()
Description copied from interface:S2RegionReturn a bounding latitude-longitude rectangle.- Specified by:
getRectBoundin interfaceS2Region
-
getCellUnionBound
public void getCellUnionBound(List<S2CellId> cellIds)
Clears the given list of cells and adds the cell union of this index. An index of shapes in one face adds up to 4 cells, otherwise up to 6 may be added.
-
contains
public boolean contains(S2Point p)
Returns true if the given point is contained by any two-dimensional shape (i.e., polygon). Zero and one-dimensional shapes are ignored by this method.
-
contains
public boolean contains(S2Cell target)
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
public boolean mayIntersect(S2Cell target)
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
-
-