Class S2ShapeIndex
java.lang.Object
com.google.common.geometry.S2ShapeIndex
- All Implemented Interfaces:
Serializable
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classThis class contains the set of clipped shapes within a particular index cell, sorted in increasing order of shape id.static enumThe possible relationships between a "target" cell and the cells of the S2ShapeIndex.static classOptions that affect construction of the S2ShapeIndex.static final classRangeIterator is a wrapper over CellIterator that is specialized for merging shape indices.static classS2ClippedShape represents the part of a shape that intersects an S2Cell. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final doubleThe amount in UV coordinates by which cells are "padded" to compensate for numerical errors when clipping line segments to cell boundaries.static final intThe current encoding version.static final doubleDefault maximum cell size, relative to an edge's length, for which that edge is considered 'long'.static final intDefault maximum number of edges per cell (not counting 'long' edges).Shapes currently in the index. -
Constructor Summary
ConstructorsConstructorDescriptionCreates an S2ShapeIndex that uses the default options,S2ShapeIndex.Options.S2ShapeIndex(S2ShapeIndex.Options options) Creates an S2ShapeIndex with the given options. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds the given shape to this index.Returns an immutable list view of shapes in the index.booleanisFresh()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.voidCurrently not implemented.voidreset()Clears the contents of the index and resets it to its original state.
-
Field Details
-
CELL_PADDING
public static final double CELL_PADDINGThe amount in UV coordinates by which cells are "padded" to compensate for numerical errors when clipping line segments to cell boundaries. The total error when clipping an edge comes from two sources:- Clipping the original spherical edge to a cube face (the "face edge"). The maximum error
in this step is
S2EdgeUtil.FACE_CLIP_ERROR_UV_COORD. - Clipping the face edge to the u- or v-coordinate of a cell boundary. The maximum error in
this step is
S2EdgeUtil.EDGE_CLIP_ERROR_UV_COORD.
Finally, since we encounter the same errors when clipping query edges, we double the total error so that we only need to pad edges during indexing and not at query time.
- Clipping the original spherical edge to a cube face (the "face edge"). The maximum error
in this step is
-
DEFAULT_MAX_EDGES_PER_CELL
public static final int DEFAULT_MAX_EDGES_PER_CELLDefault maximum number of edges per cell (not counting 'long' edges). Reasonable values range from 10 to 50. Small values makes queries faster, while large values make construction faster and use less memory.- See Also:
-
DEFAULT_CELL_SIZE_TO_LONG_EDGE_RATIO
public static final double DEFAULT_CELL_SIZE_TO_LONG_EDGE_RATIODefault maximum cell size, relative to an edge's length, for which that edge is considered 'long'. Long edges are not counted towardsS2ShapeIndex.Options.maxEdgesPerCell. The size and speed of the index are typically not very sensitive to this parameter. Reasonable values range from 0.1 to 10, with smaller values causing more aggressive subdivision of long edges grouped closely together.- See Also:
-
CURRENT_ENCODING_VERSION
public static final int CURRENT_ENCODING_VERSIONThe current encoding version. When adding a new encoding, be aware that old binaries will not be able to decode it.- See Also:
-
shapes
-
-
Constructor Details
-
S2ShapeIndex
public S2ShapeIndex()Creates an S2ShapeIndex that uses the default options,S2ShapeIndex.Options. -
S2ShapeIndex
Creates an S2ShapeIndex with the given options.
-
-
Method Details
-
options
Returns the options used for this index. -
getShapes
-
add
Adds the given shape to this index. Invalidates all iterators and their associated data. -
remove
Currently not implemented. Will eventually remove the given shape from the index, and invalidate all iterators and their associated data.- Parameters:
shape- the shape to remove
-
reset
public void reset()Clears the contents of the index and resets it to its original state. -
iterator
Returns a new iterator over the cells of this index, positioned at the first cell in the index, after initializing any pending updates. -
isFresh
public boolean isFresh()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.
-