public void getH3UnidirectionalEdgeAndFriends()
        {
            H3Index        sf   = H3Index.geoToH3(ref sfGeo, 9);
            List <H3Index> 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(sf == H3UniEdge.getOriginH3IndexFromUnidirectionalEdge(edge),
                        "can retrieve the origin from the edge");
            Assert.True(
                sf2 == H3UniEdge.getDestinationH3IndexFromUnidirectionalEdge(edge),
                "can retrieve the destination from the edge");

            var originDestination = new ulong[2].Select(cell => new H3Index(cell)).ToList();

            H3UniEdge.getH3IndexesFromUnidirectionalEdge(edge, ref originDestination);
            Assert.True(originDestination[0] == sf,
                        "got the origin first in the pair request");
            Assert.True(originDestination[1] == sf2,
                        "got the destination last in the pair request");

            List <H3Index> largerRing = new ulong[Algos.maxKringSize(2)].Select(cell => new H3Index(cell)).ToList();

            Algos.hexRing(sf, 2, ref largerRing);
            H3Index sf3 = largerRing[0];

            H3Index notEdge = H3UniEdge.getH3UnidirectionalEdge(sf, sf3);

            Assert.True(notEdge == 0, "Non-neighbors can't have edges");
        }
Beispiel #2
0
        public static H3Index[] GetH3IndexesFromUnidirectionalEdge(Code.H3Index edge)
        {
            List <Code.H3Index> cells = new List <Code.H3Index> {
                0, 0
            };

            H3UniEdge.getH3IndexesFromUnidirectionalEdge(edge, ref cells);
            return(cells.Select(v => new H3Index {
                Value = v.value
            }).ToArray());
        }