Beispiel #1
0
        public DataColumn(string id, string name, IDimension dimension, BaseGrid baseGrid)
        {
            Id           = id;
            Name         = name;
            Dimension    = dimension;
            BaseGrid     = baseGrid;
            QuantityInfo = new QuantityInfo(new List <string>(), QuantityType.Undefined);
            var defaultUnitName = dimension != null ? dimension.DefaultUnitName : string.Empty;

            DataInfo = new DataInfo(ColumnOrigins.Undefined)
            {
                DisplayUnitName = defaultUnitName
            };
            IsInternal = false;
        }
Beispiel #2
0
        public virtual float GetValue(float baseValue)
        {
            if (Values == null || !Values.Any())
            {
                return(float.NaN);
            }

            int index = BaseGrid.IndexOf(baseValue);

            if (index >= 0)
            {
                return(Values[index]);
            }

            int leftIndex  = BaseGrid.LeftIndexOf(baseValue);
            int rightIndex = BaseGrid.RightIndexOf(baseValue);

            if (leftIndex < 0)
            {
                return(float.NaN);
            }

            if (rightIndex >= BaseGrid.Count)
            {
                return(float.NaN);
            }

            if (leftIndex == rightIndex)
            {
                return(float.NaN);
            }

            return(Values[leftIndex] +
                   (Values[rightIndex] - Values[leftIndex]) * (baseValue - BaseGrid[leftIndex]) /
                   (BaseGrid[rightIndex] - BaseGrid[leftIndex]));
        }
Beispiel #3
0
 public DataColumn(string name, IDimension dimension, BaseGrid baseGrid)
     : this(Guid.NewGuid().ToString(), name, dimension, baseGrid)
 {
 }