S2LatLngRectBounder

This class computes a bounding rectangle that contains all edges defined by a vertex chain v0, v1, v2, ... All vertices must be unit length. Note that the bounding rectangle of an edge can be larger than the bounding rectangle of its endpoints, e.g. consider an edge that passes through the north pole.

The bounds are calculated conservatively to account for numerical errors when S2Points are converted to S2LatLngs. More precisely, this class guarantees the following. Let L be a closed edge chain (loop) such that the interior of the loop does not contain either pole. Now if P is any point such that L.Contains(P), then RectBound(L).Contains(S2LatLng(P)).

Constructors

this
this()
Undocumented in source.

Members

Functions

addLatLng
void addLatLng(S2LatLng b_latlng)

This method is called to add a vertex to the chain when the vertex is represented as an S2LatLng. Repeated vertices are ignored.

addPoint
void addPoint(S2Point b)

This method is called to add a vertex to the chain when the vertex is represented as an S2Point. Requires that 'b' has unit length. Repeated vertices are ignored.

getBound
S2LatLngRect getBound()

Returns the bounding rectangle of the edge chain that connects the vertices defined so far. This bound satisfies the guarantee made above, i.e. if the edge chain defines a loop, then the bound contains the S2LatLng coordinates of all S2Points contained by the loop.

Static functions

expandForSubregions
S2LatLngRect expandForSubregions(S2LatLngRect bound)

Expands a bound returned by GetBound() so that it is guaranteed to contain the bounds of any subregion whose bounds are computed using this class. For example, consider a loop L that defines a square. GetBound() ensures that if a point P is contained by this square, then S2LatLng(P) is contained by the bound. But now consider a diamond shaped loop S contained by L. It is possible that GetBound() returns a *larger* bound for S than it does for L, due to rounding errors. This method expands the bound for L so that it is guaranteed to contain the bounds of any subregion S.

maxErrorForTests
S2LatLng maxErrorForTests()
Undocumented in source. Be warned that the author may not have intended to support it.

Meta