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

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

Introduction

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

Prototype

public S2CellId rangeMax() 

Source Link

Usage

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

/**
 * Merge continuous cells in cellUnion and return a list of merged GeohashRanges.
 * /*ww  w. j  a  va2s.  c om*/
 * @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;
}