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

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

Introduction

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

Prototype

public boolean isLeaf() 

Source Link

Document

Return true if this is a leaf cell (more efficient than checking whether level() == MAX_LEVEL).

Usage

From source file:com.amazonaws.geo.s2.internal.S2Manager.java

private static void processChildren(S2CellId parent, S2LatLngRect latLngRect,
        ConcurrentLinkedQueue<S2CellId> queue, ArrayList<S2CellId> cellIds) {
    List<S2CellId> children = new ArrayList<S2CellId>(4);

    for (S2CellId c = parent.childBegin(); !c.equals(parent.childEnd()); c = c.next()) {
        if (containsGeodataToFind(c, latLngRect)) {
            children.add(c);/*from www .j  a  v  a  2  s.  c om*/
        }
    }

    /*
     * TODO: Need to update the strategy!
     * 
     * Current strategy:
     * 1 or 2 cells contain cellIdToFind: Traverse the children of the cell.
     * 3 cells contain cellIdToFind: Add 3 cells for result.
     * 4 cells contain cellIdToFind: Add the parent for result.
     * 
     * ** All non-leaf cells contain 4 child cells.
     */
    if (children.size() == 1 || children.size() == 2) {
        for (S2CellId child : children) {
            if (child.isLeaf()) {
                cellIds.add(child);
            } else {
                queue.add(child);
            }
        }
    } else if (children.size() == 3) {
        cellIds.addAll(children);
    } else if (children.size() == 4) {
        cellIds.add(parent);
    } else {
        assert false; // This should not happen.
    }
}