public void testAllNeighbors(S2CellId id, int level) { Assert.True(level >= id.Level && level < S2CellId.MaxLevel); // We compute GetAllNeighbors, and then add in all the children of "id" // at the given level. We then compare this against the result of finding // all the vertex neighbors of all the vertices of children of "id" at the // given level. These should give the same result. var all = new List <S2CellId>(); var expected = new List <S2CellId>(); id.GetAllNeighbors(level, all); var end = id.ChildEndForLevel(level + 1); for (var c = id.ChildBeginForLevel(level + 1); !c.Equals(end); c = c.Next) { all.Add(c.Parent); c.GetVertexNeighbors(level, expected); } // Sort the results and eliminate duplicates. all.Sort(); expected.Sort(); ISet <S2CellId> allSet = new HashSet <S2CellId>(all); ISet <S2CellId> expectedSet = new HashSet <S2CellId>(expected); var result = allSet.SetEquals(expectedSet); Assert.True(result); }
public void testAllNeighbors(S2CellId id, int level) { Assert.True(level >= id.Level && level < S2CellId.MaxLevel); // We compute GetAllNeighbors, and then add in all the children of "id" // at the given level. We then compare this against the result of finding // all the vertex neighbors of all the vertices of children of "id" at the // given level. These should give the same result. var all = new List<S2CellId>(); var expected = new List<S2CellId>(); id.GetAllNeighbors(level, all); var end = id.ChildEndForLevel(level + 1); for (var c = id.ChildBeginForLevel(level + 1); !c.Equals(end); c = c.Next) { all.Add(c.Parent); c.GetVertexNeighbors(level, expected); } // Sort the results and eliminate duplicates. all.Sort(); expected.Sort(); ISet<S2CellId> allSet = new HashSet<S2CellId>(all); ISet<S2CellId> expectedSet = new HashSet<S2CellId>(expected); var result = allSet.SetEquals(expectedSet); Assert.True(result); }