List of usage examples for com.google.common.geometry S2CellId childPosition
public int childPosition(int level)
From source file:org.apache.lucene.spatial.prefix.tree.S2PrefixTreeCell.java
/** * Codify a {@link S2CellId} into its {@link BytesRef} representation. * * @param cellId The S2 Cell id to codify. * @param bref The byteref representation. */// ww w.j a va 2 s.com private void getBytesRefFromS2CellId(S2CellId cellId, BytesRef bref) { if (cellId == null) {//world cell bref.length = 0; return; } int length = getLevel() + 1; byte[] b = bref.bytes.length >= length ? bref.bytes : new byte[length]; b[0] = TOKENS[cellId.face()]; for (int i = 1; i < getLevel(); i++) { int offset = 0; int level = tree.arity * i; for (int j = 1; j < tree.arity; j++) { offset = 4 * offset + cellId.childPosition(level - tree.arity + j); } b[i] = TOKENS[4 * offset + cellId.childPosition(level)]; } bref.bytes = b; bref.length = getLevel(); bref.offset = 0; }