public void Test_ShapeIndexTarget_VisitContainingShapesEmptyAndFull() { // Verify that VisitContainingShapes never returns empty polygons and always // returns full polygons (i.e., those containing the entire sphere). // Creating an index containing one empty and one full polygon. var index = MakeIndexOrDie("# # empty | full"); // Check only the full polygon is returned for a point target. var point_index = MakeIndexOrDie("1:1 # #"); var point_target = new S2MinDistanceShapeIndexTarget(point_index); Assert.Equal((new int[] { 1 }), GetContainingShapes(point_target, index, 5)); // Check only the full polygon is returned for a full polygon target. var full_polygon_index = MakeIndexOrDie("# # full"); var full_target = new S2MinDistanceShapeIndexTarget(full_polygon_index); Assert.Equal((new int[] { 1 }), GetContainingShapes(full_target, index, 5)); // Check that nothing is returned for an empty polygon target. (An empty // polygon has no connected components and does not intersect anything, so // according to the API of GetContainingShapes nothing should be returned.) var empty_polygon_index = MakeIndexOrDie("# # empty"); var empty_target = new S2MinDistanceShapeIndexTarget(empty_polygon_index); Assert.Equal((new int[] { }), GetContainingShapes(empty_target, index, 5)); }
public void Test_ShapeIndexTarget_UpdateMinDistanceToCellWhenEqual() { var target_index = MakeIndexOrDie("1:0 # #"); var target = new S2MinDistanceShapeIndexTarget(target_index); 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_ShapeIndexTarget_UpdateMinDistanceToEdgeWhenEqual() { var target_index = MakeIndexOrDie("1:0 # #"); var target = new S2MinDistanceShapeIndexTarget(target_index); 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_ShapeIndexTarget_VisitContainingShapes() { // Create an index containing a repeated grouping of one point, one // polyline, and one polygon. var index = MakeIndexOrDie("1:1 | 4:4 | 7:7 | 10:10 # " + "1:1, 1:2 | 4:4, 4:5 | 7:7, 7:8 | 10:10, 10:11 # " + "0:0, 0:3, 3:0 | 3:3, 3:6, 6:3 | 6:6, 6:9, 9:6 | 9:9, 9:12, 12:9"); // Construct a target consisting of one point, one polyline, and one polygon // with two loops where only the second loop is contained by a polygon in // the index above. var target_index = MakeIndexOrDie( "1:1 # 4:5, 5:4 # 20:20, 20:21, 21:20; 10:10, 10:11, 11:10"); var target = new S2MinDistanceShapeIndexTarget(target_index); // These are the shape_ids of the 1st, 2nd, and 4th polygons of "index" // (noting that the 4 points are represented by one S2PointVectorShape). Assert.Equal((new int[] { 5, 6, 8 }), GetContainingShapes(target, index, 5)); }