Package com.google.common.geometry
Class S2ShapeIndexCoder
- java.lang.Object
-
- com.google.common.geometry.S2ShapeIndexCoder
-
- All Implemented Interfaces:
S2Coder<S2ShapeIndex>
@GwtIncompatible("S2LaxPolylineShape and S2LaxPolygonShape") public class S2ShapeIndexCoder extends Object implements S2Coder<S2ShapeIndex>An encoder/decoder ofS2ShapeIndexs.Values from the
S2ShapeIndexreturned bydecode(Bytes, Cursor)are decoded only when they are accessed. This allows for very fast initialization and no additional memory use beyond the encoded data, and a cache of the clipped shapes that have been accessed. When accessing the entire index, this uses slightly more memory thanS2ShapeIndex, but uses dramatically less memory when accessing only a few cells of the index.
-
-
Field Summary
Fields Modifier and Type Field Description static S2ShapeIndexCoderINSTANCEAn instance of aS2ShapeIndexCoderwhich can encode anS2ShapeIndexbut will throw anIllegalArgumentExceptionif used to decode anS2ShapeIndex.
-
Constructor Summary
Constructors Constructor Description S2ShapeIndexCoder(List<S2Shape> shapes)Constructs aS2ShapeIndexCoder.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description S2ShapeIndexdecode(PrimitiveArrays.Bytes data, PrimitiveArrays.Cursor cursor)voidencode(S2ShapeIndex value, OutputStream output)Encodesvaluetooutput.
-
-
-
Field Detail
-
INSTANCE
public static final S2ShapeIndexCoder INSTANCE
An instance of aS2ShapeIndexCoderwhich can encode anS2ShapeIndexbut will throw anIllegalArgumentExceptionif used to decode anS2ShapeIndex.
-
-
Constructor Detail
-
S2ShapeIndexCoder
public S2ShapeIndexCoder(@Nullable List<S2Shape> shapes)
Constructs aS2ShapeIndexCoder.- Parameters:
shapes- the list of shapes, used only bydecode(com.google.common.geometry.PrimitiveArrays.Bytes, com.google.common.geometry.PrimitiveArrays.Cursor), commonly the result of {@link VectorCoder#FAST_SHAPE#decode(Bytes, Cursor)}.
-
-
Method Detail
-
encode
public void encode(S2ShapeIndex value, OutputStream output) throws IOException
Description copied from interface:S2CoderEncodesvaluetooutput.- Specified by:
encodein interfaceS2Coder<S2ShapeIndex>- Throws:
IOException
-
decode
public S2ShapeIndex decode(PrimitiveArrays.Bytes data, PrimitiveArrays.Cursor cursor)
Description copied from interface:S2CoderDecodes a value of typeS2Coderfromdatastarting atcursor.position.cursor.positionis updated to the position of the first byte indatafollowing the encoded value.- Specified by:
decodein interfaceS2Coder<S2ShapeIndex>
-
-