Example #1
0
    private static void TestCellOps(S2LatLngRect r, S2Cell cell, int level)
    {
        // Test the relationship between the given rectangle and cell:
        // 0 == no intersection, 1 == MayIntersect, 2 == Intersects,
        // 3 == Vertex Containment, 4 == Contains

        bool vertex_contained = false;

        for (int i = 0; i < 4; ++i)
        {
            if (r.Contains(cell.VertexRaw(i)) ||
                (!r.IsEmpty() && cell.Contains(r.Vertex(i).ToPoint())))
            {
                vertex_contained = true;
            }
        }
        Assert.Equal(r.MayIntersect(cell), level >= 1);
        Assert.Equal(r.Intersects(cell), level >= 2);
        Assert.Equal(vertex_contained, level >= 3);
        Assert.Equal(r.Contains(cell), level >= 4);
    }