S2ShapeIndexRegion

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).

Constructors

this
this(IndexT index)
Undocumented in source.

Members

Functions

clone
S2ShapeIndexRegion!IndexT clone()

/////////////////////////////////////////////////////////////////////

contains
bool contains(S2Point p)
Undocumented in source. Be warned that the author may not have intended to support it.
contains
bool contains(S2Cell target)
Undocumented in source. Be warned that the author may not have intended to support it.
getCapBound
S2Cap getCapBound()
Undocumented in source. Be warned that the author may not have intended to support it.
getCellUnionBound
void getCellUnionBound(S2CellId[] cell_ids)
Undocumented in source. Be warned that the author may not have intended to support it.
getRectBound
S2LatLngRect getRectBound()
Undocumented in source. Be warned that the author may not have intended to support it.
index
inout(IndexT) index()
Undocumented in source. Be warned that the author may not have intended to support it.
mayIntersect
bool mayIntersect(S2Cell target)
Undocumented in source. Be warned that the author may not have intended to support it.

Inherited Members

From S2Region

clone
S2Region clone()

Returns a deep copy of the region.

getCapBound
S2Cap getCapBound()

Returns a bounding spherical cap that contains the region. The bound may not be tight.

getRectBound
S2LatLngRect getRectBound()

Returns a bounding latitude-longitude rectangle that contains the region. The bound may not be tight.

getCellUnionBound
void getCellUnionBound(S2CellId[] cellIds)

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.

contains
bool contains(S2Cell cell)

Returns true if the region completely contains the given cell, otherwise returns false.

mayIntersect
bool mayIntersect(S2Cell cell)

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.

contains
bool contains(S2Point p)

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.

Meta