Example usage for com.google.common.geometry S2CellId face

List of usage examples for com.google.common.geometry S2CellId face

Introduction

In this page you can find the example usage for com.google.common.geometry S2CellId face.

Prototype

public int face() 

Source Link

Document

Which cube face this cell belongs to, in the range 0..5.

Usage

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.
 */// w ww.  j  av a  2 s.  c o  m
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;
}