Package com.google.common.geometry
Class S2ShapeIndexCoder.EncodedS2ShapeIndex
- java.lang.Object
-
- com.google.common.geometry.S2ShapeIndex
-
- com.google.common.geometry.S2ShapeIndexCoder.EncodedS2ShapeIndex
-
- All Implemented Interfaces:
java.io.Serializable
- Enclosing class:
- S2ShapeIndexCoder
private static final class S2ShapeIndexCoder.EncodedS2ShapeIndex extends S2ShapeIndex
Represents an encodedS2ShapeIndex.This class is thread-safe.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private classS2ShapeIndexCoder.EncodedS2ShapeIndex.LazyCellA lazy implementation ofS2ShapeIndex.Cellwhich decodes members on demand.-
Nested classes/interfaces inherited from class com.google.common.geometry.S2ShapeIndex
S2ShapeIndex.Cell, S2ShapeIndex.CellRelation, S2ShapeIndex.InteriorTracker, S2ShapeIndex.Options, S2ShapeIndex.RangeIterator, S2ShapeIndex.S2ClippedShape
-
-
Field Summary
Fields Modifier and Type Field Description private S2Shape[]cachedShapesThe array of not-yet-decoded and decoded shapes.private S2Coder<S2ShapeIndex.S2ClippedShape[]>clippedShapeArrayCoderA coder ofS2ClippedShape[]s.private java.util.List<S2ShapeIndex.Cell>decodedCellsThe list ofS2ShapeIndex.Cells.private S2CellIdVectorencodedCellIdsThe encoded vector of cell IDs of this index.private java.util.List<S2ShapeIndex.S2ClippedShape[]>encodedCellsThe encoded cells of this index.private S2ShapeIndex.OptionsoptionsThe decoded options of this index.private static S2ShapeUNDECODED_SHAPEInternal representation of an undecoded shape, which must be distinguished from a null shape.-
Fields inherited from class com.google.common.geometry.S2ShapeIndex
CELL_PADDING, CURRENT_ENCODING_VERSION, DEFAULT_CELL_SIZE_TO_LONG_EDGE_RATIO, DEFAULT_MAX_EDGES_PER_CELL, MIN_SHORT_EDGE_FRACTION, shapes
-
-
Constructor Summary
Constructors Constructor Description EncodedS2ShapeIndex(PrimitiveArrays.Bytes data, PrimitiveArrays.Cursor cursor, java.util.List<S2Shape> shapeFactory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(S2Shape shape)Adds the given shape to this index.(package private) voidapplyUpdates()Ensures pending updates have been applied, returning immediately if the index is fresh as reported byS2ShapeIndex.isFresh(), and otherwise blocking while the index is built.booleanisFresh()Returns true if there are no pending updates that need to be applied.S2Iterator<S2ShapeIndex.Cell>iterator()Returns a new iterator over the cells of this index, positioned at the first cell in the index, after initializing any pending updates.S2ShapeIndex.Optionsoptions()Returns the options used for this index.voidremove(S2Shape shape)Currently not implemented.voidreset()Clears the contents of the index and resets it to its original state.-
Methods inherited from class com.google.common.geometry.S2ShapeIndex
createList, getEdgeMaxLevel, getShapes, makeIndexCell
-
-
-
-
Field Detail
-
UNDECODED_SHAPE
private static final S2Shape UNDECODED_SHAPE
Internal representation of an undecoded shape, which must be distinguished from a null shape.
-
options
private final S2ShapeIndex.Options options
The decoded options of this index.
-
cachedShapes
private final S2Shape[] cachedShapes
The array of not-yet-decoded and decoded shapes. The default value isUNDECODED_SHAPE. A value ofnullrepresents a null shape.
-
encodedCellIds
private final S2CellIdVector encodedCellIds
The encoded vector of cell IDs of this index.
-
encodedCells
private final java.util.List<S2ShapeIndex.S2ClippedShape[]> encodedCells
The encoded cells of this index.
-
decodedCells
private final java.util.List<S2ShapeIndex.Cell> decodedCells
The list ofS2ShapeIndex.Cells.
-
clippedShapeArrayCoder
private final S2Coder<S2ShapeIndex.S2ClippedShape[]> clippedShapeArrayCoder
A coder ofS2ClippedShape[]s.
-
-
Constructor Detail
-
EncodedS2ShapeIndex
EncodedS2ShapeIndex(PrimitiveArrays.Bytes data, PrimitiveArrays.Cursor cursor, java.util.List<S2Shape> shapeFactory)
Initializes anS2ShapeIndexCoder.EncodedS2ShapeIndexbacked bydataatoffset.Values are decoded only when they are accessed. This allows for very fast initialization and little additional memory use beyond the encoded data.
-
-
Method Detail
-
options
public S2ShapeIndex.Options options()
Description copied from class:S2ShapeIndexReturns the options used for this index.- Overrides:
optionsin classS2ShapeIndex
-
add
public void add(S2Shape shape)
Description copied from class:S2ShapeIndexAdds the given shape to this index. Invalidates all iterators and their associated data.- Overrides:
addin classS2ShapeIndex
-
remove
public void remove(S2Shape shape)
Description copied from class:S2ShapeIndexCurrently not implemented. Will eventually remove the given shape from the index, and invalidate all iterators and their associated data.- Overrides:
removein classS2ShapeIndex- Parameters:
shape- the shape to remove
-
reset
public void reset()
Description copied from class:S2ShapeIndexClears the contents of the index and resets it to its original state.- Overrides:
resetin classS2ShapeIndex
-
iterator
public S2Iterator<S2ShapeIndex.Cell> iterator()
Description copied from class:S2ShapeIndexReturns a new iterator over the cells of this index, positioned at the first cell in the index, after initializing any pending updates.- Overrides:
iteratorin classS2ShapeIndex
-
isFresh
public boolean isFresh()
Description copied from class:S2ShapeIndexReturns true if there are no pending updates that need to be applied. This can be useful to avoid building the index unnecessarily, or for choosing between two different algorithms depending on whether the index is available.- Overrides:
isFreshin classS2ShapeIndex
-
applyUpdates
void applyUpdates()
Description copied from class:S2ShapeIndexEnsures pending updates have been applied, returning immediately if the index is fresh as reported byS2ShapeIndex.isFresh(), and otherwise blocking while the index is built.This operation is thread safe, guarded by 'this'.
- Overrides:
applyUpdatesin classS2ShapeIndex
-
-