示例#1
0
    public function __toString()
    {
        return sprintf("(face=%d, pos=%16x, level=%d)", $this->face(), $this->pos(), $this->level());
    }
    public static function initLookupCell($level, $i, $j, $origOrientation, $pos, $orientation)
    {
        if ($level == self::LOOKUP_BITS) {
            $ij = ($i << self::LOOKUP_BITS) + $j;
            self::$LOOKUP_POS[($ij << 2) + $origOrientation] = ($pos << 2) + $orientation;
            self::$LOOKUP_IJ[($pos << 2) + $origOrientation] = ($ij << 2) + $orientation;
        } else {
            $level++;
            $i <<= 1;
            $j <<= 1;
            $pos <<= 2;
            // Initialize each sub-cell recursively.
            for ($subPos = 0; $subPos < 4; $subPos++) {
                $ij = S2::posToIJ($orientation, $subPos);
                $orientationMask = S2::posToOrientation($subPos);
                self::initLookupCell($level, $i + ($ij >> 1 & PHP_INT_MAX >> 0), $j + ($ij & 1), $origOrientation, $pos + $subPos, $orientation ^ $orientationMask);
                /* >>> */
            }
        }
    }
}
S2CellId::$LOOKUP_POS = array_pad(array(), 1 << 2 * S2CellId::LOOKUP_BITS + 2, 0);
S2CellId::$LOOKUP_IJ = array_pad(array(), 1 << 2 * S2CellId::LOOKUP_BITS + 2, 0);
S2CellId::initLookupCell(0, 0, 0, 0, 0, 0);
S2CellId::initLookupCell(0, 0, 0, S2CellId::SWAP_MASK, 0, S2CellId::SWAP_MASK);
S2CellId::initLookupCell(0, 0, 0, S2CellId::INVERT_MASK, 0, S2CellId::INVERT_MASK);
S2CellId::initLookupCell(0, 0, 0, S2CellId::SWAP_MASK | S2CellId::INVERT_MASK, 0, S2CellId::SWAP_MASK | S2CellId::INVERT_MASK);