/// <summary> /// Returns a new extents object. /// </summary> /// <param name="coordinates">The coordinates.</param> /// <returns>Extents.</returns> public static Extents GetExtents(IEnumerable <Vector> coordinates) { Extents extents = new Extents(); extents.Add(coordinates); return(extents); }
/// <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<Region>.</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); }