Exemple #1
0
        private void AnalyzeY_Click(object sender, RoutedEventArgs e)
        {
            var    sortedInput     = ParseCSV.GetRange(this.importedData, this.Y_Index);
            double average_space   = (sortedInput[sortedInput.Length - 1] - sortedInput[0]) / (sortedInput.Length - 1);
            double spacingVariance = 0;

            for (int i = 0; i < sortedInput.Length - 1; i++)
            {
                double space = sortedInput[i + 1] - sortedInput[i];
                space           -= average_space;
                spacingVariance += space * space;
            }
            spacingVariance /= (sortedInput.Length - 1);
            StringBuilder sb = new StringBuilder();

            sb.AppendLine(string.Format("Field Name:\t\t{0}", this.IDToFields[this.Y_Index]));
            sb.AppendLine(string.Format("Field Index:\t\t{0}", this.Y_Index.ToString()));
            sb.AppendLine(string.Format("Number of Y Spaces:\t{0}", sortedInput.Length.ToString()));
            sb.AppendLine(string.Format("Average of Y Space:\t{0}", average_space.ToString()));
            sb.AppendLine(string.Format("Variance of Y Space:\t{0}", Math.Sqrt(spacingVariance).ToString()));
            sb.AppendLine("Range: ");
            sb.AppendLine(string.Format("\tMin:\t{0}", sortedInput[0].ToString()));
            sb.AppendLine(string.Format("\tMax:\t{0}", sortedInput[sortedInput.Length - 1].ToString()));
            sb.AppendLine("Output Range: ");
            sb.AppendLine(string.Format("\tMin:\t{0}", this.cellularFloor.Origin.V.ToString()));
            sb.AppendLine(string.Format("\tMax:\t{0}", this.cellularFloor.TopRight.V.ToString()));
            MessageBox.Show(sb.ToString(), "Fields Data Description");
            sb.Clear();
            sb          = null;
            sortedInput = null;
        }
Exemple #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ParseCSV"/> class.
        /// </summary>
        /// <param name="host">The host.</param>
        public ParseCSV(OSMDocument host)
        {
            this._host = host;
            #region Reading data and getting data fields
            if (this.readFile())
            {
                this.importer  = new DataImportInterface(this.inputData, this._host.cellularFloor);
                importer.Owner = this._host;
                this.importer.ShowDialog();
                if (importer.X_Index == -1)
                {
                    importer = null;
                    MessageBox.Show("Data was not loaded!");
                    this.Succeed = false;
                    return;
                }
                else
                {
                    this.Succeed = true;
                }
            }
            else
            {
                MessageBox.Show("Data was not loaded!");
                this.Succeed = false;
                return;
            }
            #endregion
            this.IndexToArea = new Dictionary <Index, double>();
            #region load ID map to names

            this.IDToName = new Dictionary <int, string>();
            this.NameToID = new Dictionary <string, int>();
            for (int i = 0; i < this.importer.Names.Length; i++)
            {
                if (i != this.importer.X_Index && i != this.importer.Y_Index)
                {
                    this.IDToName.Add(i, this.importer.Names[i]);
                    this.NameToID.Add(this.importer.Names[i], i);
                }
            }

            #endregion
            var x_sorted = ParseCSV.GetRange(inputData, this.importer.X_Index, this.importer.Scale);
            var y_sorted = ParseCSV.GetRange(inputData, this.importer.Y_Index, this.importer.Scale);


            this.dist_x   = (x_sorted[x_sorted.Length - 1] - x_sorted[0]) / (x_sorted.Length - 1);
            this.dist_y   = (y_sorted[y_sorted.Length - 1] - y_sorted[0]) / (y_sorted.Length - 1);
            this.X_min    = x_sorted[0];
            this.X_max    = x_sorted[x_sorted.Length - 1] + this.dist_x;
            this.Y_min    = y_sorted[0];
            this.Y_max    = y_sorted[y_sorted.Length - 1] + this.dist_y;
            this.number_X = x_sorted.Length;
            this.number_Y = y_sorted.Length;


            this.DataPoints = new UVData[this.number_X, this.number_Y];
            for (int i = 1; i < inputData.Length; i++)
            {
                this.parse(inputData[i]);
            }
        }