示例#1
0
 public static H3Index GetOriginH3FromUniDirectionalEdge(Code.H3Index edge)
 {
     return(new H3Index
     {
         Value = H3UniEdge.getOriginH3IndexFromUnidirectionalEdge(edge).value
     });
 }
示例#2
0
        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");
        }
示例#3
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"
                );
            }
        }
示例#4
0
        public void getOriginH3IndexFromUnidirectionalEdgeBadInput()
        {
            H3Index hexagon = 0x891ea6d6533ffffL;

            Assert.True(H3UniEdge.getOriginH3IndexFromUnidirectionalEdge(hexagon) == 0,
                        "getting the origin from a hexagon index returns 0");
            Assert.True(H3UniEdge.getOriginH3IndexFromUnidirectionalEdge(0) == 0,
                        "getting the origin from a null index returns 0");
        }
示例#5
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"
            );
        }