Class S2EdgeUtil.RectBounder

  • Enclosing class:
    S2EdgeUtil

    public static class S2EdgeUtil.RectBounder
    extends Object
    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. For example, this class guarantees that if L is a closed edge chain (a loop) such that the interior of the loop does not contain either pole, and P is any point such that L contains P, then the RectBounder of all edges in L will contain S2LatLng(P).

    • Constructor Detail

      • RectBounder

        public RectBounder()
    • Method Detail

      • addPoint

        public void addPoint​(S2LatLng b)
        This method is called to add each vertex to the chain. This method is much faster than addPoint(S2Point), since converting S2LatLng to an S2Point is much faster than the other way around..
      • addPoint

        public void addPoint​(S2Point b)
        This method is called to add each vertex to the chain. Prefer calling addPoint(S2LatLng) if you have that type available. The point must be unit length.
      • getBound

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