Function S2CellId.rangeMin

These methods return the range of cell ids that are contained within this cell \(including itself\).

S2CellId rangeMin() const;

The range is *inclusive* \(i.e. test using >= and <=\) and the return values of both methods are valid leaf cell ids. In other words, a.contains(b) if and only if

(b >= a.range_min() && b <= a.range_max())

If you want to iterate through all the descendants of this cell at a particular level, use childBegin(level) and childEnd(level) instead. Also see maximumTile(), which can be used to iterate through a range of cells using S2CellIds at different levels that are as large as possible.

If you need to convert the range to a semi-open interval \[min, limit\) \(e.g., in order to use a key-value store that only supports semi-open range queries\), do not attempt to define "limit" as range_max.next(). The problem is that leaf S2CellIds are 2 units apart, so the semi-open interval \[min, limit\) includes an additional value (range_max.id() + 1) which is happens to be a valid S2CellId about one-third of the time and is *never* contained by this cell. \(It always correpsonds to a cell that is larger than this one.\) You can define "limit" as (range_max.id() + 1) if necessary \(which is not always a valid S2CellId but can still be used with FromToken/ToToken\), or you can convert rangeMax() to the key space of your key-value store and define "limit" as successor(key).

Note that Sentinel().rangeMin() == Sentinel.rangeMax() == Sentinel().