Exemple #1
0
        private static void computeLocationClusters()
        {
            GPSAS_DestinationsFormInstance.SetStatusText("Clustering area");

            areaID = 0;

            // For each data point in the array of data
            for (int i = 0; i < arrData.Length; i++)
            {
                // Update progress bar
                GPSAS_DestinationsFormInstance.UpdateProgressBarParse((int)Math.Round(((Double)i / (Double)arrData.Length) * 100));

                // If the data point location has not been processed yet
                if (arrData[i].AID == UNMARKED)
                {
                    // Retrieve the indexes of the location based neighbors for this datapoint
                    List <int> neighborIndexes = retrieveAreaNeighbours(i);

                    // If the number of neighbors to this data point does not meet the num neighbors requirement, mark as NOISE
                    if (neighborIndexes.Count < MINPTS)
                    {
                        arrData[i].AID = NOISE;
                    }
                    else
                    {
                        // Increment cluster ID
                        areaID = areaID + 1;

                        // Mark each neighbor data point with the coresponding neighbor index
                        foreach (int index in neighborIndexes)
                        {
                            arrData[index].AID = areaID;
                        }
                    }
                }
            }
            Logger.Log("There are this many area clusters: " + areaID.ToString());
        }
Exemple #2
0
        /// <summary>
        /// Reads the provided excel file into a data set.
        /// </summary>
        /// <param name="parentInstance">Instance of parent form</param>
        /// <param name="fileName">File name to be parsed.</param>
        public static void ReadData(GPSAS_DestinationsForm parentInstance, String fileName)
        {
            parentInstance.SetStatusText("Reading file");
            // Create file stream
            FileStream stream = File.Open(fileName, FileMode.Open, FileAccess.Read);
            // Create excel reader instance
            IExcelDataReader excelReader = ExcelReaderFactory.CreateOpenXmlReader(stream);

            // Column names ARE in first row, but they are needed to determine column names
            excelReader.IsFirstRowAsColumnNames = false;
            // Assign data to DataSet
            DataSet dataSet = excelReader.AsDataSet();

            // Clean up
            excelReader.Close();
            stream.Close();
            // Parse data
            parseDataSet(dataSet);
        }