public bool Equals(DataPoint2D p) { // If parameter is null return false: if ((object)p == null) { return(false); } // Return true if the fields match: return((X == p.X) && (Y == p.Y)); }
public bool IsNear(DataPoint2D p, decimal Tolerance) { double X1 = (double)p.X; double X2 = (double)X; double Y1 = (double)p.Y; double Y2 = (double)Y; double distance = Math.Sqrt(Math.Pow(X1 - X2, 2) + Math.Pow(Y1 - Y2, 2)); decimal dist = (decimal)distance; if (dist < Tolerance) { return(true); } else { return(false); } }
public override bool Equals(System.Object obj) { // If parameter is null return false. if (obj == null) { return(false); } // If parameter cannot be cast to Point return false. DataPoint2D p = obj as DataPoint2D; if ((System.Object)p == null) { return(false); } // Return true if the fields match: return((X == p.X) && (Y == p.Y)); }
public decimal GetInterpolatedValue(decimal XAbsolute, decimal YAbsolute, decimal InterpolationAdjustment = 1.0m, decimal AdjustmentProximityLength = 1.0m) //if the value is interpolated an adjustment is introduced to account for the //difference between USGS more precise calculation and this procedure { decimal x = XAbsolute; decimal y = YAbsolute; decimal x1 = LowerLeftPoint.X; decimal x2 = UpperRightPoint.X; decimal y1 = LowerLeftPoint.Y; decimal y2 = UpperRightPoint.Y; decimal R1 = ((x2 - x) / (x2 - x1)) * LowerLeftPoint.Value + ((x - x1) / (x2 - x1)) * LowerRightPoint.Value; decimal R2 = ((x2 - x) / (x2 - x1)) * UpperLeftPoint.Value + ((x - x1) / (x2 - x1)) * UpperRightPoint.Value; decimal P = ((y2 - y) / (y2 - y1)) * R1 + ((y - y1) / (y2 - y1)) * R2; DataPoint2D readingPoint = new DataPoint2D(XAbsolute, YAbsolute, 0); //it is assumed that the middle 2/3 need adjustment closer to the gridded points no adjustment is made decimal t = Math.Min(Math.Abs(LowerRightPoint.X - LowerLeftPoint.X), Math.Abs(LowerRightPoint.Y - UpperLeftPoint.Y)) / AdjustmentProximityLength; if (!LowerLeftPoint.IsNear(readingPoint, t) && !LowerRightPoint.IsNear(readingPoint, t) && !UpperLeftPoint.IsNear(readingPoint, t) && !UpperRightPoint.IsNear(readingPoint, t)) { List <decimal> values = new List <decimal>() { LowerLeftPoint.Value, LowerRightPoint.Value, UpperLeftPoint.Value, UpperRightPoint.Value }; decimal MaxVal = values.Max(); decimal P_adjusted = P * InterpolationAdjustment; decimal P_final = Math.Min(MaxVal, P_adjusted); return(P_final); } else { return(P); } }