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

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

Introduction

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

Prototype

public S2CellId rangeMin() 

Source Link

Usage

From source file:com.grublr.geo.GeoDataManager.java

/**
 * Merge continuous cells in cellUnion and return a list of merged GeohashRanges.
 * /*from  ww w.  ja v  a2  s  .c  o m*/
 * @param cellUnion
 *            Container for multiple cells.
 * 
 * @return A list of merged GeohashRanges.
 */
private List<GeohashRange> mergeCells(S2CellUnion cellUnion) {

    List<GeohashRange> ranges = new ArrayList<GeohashRange>();
    for (S2CellId c : cellUnion.cellIds()) {
        GeohashRange range = new GeohashRange(c.rangeMin().id(), c.rangeMax().id());

        boolean wasMerged = false;
        for (GeohashRange r : ranges) {
            if (r.tryMerge(range)) {
                wasMerged = true;
                break;
            }
        }

        if (!wasMerged) {
            ranges.add(range);
        }
    }

    return ranges;
}