Exemplo n.º 1
0
        /// <summary>
        /// Opens the in google earth.
        /// </summary>
        /// <param name="dbLocation">The database location.</param>
        /// <param name="pathFile">The path file.</param>
        /// <param name="pathApplication">The path application.</param>
        public static void OpenInGoogleEarth(FormationMatcher dbLocation, string pathFile, string pathApplication)
        {
            Kml.WriteToKml(pathFile, dbLocation);

            System.Diagnostics.Process          process   = new System.Diagnostics.Process();
            System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
            startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
            startInfo.FileName    = "cmd.exe";
            // /C Carries out the command specified by string and then terminates
            startInfo.Arguments = "/C \"" + pathApplication + "\" \"" + pathFile + "\"";
            process.StartInfo   = startInfo;
            process.Start();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Collates the locations and regions.
        /// </summary>
        /// <param name="filePathKml">The file path KML.</param>
        /// <param name="filePathExcelDb">The file path excel database.</param>
        /// <param name="filePathExcelPeakbagger">The file path excel peakbagger.</param>
        /// <param name="filePathExcelDbCsv">The file path excel database CSV.</param>
        /// <param name="filePathExcelPeakbaggerCsv">The file path excel peakbagger CSV.</param>
        /// <param name="filePathExcelPeakbaggerCsvSource">The file path excel peakbagger CSV source.</param>
        /// <returns>List&lt;Region&gt;.</returns>
        public static List <Region> CollateLocationsAndRegions(string filePathKml,
                                                               string filePathExcelDb                  = "",
                                                               string filePathExcelPeakbagger          = "",
                                                               string filePathExcelDbCsv               = "",
                                                               string filePathExcelPeakbaggerCsv       = "",
                                                               string filePathExcelPeakbaggerCsvSource = "")
        {
            // Get regions
            KmlFile       file    = Kml.OpenFile(filePathKml);
            List <Region> regions = Kml.ReadRegions(file);

            // Get the extents of all regions
            Extents regionsExtents = new Extents();

            foreach (Region region in regions)
            {
                regionsExtents.Add(region.Extents);
            }


            // Get database locations
            List <FormationMatcher> locations;

            if (string.IsNullOrEmpty(filePathExcelDbCsv))
            {
                using (ExcelHelper excelDb = Excel.OpenFile(filePathExcelDb))
                {
                    locations = Excel.ReadDBLocations(excelDb);
                }

                string filePath = Path.GetFileNameWithoutExtension(filePathExcelDb) + ".csv";
                WriteToCsv(filePath, locations);
            }
            else
            {
                ReadFromCsv(filePathExcelDbCsv, out locations);
            }

            // Add locations to the appropriate region
            foreach (Region region in regions)
            {
                region.AddLocationsByRegionName(locations);
            }

            // Get peakbagger locations
            List <Formation> locationsPeakbagger =
                GetPeakbaggerLocations(regionsExtents,
                                       filePathExcelPeakbagger,
                                       filePathExcelPeakbaggerCsv,
                                       filePathExcelPeakbaggerCsvSource);

            // Add locations to the appropriate region
            foreach (Region region in regions)
            {
                region.AddLocationsByCoordinates(locationsPeakbagger);
                region.MergeLocations();
                region.CondensePotentialMatches();
            }

            return(regions);
        }