List of usage examples for com.google.common.geometry S2CellId MAX_LEVEL
int MAX_LEVEL
To view the source code for com.google.common.geometry S2CellId MAX_LEVEL.
Click Source Link
From source file:org.geosde.cassandra.GeometryTestCase.java
/** * Return a random cell id at the given level or at a randomly chosen level. * The distribution is uniform over the space of cell ids, but only * approximately uniform over the surface of the sphere. */// w ww. j a v a 2 s. c o m public S2CellId getRandomCellId(int level) { int face = random(S2CellId.NUM_FACES); long pos = rand.nextLong() & ((1L << (2 * S2CellId.MAX_LEVEL)) - 1); return S2CellId.fromFacePosLevel(face, pos, level); }
From source file:org.geosde.cassandra.GeometryTestCase.java
public S2CellId getRandomCellId() { return getRandomCellId(random(S2CellId.MAX_LEVEL + 1)); }
From source file:org.apache.lucene.spatial.prefix.tree.S2PrefixTree.java
/** * Get max levels for this spatial tree. * * @param arity The arity of the tree./*from w w w . ja v a 2s . c o m*/ * @return The maximum number of levels by the provided arity. */ public static int getMaxLevels(int arity) { return S2CellId.MAX_LEVEL / arity + 1; }
From source file:org.apache.lucene.spatial.prefix.tree.S2PrefixTreeCell.java
/** * Get the {@link S2CellId} from the {@link BytesRef} representation. * * @param ref The bytes.//from ww w .j av a2 s .c om * @return the corresponding S2 cell. */ private S2CellId getS2CellIdFromBytesRef(BytesRef ref) { int length = ref.length; if (isLeaf(ref)) { length--; } if (length == 0) { return null; //world cell } int face = PIXELS.get(ref.bytes[ref.offset]); S2CellId cellId = FACES[face]; long id = cellId.id(); for (int i = ref.offset + 1; i < ref.offset + length; i++) { int thisLevel = i - ref.offset; int pos = PIXELS.get(ref.bytes[i]); // first child at level id = id - (id & -id) + (1L << (2 * (S2CellId.MAX_LEVEL - thisLevel * tree.arity))); // next until pos id = id + pos * ((id & -id) << 1); } return new S2CellId(id); }