示例#1
0
        public void getH3UnidirectionalEdgeBoundaryPentagonClassIII()
        {
            H3Index     pentagon     = 0;
            GeoBoundary boundary     = new GeoBoundary();
            GeoBoundary edgeBoundary = new GeoBoundary();
            var         edges        = new ulong[6].Select(cell => new H3Index(cell)).ToList();

            int[,] expectedVertices =
            {
                { -1, -1, -1 }, { 2, 3, 4 },
                {  4,  5,  6 }, { 8, 9, 0 },
                {  6,  7,  8 }, { 0, 1, 2 }
            };

            // TODO: The current implementation relies on lat/lon comparison and fails
            // on resolutions finer than 12
            for (int res = 1; res < 13; res += 2)
            {
                H3Index.setH3Index(ref pentagon, res, 24, 0);
                H3Index.h3ToGeoBoundary(pentagon, ref boundary);
                H3UniEdge.getH3UnidirectionalEdgesFromHexagon(pentagon, edges);

                int missingEdgeCount = 0;
                for (int i = 0; i < 6; i++)
                {
                    if (edges[i] == 0)
                    {
                        missingEdgeCount++;
                    }
                    else
                    {
                        H3UniEdge.getH3UnidirectionalEdgeBoundary(edges[i], ref edgeBoundary);
                        Assert.True
                            (edgeBoundary.numVerts == 3,
                            "Got the expected number of vertices back for a Class III pentagon"
                            );
                        for (int j = 0; j < edgeBoundary.numVerts; j++)
                        {
                            Assert.True
                            (
                                GeoCoord.geoAlmostEqual(edgeBoundary.verts[j], boundary.verts[expectedVertices[i, j]]),
                                "Got expected vertex"
                            );
                        }
                    }
                }

                Assert.True
                    (missingEdgeCount == 1,
                    "Only one edge was deleted for the pentagon"
                    );
            }
        }
示例#2
0
        public static GeoBoundary GetH3UnidirectionalEdgeBoundary(Code.H3Index edge)
        {
            Code.GeoBoundary gb = new Code.GeoBoundary();
            H3UniEdge.getH3UnidirectionalEdgeBoundary(edge, ref gb);
            var newVerts = gb.verts.Select(v => new GeoCoord(v)).ToArray();

            return(new GeoBoundary
            {
                VertexCount = gb.numVerts,
                Vertices = newVerts
            });
        }
示例#3
0
        public void getH3UnidirectionalEdgeBoundary()
        {
            H3Index     sf           = 0;
            GeoBoundary boundary     = new GeoBoundary();
            GeoBoundary edgeBoundary = new GeoBoundary();
            var         edges        = new ulong[6].Select(cell => new H3Index(cell)).ToList();

            int[,] expectedVertices =
            {
                { 3, 4 }, { 1, 2 }, { 2, 3 },
                { 5, 0 }, { 4, 5 }, { 0, 1 }
            };

            // TODO: The current implementation relies on lat/lon comparison and fails
            // on resolutions finer than 12
            for (int res = 0; res < 13; res++)
            {
                sf = H3Index.geoToH3(ref sfGeo, res);
                H3Index.h3ToGeoBoundary(sf, ref boundary);
                H3UniEdge.getH3UnidirectionalEdgesFromHexagon(sf, edges);

                for (int i = 0; i < 6; i++)
                {
                    H3UniEdge.getH3UnidirectionalEdgeBoundary(edges[i], ref edgeBoundary);
                    Assert.True(edgeBoundary.numVerts == 2,
                                "Got the expected number of vertices back");
                    for (int j = 0; j < edgeBoundary.numVerts; j++)
                    {
                        Assert.True(
                            GeoCoord.geoAlmostEqual(edgeBoundary.verts[j],
                                                    boundary.verts[expectedVertices[i, j]]),
                            "Got expected vertex");
                    }
                }
            }
        }