s2js
    Preparing search index...

    Class Cell

    Cell is an S2 region object that represents a cell. Unlike CellIDs, it supports efficient containment and intersection tests. However, it is also a more expensive representation.

    Implements

    Index

    Constructors

    • Returns a new Cell.

      Parameters

      • face: number
      • level: number
      • orientation: number
      • id: bigint
      • uv: r2.Rect

      Returns Cell

    Other

    face: number
    id: bigint
    level: number
    orientation: number
    uv: r2.Rect
    • Returns the approximate area of this cell. This method is accurate to within 3% percent for all cell sizes and accurate to within 0.1% for cells at level 5 or higher (i.e. squares 350km to a side or smaller on the Earth's surface). It is moderately cheap to compute.

      Returns number

    • Returns the average area of cells at the level of this cell. This is accurate to within a factor of 1.7.

      Returns number

    • Returns the direction vector corresponding to the center in (s,t)-space of the given cell. This is the point at which the cell is divided into four subcells; it is not necessarily the centroid of the cell in (u,v)-space or (x,y,z)-space

      Returns s2.Point

    • Returns the four direct children of this cell in traversal order and returns true. If this is a leaf cell, or the children could not be created, false is returned. The C++ method is called Subdivide.

      Returns Cell[]

    • Reports whether this cell contains the given point. Note that unlike Loop/Polygon, a Cell is considered to be a closed set. This means that a point on a Cell's edge or vertex belongs to the Cell and the relevant adjacent Cells too.

      If you want every point to be contained by exactly one Cell, you will need to convert the Cell to a Loop.

      Parameters

      Returns boolean

    • Reports the distance from the cell to the given point. Returns zero if the point is inside the cell.

      Parameters

      Returns number

    • Reports the distance from the given point to the interior of the cell if toInterior is true or to the boundary of the cell otherwise.

      Parameters

      • targetXYZ: s2.Point
      • toInterior: boolean

      Returns number

    • Returns the minimum distance from this cell to the given cell. It returns zero if one cell contains the other.

      Parameters

      Returns number

    • Returns the inward-facing normal of the great circle passing through the CCW ordered edge from vertex k to vertex k+1 (mod 4) (for k = 0,1,2,3).

      Parameters

      • k: number

      Returns s2.Point

    • Returns the latitude of the cell vertex in radians given by (i,j), where i and j indicate the Hi (1) or Lo (0) corner.

      Parameters

      • i: number
      • j: number

      Returns number

    • Returns the longitude of the cell vertex in radians given by (i,j), where i and j indicate the Hi (1) or Lo (0) corner.

      Parameters

      • i: number
      • j: number

      Returns number

    • Returns the maximum distance from the cell (including its interior) to the given target cell.

      Parameters

      Returns number

    • Reports whether a point P is closer to the interior of the specified Cell edge (either the lower or upper edge of the Cell) or to the endpoints.

      Parameters

      Returns boolean

    • Reports whether a point P is closer to the interior of the specified Cell edge (either the right or left edge of the Cell) or to the endpoints.

      Parameters

      Returns boolean

    • Returns the k-th vertex of the cell (k = 0,1,2,3) in CCW order (lower left, lower right, upper right, upper left in the UV plane).

      Parameters

      • k: number

      Returns s2.Point

    • Returns the squared chord distance from point P to the given corner vertex specified by the Hi or Lo values of each.

      Parameters

      • p: s2.Point
      • xHi: boolean
      • yHi: boolean

      Returns number

    • Reports the distance from a Point P to a given Cell edge. The point P is given by its dot product, and the uv edge by its normal in the given coordinate value.

      Parameters

      • ij: number
      • uv: number

      Returns number

    • Returns the face opposite the given face.

      Parameters

      • face: number

      Returns number