public static IEnumerable <GeometryData> Load(PolygonFile source) { var geomFact = new GeometryFactory(); using var reader = new ShapefileDataReader(source.Filename, geomFact); CoordinateSystem f = ProjectionUtils.Transforms[source.Srid]; CoordinateSystem t = ProjectionUtils.EPSG_4326(); var transformer = ProjectionUtils.GetTransformer(f, t); while (reader.Read()) { var name = reader.GetString(source.Name); string reference = null; if (source.Reference != null) { reference = reader.GetString((int)source.Reference); } if (reference == null) { reference = Guid.NewGuid().ToString(); } var geom = ProjectionUtils.Transform(reader.Geometry, transformer); var data = new GeometryData { Name = name, DataType = source.DataType, Reference = reference, Geom = geom }; yield return(data); } }
IEnumerable <GeometryData> ProcessSourceFile(PolygonFile sourcefile) { switch (sourcefile.Processor) { case "shapefile": { var items = ShapefileLoader.Load(sourcefile).ToList(); _logger.LogInformation($"Loaded {items.Count} from {sourcefile.Title}"); return(items); } } return(null); }