Пример #1
0
        public decimal GetValue(object ValueParameter, bool UseInterpolation = true,
                                decimal InterpolationAdjustment = 1.0m, decimal AdjustmentProximityLength = 1.0m)
        {
            decimal ValLowerLeftPoint  = LowerLeftPoint.GetValue(ValueParameter);
            decimal ValLowerRightPoint = LowerRightPoint.GetValue(ValueParameter);
            decimal ValUpperLeftPoint  = UpperLeftPoint.GetValue(ValueParameter);
            decimal ValUpperRightPoint = UpperRightPoint.GetValue(ValueParameter);

            decimal retVal;

            if (UseInterpolation == true)
            {
                Quad Quad = new Quad()
                {
                    LowerLeftPoint  = new DataPoint2D(LowerLeftPoint.Longitude, LowerLeftPoint.Latitude, ValLowerLeftPoint),
                    LowerRightPoint = new DataPoint2D(LowerRightPoint.Longitude, LowerRightPoint.Latitude, ValLowerRightPoint),
                    UpperLeftPoint  = new DataPoint2D(UpperLeftPoint.Longitude, UpperLeftPoint.Latitude, ValUpperLeftPoint),
                    UpperRightPoint = new DataPoint2D(UpperRightPoint.Longitude, UpperRightPoint.Latitude, ValUpperRightPoint)
                };

                retVal = Quad.GetInterpolatedValue(Longitude, Latitude, InterpolationAdjustment, AdjustmentProximityLength);
            }
            else
            {
                List <decimal> ValList = new List <decimal> {
                    ValLowerLeftPoint, ValLowerRightPoint, ValUpperLeftPoint, ValUpperRightPoint
                };
                retVal = ValList.Max();
            }
            return(retVal);
        }
Пример #2
0
        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);
            }
        }