private static int GetIDWNeighbors(double[] InCellPoint, ref KDTreeDLL.KDTree InPointsTree, ref double[][] InPoints, out int[] Neighbors, IDWNeighborhoodType NeighborhoodType, int NeighborhoodCount, double NeighborhoodDistance, string ProjUnits) { int tmpIdx; Neighbors = new int[1]; if (NeighborhoodType == IDWNeighborhoodType.Variable) //Taking NeighborhoodCount number of nearest points { if (NeighborhoodDistance == -1) //Then take NeighborhoodCount number of nearest points { Object[] ptIndexObjs = InPointsTree.nearest(InCellPoint, NeighborhoodCount); if (ptIndexObjs.Length == 0) { return(-1); } Neighbors = new int[ptIndexObjs.Length]; for (int i = 0; i < ptIndexObjs.Length; i++) { Neighbors[i] = (int)ptIndexObjs[i]; } } else //Take NeighborhoodCount of nearest points that are a maximum of NeighborhoodDistance away { Object[] ptIndexObjs = InPointsTree.nearest(InCellPoint, NeighborhoodCount); if (ptIndexObjs.Length == 0) { return(-1); } Neighbors = new int[ptIndexObjs.Length]; for (int i = 0; i < ptIndexObjs.Length; i++) { tmpIdx = (int)ptIndexObjs[i]; if (SpatialOperations.Distance(InCellPoint[0], InCellPoint[1], InPoints[tmpIdx][0], InPoints[tmpIdx][1], ProjUnits) <= NeighborhoodDistance) { Neighbors[i] = tmpIdx; } else { Neighbors[i] = -1; } } } } else if (NeighborhoodType == IDWNeighborhoodType.Fixed) //Taking all points in fixed distance { //Something //if (OutNeighbors.Count < NeighborhoodCount) //Test for minimum number of points found //{ // return -1; // //Error //} } else { return(-1); //Error } return(0); }
private static void SortInterpolationPointsByDistanceBrute(InterpolationPoint InCellPoint, ref List <InterpolationPoint> InPointCache, string ProjUnits) { foreach (InterpolationPoint cpoint in InPointCache) { cpoint.Distance = SpatialOperations.Distance(InCellPoint.X, InCellPoint.Y, cpoint.X, cpoint.Y, ProjUnits); } InterpolationPointSorter sorter = new InterpolationPointSorter(); InPointCache.Sort(sorter); }
private static double GetIDWeightBrute(InterpolationPoint CellPoint, InterpolationPoint TestPoint, String ProjUnits, double Power) { return(1 / Math.Pow(SpatialOperations.Distance(CellPoint.X, CellPoint.Y, TestPoint.X, TestPoint.Y, ProjUnits), Power)); }
private static double GetIDWeight(double[] InCellPoint, double[] InTestPoint, String ProjUnits, double Power) { return(1 / Math.Pow(SpatialOperations.Distance(InCellPoint[0], InCellPoint[1], InTestPoint[0], InTestPoint[1], ProjUnits), Power)); }