public static IEnumerable <GeometryData> Load(PointFile source) { var fact = new GeometryFactory(); using StreamReader reader = File.OpenText(source.Filename); var options = new CsvOptions { HeaderMode = source.HeaderMode, RowsToSkip = source.RowsToSkip, Separator = source.Separator[0] }; CoordinateSystem f = ProjectionUtils.Transforms[source.Srid]; CoordinateSystem t = ProjectionUtils.EPSG_4326(); foreach (var row in CsvReader.Read(reader, options).Take(source.MaxRecords ?? int.MaxValue)) { double.TryParse(row[source.Latitude], out double latitude); double.TryParse(row[source.Longitude], out double longitude); var geom = new Coordinate(longitude, latitude); geom = geom.Transform(f, t); var data = new GeometryData { DataType = source.DataType, Geom = fact.CreatePoint(geom), Name = row[source.Name], Reference = source.Reference != null ? row[(int)source.Reference] : null, }; yield return(data); } }
IEnumerable <GeometryData> ProcessSourceFile(PointFile sourcefile) { var items = PointCsvFileLoader.Load(sourcefile).ToList(); _logger.LogInformation($"Loaded {items.Count} from {sourcefile.Title}"); return(items); }
private void pointFilesListView_SelectionChanged(object sender, SelectionChangedEventArgs e) { PointFile selectedFile = (PointFile)pointFilesListView.SelectedItem; if (selectedFile != null) { GraphWindow contactDetailsWindow = new GraphWindow(PointsToFile.parse(selectedFile.Points)); contactDetailsWindow.ShowDialog(); } }