Example usage for com.google.common.geometry S2CellUnion initFromCellIds

List of usage examples for com.google.common.geometry S2CellUnion initFromCellIds

Introduction

In this page you can find the example usage for com.google.common.geometry S2CellUnion initFromCellIds.

Prototype

public void initFromCellIds(ArrayList<S2CellId> cellIds) 

Source Link

Usage

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

public static S2CellUnion findCellIds(S2LatLngRect latLngRect) {

    ConcurrentLinkedQueue<S2CellId> queue = new ConcurrentLinkedQueue<S2CellId>();
    ArrayList<S2CellId> cellIds = new ArrayList<S2CellId>();

    for (S2CellId c = S2CellId.begin(0); !c.equals(S2CellId.end(0)); c = c.next()) {
        if (containsGeodataToFind(c, latLngRect)) {
            queue.add(c);//  www  .  j  av a 2  s.c  om
        }
    }

    processQueue(queue, cellIds, latLngRect);
    assert queue.size() == 0;
    queue = null;

    if (cellIds.size() > 0) {
        S2CellUnion cellUnion = new S2CellUnion();
        cellUnion.initFromCellIds(cellIds); // This normalize the cells.
        // cellUnion.initRawCellIds(cellIds); // This does not normalize the cells.
        cellIds = null;

        return cellUnion;
    }

    return null;
}