예제 #1
0
        public void Test_PointTarget_VisitContainingShapes()
        {
            // Only shapes 2 and 4 should contain the target point.
            var index = MakeIndexOrDie(
                "1:1 # 1:1, 2:2 # 0:0, 0:3, 3:0 | 6:6, 6:9, 9:6 | 0:0, 0:4, 4:0");
            var target = new S2MinDistancePointTarget(MakePointOrDie("1:1"));

            Assert.True(IsSubsetOfSize(GetContainingShapes(target, index, 1),
                                       new int[] { 2, 4 }, 1));
            Assert.Equal((new int[] { 2, 4 }), GetContainingShapes(target, index, 5));
        }
예제 #2
0
        public void Test_PointTarget_UpdateMinDistanceToCellWhenEqual()
        {
            // Verifies that UpdateMinDistance only returns true when the new distance
            // is less than the old distance (not less than or equal to).
            var    target = new S2MinDistancePointTarget(MakePointOrDie("1:0"));
            var    dist   = S1ChordAngle.Infinity;
            S2Cell cell   = new(new S2CellId(MakePointOrDie("0:0")));

            Assert.True(target.UpdateMinDistance(cell, ref dist));
            Assert.False(target.UpdateMinDistance(cell, ref dist));
        }
예제 #3
0
        public void Test_PointTarget_UpdateMinDistanceToEdgeWhenEqual()
        {
            // Verifies that UpdateMinDistance only returns true when the new distance
            // is less than the old distance (not less than or equal to).
            var          target = new S2MinDistancePointTarget(MakePointOrDie("1:0"));
            S1ChordAngle dist   = S1ChordAngle.Infinity;
            var          edge   = ParsePointsOrDie("0:-1, 0:1");

            Assert.True(target.UpdateMinDistance(edge[0], edge[1], ref dist));
            Assert.False(target.UpdateMinDistance(edge[0], edge[1], ref dist));
        }