A Region represents a two-dimensional region on the unit sphere. The purpose of this interface is to allow complex regions to be approximated as simpler regions. The interface is restricted to methods that are useful for computing approximations.
| 20 | // approximated as simpler regions. The interface is restricted to methods |
| 21 | // that are useful for computing approximations. |
| 22 | type Region interface { |
| 23 | // CapBound returns a bounding spherical cap. This is not guaranteed to be exact. |
| 24 | CapBound() Cap |
| 25 | |
| 26 | // RectBound returns a bounding latitude-longitude rectangle that contains |
| 27 | // the region. The bounds are not guaranteed to be tight. |
| 28 | RectBound() Rect |
| 29 | |
| 30 | // ContainsCell reports whether the region completely contains the given region. |
| 31 | // It returns false if containment could not be determined. |
| 32 | ContainsCell(c Cell) bool |
| 33 | |
| 34 | // IntersectsCell reports whether the region intersects the given cell or |
| 35 | // if intersection could not be determined. It returns false if the region |
| 36 | // does not intersect. |
| 37 | IntersectsCell(c Cell) bool |
| 38 | |
| 39 | // ContainsPoint reports whether the region contains the given point or not. |
| 40 | // The point should be unit length, although some implementations may relax |
| 41 | // this restriction. |
| 42 | ContainsPoint(p Point) bool |
| 43 | |
| 44 | // CellUnionBound returns a small collection of CellIDs whose union covers |
| 45 | // the region. The cells are not sorted, may have redundancies (such as cells |
| 46 | // that contain other cells), and may cover much more area than necessary. |
| 47 | // |
| 48 | // This method is not intended for direct use by client code. Clients |
| 49 | // should typically use Covering, which has options to control the size and |
| 50 | // accuracy of the covering. Alternatively, if you want a fast covering and |
| 51 | // don't care about accuracy, consider calling FastCovering (which returns a |
| 52 | // cleaned-up version of the covering computed by this method). |
| 53 | // |
| 54 | // CellUnionBound implementations should attempt to return a small |
| 55 | // covering (ideally 4 cells or fewer) that covers the region and can be |
| 56 | // computed quickly. The result is used by RegionCoverer as a starting |
| 57 | // point for further refinement. |
| 58 | CellUnionBound() []CellID |
| 59 | } |
| 60 | |
| 61 | // Enforce Region interface satisfaction. |
| 62 | var ( |