Esempio n. 1
0
        public void Test_S2CellId_Continuity()
        {
            // Make sure that sequentially increasing cell ids form a continuous
            // path over the surface of the sphere, i.e. there are no
            // discontinuous jumps from one region to another.

            double   max_dist = S2.kMaxEdge.GetValue(kMaxWalkLevel);
            S2CellId end      = S2CellId.End(kMaxWalkLevel);
            S2CellId id       = S2CellId.Begin(kMaxWalkLevel);

            for (; id != end; id = id.Next())
            {
                Assert.True(id.ToPointRaw().Angle(id.NextWrap().ToPointRaw()) <= max_dist);
                Assert.Equal(id.NextWrap(), id.AdvanceWrap(1));
                Assert.Equal(id, id.NextWrap().AdvanceWrap(-1));

                // Check that the ToPointRaw() returns the center of each cell
                // in (s,t) coordinates.
                S2.XYZtoFaceUV(id.ToPointRaw(), out var u, out var v);
                Assert2.Near(Math.IEEERemainder(S2.UVtoST(u), 0.5 * kCellSize), 0.0, S2.DoubleError);
                Assert2.Near(Math.IEEERemainder(S2.UVtoST(v), 0.5 * kCellSize), 0.0, S2.DoubleError);
            }
        }