Пример #1
0
        public void cwOffsetPent()
        {
            // Try to find a case where h3NeighborRotations would not pass the
            // cwOffsetPent check, and would hit a line marked as unreachable.

            // To do this, we need to find a case that would move from one
            // non-pentagon base cell into the deleted k-subsequence of a pentagon
            // base cell, and neither of the cwOffsetPent values are the original
            // base cell's face.

            for (int pentagon = 0; pentagon < Constants.NUM_BASE_CELLS; pentagon++)
            {
                if (!BaseCells._isBaseCellPentagon(pentagon))
                {
                    continue;
                }

                for (int neighbor = 0; neighbor < Constants.NUM_BASE_CELLS; neighbor++)
                {
                    FaceIJK homeFaceIjk = new FaceIJK();
                    BaseCells._baseCellToFaceIjk(neighbor, ref homeFaceIjk);
                    int neighborFace = homeFaceIjk.face;

                    // Only direction 2 needs to be checked, because that is the
                    // only direction where we can move from digit 2 to digit 1, and
                    // into the deleted k subsequence.
                    Assert.True(
                        BaseCells._getBaseCellNeighbor(neighbor, Direction.J_AXES_DIGIT) != pentagon ||
                        BaseCells._baseCellIsCwOffset(pentagon, neighborFace),
                        "cwOffsetPent is reachable");
                }
            }
        }
Пример #2
0
        public void faceIjkToH3ExtremeCoordinates()
        {
            //FaceIJK fijk0I = { 0, { 3, 0, 0 } };
            //t_assert(_faceIjkToH3(&fijk0I, 0) == 0, "i out of bounds at res 0");
            var fijk0I = new FaceIJK(0, new CoordIJK(3, 0, 0));

            Assert.IsTrue(0 == (ulong)fijk0I.ToH3Index(0), "i out of bounds at res 0");

            //FaceIJK fijk0J = { 1, { 0, 4, 0 } };
            //t_assert(_faceIjkToH3(&fijk0J, 0) == 0, "j out of bounds at res 0");
            var fijk0J = new FaceIJK(1, new CoordIJK(0, 4, 0));

            Assert.IsTrue(0 == fijk0J.ToH3Index(0), "i out of bounds at res 0");

            //FaceIJK fijk0K = { 2, { 2, 0, 5 } };
            //t_assert(_faceIjkToH3(&fijk0K, 0) == 0, "k out of bounds at res 0");
            var fijk0K = new FaceIJK(2, new CoordIJK(2, 0, 5));

            Assert.IsTrue(0 == fijk0K.ToH3Index(0), "i out of bounds at res 0");


            //FaceIJK fijk1I = { 3, { 6, 0, 0 } };
            //t_assert(_faceIjkToH3(&fijk1I, 1) == 0, "i out of bounds at res 1");
            var fijk1I = new FaceIJK(3, new CoordIJK(6, 0, 0));

            Assert.IsTrue(0 == fijk1I.ToH3Index(1), "i out of bounds at res 0");

            //FaceIJK fijk1J = { 4, { 0, 7, 1 } };
            //t_assert(_faceIjkToH3(&fijk1J, 1) == 0, "j out of bounds at res 1");
            var fijk1J = new FaceIJK(4, new CoordIJK(0, 7, 1));

            Assert.IsTrue(0 == fijk1J.ToH3Index(1), "i out of bounds at res 0");

            //FaceIJK fijk1K = { 5, { 2, 0, 8 } };
            //t_assert(_faceIjkToH3(&fijk1K, 1) == 0, "k out of bounds at res 1");
            var fijk1K = new FaceIJK(5, new CoordIJK(2, 0, 8));

            Assert.IsTrue(0 == fijk1K.ToH3Index(1), "i out of bounds at res 0");


            //FaceIJK fijk2I = { 6, { 18, 0, 0 } };
            //t_assert(_faceIjkToH3(&fijk2I, 2) == 0, "i out of bounds at res 2");
            var fijk2I = new FaceIJK(6, new CoordIJK(18, 0, 0));

            Assert.IsTrue(0 == fijk2I.ToH3Index(2), "i out of bounds at res 0");

            //FaceIJK fijk2J = { 7, { 0, 19, 1 } };
            //t_assert(_faceIjkToH3(&fijk2J, 2) == 0, "j out of bounds at res 2");
            var fijk2J = new FaceIJK(7, new CoordIJK(0, 19, 1));

            Assert.IsTrue(0 == fijk2J.ToH3Index(2), "i out of bounds at res 0");

            //FaceIJK fijk2K = { 8, { 2, 0, 20 } };
            //t_assert(_faceIjkToH3(&fijk2K, 2) == 0, "k out of bounds at res 2");
            var fijk2K = new FaceIJK(8, new CoordIJK(2, 0, 20));

            Assert.IsTrue(0 == fijk2K.ToH3Index(2), "i out of bounds at res 0");
        }
Пример #3
0
        public void faceIjkToH3ExtremeCoordinates()
        {
            FaceIJK fijk0I = new FaceIJK {
                face = 0, coord = new CoordIJK(3, 0, 0)
            };

            Assert.True(H3Index._faceIjkToH3(ref fijk0I, 0) == 0, "i out of bounds at res 0");
            FaceIJK fijk0J = new FaceIJK {
                face = 1, coord = new CoordIJK(0, 4, 0)
            };

            Assert.True(H3Index._faceIjkToH3(ref fijk0J, 0) == 0, "j out of bounds at res 0");
            FaceIJK fijk0K = new FaceIJK {
                face = 2, coord = new CoordIJK(2, 0, 5)
            };

            Assert.True(H3Index._faceIjkToH3(ref fijk0K, 0) == 0, "k out of bounds at res 0");

            FaceIJK fijk1I = new FaceIJK {
                face = 3, coord = new CoordIJK(6, 0, 0)
            };

            Assert.True(H3Index._faceIjkToH3(ref fijk1I, 1) == 0, "i out of bounds at res 1");
            FaceIJK fijk1J = new FaceIJK {
                face = 4, coord = new CoordIJK(0, 7, 1)
            };

            Assert.True(H3Index._faceIjkToH3(ref fijk1J, 1) == 0, "j out of bounds at res 1");
            FaceIJK fijk1K = new FaceIJK {
                face = 5, coord = new CoordIJK(2, 0, 8)
            };

            Assert.True(H3Index._faceIjkToH3(ref fijk1K, 1) == 0, "k out of bounds at res 1");

            FaceIJK fijk2I = new FaceIJK {
                face = 6, coord = new CoordIJK(18, 0, 0)
            };

            Assert.True(H3Index._faceIjkToH3(ref fijk2I, 2) == 0, "i out of bounds at res 2");
            FaceIJK fijk2J = new FaceIJK {
                face = 7, coord = new CoordIJK(0, 19, 1)
            };

            Assert.True(H3Index._faceIjkToH3(ref fijk2J, 2) == 0, "j out of bounds at res 2");
            FaceIJK fijk2K = new FaceIJK {
                face = 8, coord = new CoordIJK(2, 0, 20)
            };

            Assert.True(H3Index._faceIjkToH3(ref fijk2K, 2) == 0, "k out of bounds at res 2");
        }