Package com.google.common.geometry
Class S2ShapeIndex.Cell
- java.lang.Object
-
- com.google.common.geometry.S2ShapeIndex.Cell
-
- All Implemented Interfaces:
S2Iterator.Entry,java.io.Serializable
- Direct Known Subclasses:
S2ShapeIndex.Cell.BinaryCell,S2ShapeIndex.Cell.MultiCell,S2ShapeIndex.S2ClippedShape,S2ShapeIndexCoder.EncodedS2ShapeIndex.LazyCell
- Enclosing class:
- S2ShapeIndex
public abstract static class S2ShapeIndex.Cell extends java.lang.Object implements S2Iterator.Entry, java.io.Serializable
This class contains the set of clipped shapes within a particular index cell, sorted in increasing order of shape id.To be as memory efficient as possible, we specialize two very common cases.
- The Cell class is extended by S2ClippedShape, and in the *very* common case of a cell
containing just one clipped shape, we return the shape directly without wrapping it (this
requires that the clipped shapes contain the cell IDs, rather than the Cell; more about
that on
S2ShapeIndex.S2ClippedShape.) - In the fairly common case of a cell intersecting two shapes, we have a BinaryCell implementation that is half the size of the general purpose MultiCell in that case.
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classS2ShapeIndex.Cell.BinaryCellA specialization of Cell for the case of two clipped shapes.private static classS2ShapeIndex.Cell.MultiCellA specialization of Cell for multiple shapes per cell.
-
Field Summary
Fields Modifier and Type Field Description private static longserialVersionUID
-
Constructor Summary
Constructors Constructor Description Cell()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract S2ShapeIndex.S2ClippedShapeclipped(int i)Returns the clipped shape at the given index.(package private) static S2ShapeIndex.Cellcreate(int size, S2ShapeIndex.S2ClippedShape[] tempClippedShapes)Returns a Cell with a copy of the given shapes, specialized for the number of elements.(package private) S2ShapeIndex.S2ClippedShapefindClipped(S2Shape shape)Returns the clipped shape corresponding to the given shape ID, or null if the shape does not intersect this cell.longid()Returns the cell ID of this cell as a primitive.abstract intnumShapes()Returns the number of clipped shapes in this cell.
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
-
Method Detail
-
create
static S2ShapeIndex.Cell create(int size, S2ShapeIndex.S2ClippedShape[] tempClippedShapes)
Returns a Cell with a copy of the given shapes, specialized for the number of elements.
-
id
public long id()
Description copied from interface:S2Iterator.EntryReturns the cell ID of this cell as a primitive.- Specified by:
idin interfaceS2Iterator.Entry
-
numShapes
public abstract int numShapes()
Returns the number of clipped shapes in this cell.
-
clipped
public abstract S2ShapeIndex.S2ClippedShape clipped(int i)
Returns the clipped shape at the given index.- Parameters:
i- must be at least 0 and less thannumShapes()
-
findClipped
S2ShapeIndex.S2ClippedShape findClipped(S2Shape shape)
Returns the clipped shape corresponding to the given shape ID, or null if the shape does not intersect this cell.
-
-