示例#1
0
        public void IjBaseCells()
        {
            H3Index origin = 0x8029fffffffffff;
            CoordIj ij     = new CoordIj(0, 0);

            (int status, var retrieved) = ij.ToH3Experimental(origin);
            Assert.AreEqual(0, status);
            Assert.AreEqual(0x8029fffffffffff, retrieved.Value);

            ij = ij.ReplaceI(1);
            (status, retrieved) = ij.ToH3Experimental(origin);
            Assert.AreEqual(0, status);
            Assert.AreEqual(0x8051fffffffffff, retrieved.Value);

            ij = ij.ReplaceI(2);
            (status, retrieved) = ij.ToH3Experimental(origin);
            Assert.AreNotEqual(0, status);

            ij = new CoordIj(0, 2);
            (status, retrieved) = ij.ToH3Experimental(origin);
            Assert.AreNotEqual(0, status);

            ij = new CoordIj(-2, -2);
            (status, retrieved) = ij.ToH3Experimental(origin);
            Assert.AreNotEqual(0, status);
        }
示例#2
0
        public void OnOffPentagonSame()
        {
            //  Test that coming from the same direction outside the pentagon is handled
            //  the same as coming from the same direction inside the pentagon.
            for (var bc = 0; bc < Constants.H3.NUM_BASE_CELLS; bc++)
            {
                for (var res = 1; res <= Constants.H3.MAX_H3_RES; res++)
                {
                    // K_AXES_DIGIT is the first internal direction, and it's also
                    // invalid for pentagons, so skip to next.
                    var startDir = Direction.K_AXES_DIGIT;
                    if (bc.IsBaseCellPentagon())
                    {
                        startDir++;
                    }

                    for (var dir = startDir; dir < Direction.NUM_DIGITS; dir++)
                    {
                        var internalOrigin = new H3Index(res, bc, dir);
                        var externalOrigin = new H3Index(res, bc.GetNeighbor(dir), Direction.CENTER_DIGIT);

                        for (var testDir = startDir; testDir < Direction.NUM_DIGITS; testDir++)
                        {
                            var testIndex = new H3Index(res, bc, testDir);
                            (int internalIjFailed, var internalIj) = internalOrigin.ToLocalIjExperimental(testIndex);
                            (int externalIjFailed, var externalIj) = externalOrigin.ToLocalIjExperimental(testIndex);

                            Assert.AreEqual(externalIjFailed != 0, internalIjFailed != 0);

                            if (internalIjFailed != 0)
                            {
                                continue;
                            }

                            (int internalIjFailed2, var internalIndex) = internalIj.ToH3Experimental(internalOrigin);
                            (int externalIjFailed2, var externalIndex) = externalIj.ToH3Experimental(externalOrigin);

                            Assert.AreEqual(externalIjFailed2 != 0, internalIjFailed2 != 0);

                            if (internalIjFailed2 != 0)
                            {
                                continue;
                            }

                            Assert.AreEqual(externalIndex, internalIndex);
                        }
                    }
                }
            }
        }
示例#3
0
文件: Api.cs 项目: wangpei421/h3net
        /// <summary>
        /// hexagons neighbors in all directions, assuming no pentagons,
        /// reporting distance from origin
        /// </summary>
        public static int HexRangeDistances(H3Index origin, int k, out List <H3Index> outCells, out List <int> distances)
        {
            (int status, var values) = origin.HexRangeDistances(k);

            outCells  = new List <H3Index>();
            distances = new List <int>();
            foreach (var tuple in values)
            {
                outCells.Add(tuple.Item1);
                distances.Add(tuple.Item2);
            }

            return(status);
        }
示例#4
0
文件: Api.cs 项目: wangpei421/h3net
 /// <summary>
 /// Number of indexes in a line connecting two indexes
 /// </summary>
 public static int H3LineSize(H3Index start, H3Index end)
 {
     return(start.LineSize(end));
 }
示例#5
0
文件: Api.cs 项目: wangpei421/h3net
 /// <summary>
 /// Returns the GeoBoundary containing the coordinates of the edge
 /// </summary>
 public static void GetH3UnidirectionalEdgeBoundary(H3Index edge, out GeoBoundary gb)
 {
     gb = edge.UniEdgeToGeoBoundary();
 }
示例#6
0
文件: Api.cs 项目: wangpei421/h3net
 /// <summary>
 /// Returns the origin and destination hexagons from the unidirectional
 /// edge H3Index
 /// </summary>
 public static void GetH3IndexesFromUnidirectionalEdge(H3Index edge, out (H3Index, H3Index) originDestination)
 {
     originDestination = edge.GetH3IndexesFromUniEdge();
 }
示例#7
0
文件: Api.cs 项目: wangpei421/h3net
 /// <summary>
 /// Returns the origin hexagon H3Index from the unidirectional edge
 /// </summary>
 /// H3Index
 public static H3Index GetOriginH3IndexFromUnidirectionalEdge(H3Index edge)
 {
     return(edge.OriginFromUniDirectionalEdge());
 }
示例#8
0
文件: Api.cs 项目: wangpei421/h3net
 /// <summary>
 /// returns the unidirectional edge H3Index for the specified origin and
 /// destination
 /// </summary>
 public static H3Index GetH3UnidirectionalEdge(H3Index origin, H3Index destination)
 {
     return(origin.UniDirectionalEdgeTo(destination));
 }
示例#9
0
文件: Api.cs 项目: wangpei421/h3net
 /// <summary>
 /// returns the parent (or grandparent, etc) hexagon of the given hexagon
 /// </summary>
 public static H3Index H3ToParent(H3Index h, int parentRes)
 {
     return(h.ToParent(parentRes));
 }
示例#10
0
文件: Api.cs 项目: wangpei421/h3net
 /// <summary>
 /// confirms if an H3Index is a valid cell (hexagon or pentagon)
 /// </summary>
 public static int H3IsValid(H3Index h)
 {
     return(h.IsValid()
                ? 1
                : 0);
 }
示例#11
0
文件: Api.cs 项目: wangpei421/h3net
 /// <summary>
 /// converts an H3Index to a canonical string
 /// </summary>
 public static void H3ToString(H3Index h, out string str)
 {
     str = h.ToString();
 }
示例#12
0
文件: Api.cs 项目: wangpei421/h3net
 /// <summary>
 /// returns the base cell "number" (0 to 121) of the provided H3 cell
 /// </summary>
 public static int H3GetBaseCell(H3Index h)
 {
     return(h.BaseCell);
 }
示例#13
0
文件: Api.cs 项目: wangpei421/h3net
 /// <summary>
 /// returns the resolution of the provided H3 index
 /// Works on both cells and unidirectional edges.
 /// </summary>
 public static int H3GetResolution(H3Index h)
 {
     return(h.Resolution);
 }
示例#14
0
文件: Api.cs 项目: wangpei421/h3net
 /// <summary>
 /// give the cell boundary in lat/lon coordinates for the cell h3
 /// </summary>
 public static void H3ToGeoBoundary(H3Index h3, out GeoBoundary gb)
 {
     gb = h3.ToGeoBoundary();
 }
示例#15
0
文件: Api.cs 项目: wangpei421/h3net
 /// <summary>
 /// exact length for a specific unidirectional edge in meters*/
 /// </summary>
 public static decimal ExactEdgeLengthM(H3Index edge)
 {
     return(edge.ExactEdgeLengthM());
 }
示例#16
0
文件: Api.cs 项目: wangpei421/h3net
 /// <summary>
 /// hexagons neighbors in all directions, assuming no pentagons
 /// </summary>
 public static int HexRange(H3Index origin, int k, out List <H3Index> outHex)
 {
     (int status, var tempHex) = origin.HexRange(k);
     outHex = tempHex;
     return(status);
 }
示例#17
0
文件: Api.cs 项目: wangpei421/h3net
 /// <summary>
 /// returns whether or not the provided hexagons border
 /// </summary>
 public static int H3IndexesAreNeighbors(H3Index origin, H3Index destination)
 {
     return(origin.IsNeighborTo(destination)
                ? 1
                : 0);
 }
示例#18
0
文件: Api.cs 项目: wangpei421/h3net
 /// <summary>
 /// determines the maximum number of children (or grandchildren, etc)
 /// </summary>
 public static long MaxH3ToChildrenSize(H3Index h, int childRes)
 {
     return(h.MaxChildrenSize(childRes));
 }
示例#19
0
文件: Api.cs 项目: wangpei421/h3net
 /// <summary>
 /// returns whether the H3Index is a valid unidirectional edge
 /// </summary>
 public static int H3UnidirectionalEdgeIsValid(H3Index edge)
 {
     return(edge.IsValidUniEdge()
                ? 1
                : 0);
 }
示例#20
0
文件: Api.cs 项目: wangpei421/h3net
 /// <summary>
 /// provides the children (or grandchildren, etc) of the given hexagon
 /// </summary>
 public static void H3ToChildren(H3Index h, int childRes, out List <H3Index> outChildren)
 {
     outChildren = h.ToChildren(childRes);
 }
示例#21
0
文件: Api.cs 项目: wangpei421/h3net
 /// <summary>
 /// Returns the destination hexagon H3Index from the unidirectional edge
 /// H3Index
 /// </summary>
 public static H3Index GetDestinationH3IndexFromUnidirectionalEdge(H3Index edge)
 {
     return(edge.DestinationFromUniDirectionalEdge());
 }
示例#22
0
文件: Api.cs 项目: wangpei421/h3net
 /// <summary>
 /// returns the center child of the given hexagon at the specified resolution
 /// </summary>
 public static H3Index H3ToCenterChild(H3Index h, int childRes)
 {
     return(h.ToCenterChild(childRes));
 }
示例#23
0
文件: Api.cs 项目: wangpei421/h3net
 /// <summary>
 /// Returns the 6 (or 5 for pentagons) edges associated with the H3Index
 /// </summary>
 public static void GetH3UnidirectionalEdgesFromHexagon(H3Index origin, out List <H3Index> edges)
 {
     edges = origin.GetUniEdgesFromCell().ToList();
 }
示例#24
0
文件: Api.cs 项目: wangpei421/h3net
 /// <summary>
 /// determines if a hexagon is Class III (or Class II)
 /// </summary>
 public static int H3IsResClassIii(H3Index h)
 {
     return(h.IsResClassIii
                ? 1
                : 0);
 }
示例#25
0
文件: Api.cs 项目: wangpei421/h3net
 /// <summary>
 /// Returns grid distance between two indexes
 /// </summary>
 public static int H3Distance(H3Index origin, H3Index h3)
 {
     return(origin.DistanceTo(h3));
 }
示例#26
0
文件: Api.cs 项目: wangpei421/h3net
 /// <summary>
 /// determines if an H3 cell is a pentagon
 /// </summary>
 public static int H3IsPentagon(H3Index h)
 {
     return(h.IsPentagon()
                ? 1
                : 0);
 }
示例#27
0
文件: Api.cs 项目: wangpei421/h3net
 /// <summary>
 /// Line of h3 indexes connecting two indexes
 /// </summary>
 public static int H3Line(H3Index start, H3Index end, out List <H3Index> outCells)
 {
     (int status, var tempCells) = start.LineTo(end);
     outCells = tempCells.ToList();
     return(status);
 }
示例#28
0
文件: Api.cs 项目: wangpei421/h3net
 /// <summary>
 /// Max number of icosahedron faces intersected by an index
 /// </summary>
 public static int MaxFaceCount(H3Index h3)
 {
     return(h3.MaxFaceCount());
 }
示例#29
0
文件: Api.cs 项目: wangpei421/h3net
 /// <summary>
 /// hexagon neighbors in all directions
 /// </summary>
 public static void KRing(H3Index origin, int k, out List <H3Index> outCells)
 {
     outCells = origin.KRing(k);
 }
示例#30
0
文件: Api.cs 项目: wangpei421/h3net
 /// <summary>
 /// Find all icosahedron faces intersected by a given H3 index
 /// </summary>
 public static void H3GetFaces(H3Index h3, out List <int> outFaces)
 {
     outFaces = h3.GetFaces();
 }