Esempio n. 1
0
        public void getH3UnidirectionalEdgesFromHexagon()
        {
            H3Index sf    = H3Index.geoToH3(ref sfGeo, 9);
            var     edges = new ulong[6].Select(cell => new H3Index(cell)).ToList();

            H3UniEdge.getH3UnidirectionalEdgesFromHexagon(sf, edges);

            for (int i = 0; i < 6; i++)
            {
                Assert.True
                (
                    H3UniEdge.h3UnidirectionalEdgeIsValid(edges[i]) == 1,
                    "edge is an edge"
                );
                Assert.True
                (
                    sf == H3UniEdge.getOriginH3IndexFromUnidirectionalEdge(edges[i]),
                    "origin is correct"
                );
                Assert.True
                (
                    sf != H3UniEdge.getDestinationH3IndexFromUnidirectionalEdge(edges[i]),
                    "destination is not origin"
                );
            }
        }
Esempio n. 2
0
        public void h3UnidirectionalEdgeIsValid()
        {
            H3Index sf   = H3Index.geoToH3(ref sfGeo, 9);
            var     ring = new ulong[Algos.maxKringSize(1)].Select(cell => new H3Index(cell)).ToList();

            Algos.hexRing(sf, 1, ref ring);
            H3Index sf2 = ring[0];

            H3Index edge = H3UniEdge.getH3UnidirectionalEdge(sf, sf2);

            Assert.True(H3UniEdge.h3UnidirectionalEdgeIsValid(edge) == 1,
                        "edges validate correctly");
            Assert.True(H3UniEdge.h3UnidirectionalEdgeIsValid(sf) == 0,
                        "hexagons do not validate");

            H3Index fakeEdge = sf;

            H3Index.H3_SET_MODE(ref fakeEdge, Constants.H3_UNIEDGE_MODE);
            Assert.True(H3UniEdge.h3UnidirectionalEdgeIsValid(fakeEdge) == 0,
                        "edges without an edge specified don't work");

            H3Index pentagon           = 0x821c07fffffffff;
            H3Index goodPentagonalEdge = pentagon;

            H3Index.H3_SET_MODE(ref goodPentagonalEdge, Constants.H3_UNIEDGE_MODE);
            H3Index.H3_SET_RESERVED_BITS(ref goodPentagonalEdge, 2);
            Assert.True(H3UniEdge.h3UnidirectionalEdgeIsValid(goodPentagonalEdge) == 1,
                        "pentagonal edge validates");

            H3Index badPentagonalEdge = goodPentagonalEdge;

            H3Index.H3_SET_RESERVED_BITS(ref badPentagonalEdge, 1);
            Assert.True(H3UniEdge.h3UnidirectionalEdgeIsValid(badPentagonalEdge) == 0,
                        "missing pentagonal edge does not validate");
        }
Esempio n. 3
0
        public void getH3UnidirectionalEdgesFromPentagon()
        {
            H3Index pentagon = 0x821c07fffffffff;
            var     edges    = new ulong[6].Select(cell => new H3Index(cell)).ToList();

            H3UniEdge.getH3UnidirectionalEdgesFromHexagon(pentagon, edges);

            int missingEdgeCount = 0;

            for (int i = 0; i < 6; i++)
            {
                if (edges[i] == 0)
                {
                    missingEdgeCount++;
                }
                else
                {
                    Assert.True
                    (
                        H3UniEdge.h3UnidirectionalEdgeIsValid(edges[i]) == 1,
                        "edge is an edge"
                    );
                    Assert.True
                    (
                        pentagon ==
                        H3UniEdge.getOriginH3IndexFromUnidirectionalEdge(edges[i]),
                        "origin is correct"
                    );
                    Assert.True
                    (
                        pentagon !=
                        H3UniEdge.getDestinationH3IndexFromUnidirectionalEdge(edges[i]),
                        "destination is not origin"
                    );
                }
            }

            Assert.True
            (
                missingEdgeCount == 1,
                "Only one edge was deleted for the pentagon"
            );
        }
Esempio n. 4
0
 public static int H3UniDirectionalEdgeIsValid(Code.H3Index edge)
 {
     return(H3UniEdge.h3UnidirectionalEdgeIsValid(edge));
 }