public IEnumerable<KeyValuePair<string, DbGeography>> Read(string filePath, string nameColumnIdentifier) { var shapes = new ShapeFileHelper().Read(filePath, nameColumnIdentifier); return shapes.AsParallel().Select(x => { var transformedGeography = GeometryTransform.TransformGeometry( GeometryFactory.Default, x.Value, _transform); var sqlGeography = SqlGeography.STGeomFromText(new SqlChars(transformedGeography.AsText()), 4326) .MakeValid(); var invertedSqlGeography = sqlGeography.ReorientObject(); if (sqlGeography.STArea() > invertedSqlGeography.STArea()) { sqlGeography = invertedSqlGeography; } var dbGeography = DbSpatialServices.Default.GeographyFromProviderValue(sqlGeography); return new KeyValuePair<string, DbGeography>(x.Key, dbGeography); }); }
public IEnumerable <KeyValuePair <string, DbGeography> > Read(string filePath, string nameColumnIdentifier) { var shapes = new ShapeFileHelper().Read(filePath, nameColumnIdentifier); return(shapes.AsParallel().Select(x => { var transformedGeography = GeometryTransform.TransformGeometry( GeometryFactory.Default, x.Value, _transform); var sqlGeography = SqlGeography.STGeomFromText(new SqlChars(transformedGeography.AsText()), 4326) .MakeValid(); var invertedSqlGeography = sqlGeography.ReorientObject(); if (sqlGeography.STArea() > invertedSqlGeography.STArea()) { sqlGeography = invertedSqlGeography; } var dbGeography = DbSpatialServices.Default.GeographyFromProviderValue(sqlGeography); return new KeyValuePair <string, DbGeography>(x.Key, dbGeography); })); }
public void ReadShapeFile() { var shapes = new ShapeFileHelper().Read("..\\..\\..\\data\\KOMMUNE", "KOMNAVN").ToList(); }