/// <summary> /// Gets the peakbagger locations. /// </summary> /// <param name="regionsExtents">The extents of all regions of interest for which formations are retrieved.</param> /// <param name="filePathExcelSource">The file path excel source.</param> /// <param name="filePathCSV">The file path CSV.</param> /// <param name="filePathCSVSource">The file path CSV source.</param> /// <returns>List<Location>.</returns> public static List <Formation> GetPeakbaggerLocations(Extents regionsExtents, string filePathExcelSource, string filePathCSV = "", string filePathCSVSource = "") { List <Formation> locationsPeakbagger; if (string.IsNullOrEmpty(filePathCSV)) { if (string.IsNullOrEmpty(filePathCSVSource)) { using (ExcelHelper excelPeakbagger = Excel.OpenFile(filePathExcelSource)) { locationsPeakbagger = Excel.ReadPeakbaggerLocations(excelPeakbagger, regionsExtents.MaxLatitude, regionsExtents.MinLongitude, regionsExtents.MaxLongitude, regionsExtents.MinLongitude); } } else { locationsPeakbagger = ReadPeakbaggerLocationsFromCsv(filePathCSVSource, regionsExtents.MaxLatitude, regionsExtents.MinLongitude, regionsExtents.MaxLongitude, regionsExtents.MinLongitude); } string filePath = Path.GetFileNameWithoutExtension(filePathExcelSource) + ".csv"; WriteToCsv(filePath, locationsPeakbagger); } else { ReadFromCsv(filePathCSV, out locationsPeakbagger); } return(locationsPeakbagger); }
/// <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); }
/// <summary> /// Determines whether the specified location is within extents. /// </summary> /// <param name="location">The location.</param> /// <returns><c>true</c> if the specified location is within extents; otherwise, <c>false</c>.</returns> private bool isWithinExtents(Location location) { return(Extents.IsWithinExtents(location.Latitude, location.Longitude)); }
/// <summary> /// Sets the extents. /// </summary> private void setExtents() { Extents = Extents.GetExtents(Boundary); }