public void Test_CellTarget_UpdateMinDistanceToEdgeWhenEqual() { var target = new S2MinDistanceCellTarget(new S2Cell( new S2CellId(MakePointOrDie("0:1")))); var 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)); }
public void Test_CellTarget_UpdateMinDistanceToCellWhenEqual() { var target = new S2MinDistanceCellTarget(new S2Cell( new S2CellId(MakePointOrDie("0:1")))); var dist = S1ChordAngle.Infinity; var cell = new S2Cell(new S2CellId(MakePointOrDie("0:0"))); Assert.True(target.UpdateMinDistance(cell, ref dist)); Assert.False(target.UpdateMinDistance(cell, ref dist)); }
public void Test_CellTarget_VisitContainingShapes() { var index = MakeIndexOrDie( "1:1 # 1:1, 2:2 # 0:0, 0:3, 3:0 | 6:6, 6:9, 9:6 | -1:-1, -1:5, 5:-1"); // Only shapes 2 and 4 should contain a very small cell near 1:1. var cellid1 = new S2CellId(MakePointOrDie("1:1")); var target1 = new S2MinDistanceCellTarget(new S2Cell(cellid1)); Assert.True(IsSubsetOfSize(GetContainingShapes(target1, index, 1), new int[] { 2, 4 }, 1)); Assert.Equal(new int[] { 2, 4 }, GetContainingShapes(target1, index, 5)); // For a larger cell that properly contains one or more index cells, all // shapes that intersect the first such cell in S2CellId order are returned. // In the test below, this happens to again be the 1st and 3rd polygons // (whose shape_ids are 2 and 4). var cellid2 = cellid1.Parent(5); var target2 = new S2MinDistanceCellTarget(new S2Cell(cellid2)); Assert.Equal(new int[] { 2, 4 }, GetContainingShapes(target2, index, 5)); }