Exemple #1
0
    private readonly int orientation_;  // Hilbert curve orientation of this cell (see s2coords.h)

    #region Constructors

    // Construct an S2PaddedCell for the given cell id and padding.
    public S2PaddedCell(S2CellId id, double padding)
    {
        ij_lo_  = new int[2];
        Id      = id;
        Padding = padding;
        if (Id.IsFace())
        {
            // Fast path for constructing a top-level face (the most common case).
            double limit = 1 + padding;
            Bound = new R2Rect(new R1Interval(-limit, limit),
                               new R1Interval(-limit, limit));
            middle_ = new R2Rect(new R1Interval(-padding, padding),
                                 new R1Interval(-padding, padding));
            ij_lo_[0]    = ij_lo_[1] = 0;
            orientation_ = (int)(Id.Face() & 1);
            Level        = 0;
        }
        else
        {
            var ij = new int[2];
            id.ToFaceIJOrientation(out ij[0], out ij[1], out orientation_, true);
            Level = id.Level();
            Bound = S2CellId.IJLevelToBoundUV(ij, Level).Expanded(padding);
            int ij_size = S2CellId.SizeIJ(Level);
            ij_lo_[0] = ij[0] & -ij_size;
            ij_lo_[1] = ij[1] & -ij_size;
        }
    }
Exemple #2
0
    private static S2Shape NewPaddedCell(S2CellId id, double padding_uv)
    {
        var ij       = new int[2];
        var face     = id.ToFaceIJOrientation(out ij[0], out ij[1], out _, false);
        var uv       = S2CellId.IJLevelToBoundUV(ij, id.Level()).Expanded(padding_uv);
        var vertices = new S2Point[4];

        for (int i = 0; i < 4; ++i)
        {
            vertices[i] = S2.FaceUVtoXYZ(face, uv.GetVertex(i)).Normalize();
        }
        return(new S2LaxLoopShape(vertices));
    }