public void CreateKDBushIndex_RadiusSearch_CorrectPointsReturned() { var index = new KDBush <double[]>(pointsData, nodeSize: 10); var qp = new double[] { 50, 50 }; var r = 20; var result = index.Within(qp[0], qp[1], r); Assert.Equal(new[] { 60, 6, 25, 92, 42, 20, 45, 3, 71, 44, 18, 96 }, result); }
public void CreateKDBushIndex_RadiusSearch_AllUnReturnedPointsOutsideRadius() { var index = new KDBush <double[]>(pointsData, nodeSize: 10); var qp = new double[] { 50, 50 }; var r = 20; var r2 = 20 * 20; var result = index.Within(qp[0], qp[1], r); for (var i = 0; i < ids.Length; i++) { var p = pointsData[ids[i]]; Assert.False(result.IndexOf(ids[i]) < 0 && SqDist(p, qp) <= r2); } }
public void CreateKDBushIndex_RadiusSearch_AllReturnedPointsInRadius() { var index = new KDBush <double[]>(pointsData, nodeSize: 10); var qp = new double[] { 50, 50 }; var r = 20; var r2 = 20 * 20; var result = index.Within(qp[0], qp[1], r); for (var i = 0; i < result.Count; i++) { var p = pointsData[result[i]]; Assert.False(SqDist(p, qp) > r2); } }