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 class
S2ShapeIndexCoder.EncodedS2ShapeIndex.LazyCell
A lazy implementation ofS2ShapeIndex.Cell
which 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[]
cachedShapes
The array of not-yet-decoded and decoded shapes.private S2Coder<S2ShapeIndex.S2ClippedShape[]>
clippedShapeArrayCoder
A coder ofS2ClippedShape[]
s.private java.util.List<S2ShapeIndex.Cell>
decodedCells
The list ofS2ShapeIndex.Cell
s.private S2CellIdVector
encodedCellIds
The encoded vector of cell IDs of this index.private java.util.List<S2ShapeIndex.S2ClippedShape[]>
encodedCells
The encoded cells of this index.private S2ShapeIndex.Options
options
The decoded options of this index.private static S2Shape
UNDECODED_SHAPE
Internal 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 void
add(S2Shape shape)
Adds the given shape to this index.(package private) void
applyUpdates()
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.boolean
isFresh()
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.Options
options()
Returns the options used for this index.void
remove(S2Shape shape)
Currently not implemented.void
reset()
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 ofnull
represents 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.Cell
s.
-
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.EncodedS2ShapeIndex
backed bydata
atoffset
.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:S2ShapeIndex
Returns the options used for this index.- Overrides:
options
in classS2ShapeIndex
-
add
public void add(S2Shape shape)
Description copied from class:S2ShapeIndex
Adds the given shape to this index. Invalidates all iterators and their associated data.- Overrides:
add
in classS2ShapeIndex
-
remove
public void remove(S2Shape shape)
Description copied from class:S2ShapeIndex
Currently not implemented. Will eventually remove the given shape from the index, and invalidate all iterators and their associated data.- Overrides:
remove
in classS2ShapeIndex
- Parameters:
shape
- the shape to remove
-
reset
public void reset()
Description copied from class:S2ShapeIndex
Clears the contents of the index and resets it to its original state.- Overrides:
reset
in classS2ShapeIndex
-
iterator
public S2Iterator<S2ShapeIndex.Cell> iterator()
Description copied from class:S2ShapeIndex
Returns a new iterator over the cells of this index, positioned at the first cell in the index, after initializing any pending updates.- Overrides:
iterator
in classS2ShapeIndex
-
isFresh
public boolean isFresh()
Description copied from class:S2ShapeIndex
Returns 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:
isFresh
in classS2ShapeIndex
-
applyUpdates
void applyUpdates()
Description copied from class:S2ShapeIndex
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.This operation is thread safe, guarded by 'this'.
- Overrides:
applyUpdates
in classS2ShapeIndex
-
-