/////////////////////////////////////////////////////////////////////
Returns a deep copy of the region.
Returns a bounding spherical cap that contains the region. The bound may not be tight.
Returns a bounding latitude-longitude rectangle that contains the region. The bound may not be tight.
Returns a small collection of S2CellIds whose union covers the region. The cells are not sorted, may have redundancies (such as cells that contain other cells), and may cover much more area than necessary.
Returns true if the region completely contains the given cell, otherwise returns false.
If this method returns false, the region does not intersect the given cell. Otherwise, either region intersects the cell, or the intersection relationship could not be determined.
Returns true if and only if the given point is contained by the region. The point 'p' is generally required to be unit length, although some subtypes may relax this restriction.
This class wraps an S2ShapeIndex object with the additional methods needed to implement the S2Region API, in order to allow S2RegionCoverer to compute S2CellId coverings of arbitrary collections of geometry.
These methods could conceivably be made part of S2ShapeIndex itself, but there are several advantages to having a separate class:
- The class can be templated in order to avoid virtual calls and memory allocation (for iterators) when the concrete S2ShapeIndex type is known.
- Implementing these methods efficiently requires an S2ShapeIndex iterator, and this design allows a single iterator to be allocated and reused.
- S2Region::Clone() is not a good fit for the S2ShapeIndex API because it can't be implemented for some subtypes (e.g., EncodedS2ShapeIndex).
Example usage:
S2CellUnion GetCovering(const S2ShapeIndex& index) { S2RegionCoverer coverer; coverer.mutable_options()->set_max_cells(20); S2CellUnion covering; coverer.GetCovering(MakeS2ShapeIndexRegion(&index), &covering); return covering; }
This class is not thread-safe. To use it in parallel, each thread should construct its own instance (this is not expensive).