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:
Serializable
- Enclosing class:
S2ShapeIndexCoder
Represents an encoded
S2ShapeIndex
.
This class is thread-safe.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate final class
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
FieldsModifier and TypeFieldDescriptionprivate final S2Shape[]
The array of not-yet-decoded and decoded shapes.private final S2Coder
<S2ShapeIndex.S2ClippedShape[]> A coder ofS2ClippedShape[]
s.private final List
<S2ShapeIndex.Cell> The list ofS2ShapeIndex.Cell
s.private final S2CellIdVector
The encoded vector of cell IDs of this index.private final List
<S2ShapeIndex.S2ClippedShape[]> The encoded cells of this index.private final S2ShapeIndex.Options
The decoded options of this index.private static final S2Shape
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
ConstructorsConstructorDescriptionEncodedS2ShapeIndex
(PrimitiveArrays.Bytes data, PrimitiveArrays.Cursor cursor, List<S2Shape> shapeFactory) -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds the given shape to this index.(package private) void
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.iterator()
Returns a new iterator over the cells of this index, positioned at the first cell in the index, after initializing any pending updates.options()
Returns the options used for this index.void
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 Details
-
UNDECODED_SHAPE
Internal representation of an undecoded shape, which must be distinguished from a null shape. -
options
The decoded options of this index. -
cachedShapes
The array of not-yet-decoded and decoded shapes. The default value isUNDECODED_SHAPE
. A value ofnull
represents a null shape. -
encodedCellIds
The encoded vector of cell IDs of this index. -
encodedCells
The encoded cells of this index. -
decodedCells
The list ofS2ShapeIndex.Cell
s. -
clippedShapeArrayCoder
A coder ofS2ClippedShape[]
s.
-
-
Constructor Details
-
EncodedS2ShapeIndex
EncodedS2ShapeIndex(PrimitiveArrays.Bytes data, PrimitiveArrays.Cursor cursor, 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 Details
-
options
Description copied from class:S2ShapeIndex
Returns the options used for this index.- Overrides:
options
in classS2ShapeIndex
-
add
Description copied from class:S2ShapeIndex
Adds the given shape to this index. Invalidates all iterators and their associated data.- Overrides:
add
in classS2ShapeIndex
-
remove
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
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
-