Class S2ShapeIndex.S2ClippedShape

  • All Implemented Interfaces:
    S2Iterator.Entry, java.io.Serializable
    Direct Known Subclasses:
    S2ShapeIndex.S2ClippedShape.Contained, S2ShapeIndex.S2ClippedShape.EdgeRange, S2ShapeIndex.S2ClippedShape.ManyEdges, S2ShapeIndex.S2ClippedShape.OneEdge
    Enclosing class:
    S2ShapeIndex

    public abstract static class S2ShapeIndex.S2ClippedShape
    extends S2ShapeIndex.Cell
    S2ClippedShape represents the part of a shape that intersects an S2Cell. It consists of the set of edge ids that intersect that cell, and a boolean indicating whether the center of the cell is inside the shape (for shapes that have an interior). Edges themselves are not clipped; we always use the original edges for intersection tests so that the results will be the same as the original shape.

    Most of the index memory is consumed here, so we have several strategies to be as efficient as possible:

    • Since only the first clipped shape in a cell needs to store the cell ID, we have subclasses for both cases based on whether a cell ID was provided.
    • Since no edges, one edge, and one dense range of edges are very common cases, we have more efficient subclasses for those situations, in addition to the general purpose implementation.
    See Also:
    Serialized Form
    • Field Detail

      • shape

        private final S2Shape shape
        If positive, this is the shape ID and the shape does not contain the center of the cell. Otherwise the shape ID is ~this.shapeId and the shape does contains the center of the cell. This is done to save memory, since this single bit of information can otherwise be padded out up to 4 or 8 additional bytes, depending on the fields in the subclass.
    • Constructor Detail

      • S2ClippedShape

        private S2ClippedShape​(S2Shape shape)