public static SqlGeometry ReprojectTo(this SqlGeometry geom, ProjectionInfo destination) { Func<double[], double[]> reprojectionFunc = SqlGeometryReprojection.Identity; // Defines the starting coordiante system ProjectionInfo pStart = ProjectionInfo.FromEpsgCode(geom.STSrid.Value); // Defines the starting coordiante system ProjectionInfo pEnd = destination; reprojectionFunc = pts => SqlGeometryReprojection.ReprojectPoint(pts, 0, pStart, pEnd); GeometryToGeometrySink sink = new GeometryToGeometrySink(destination.AuthorityCode, pts => reprojectionFunc(pts)); geom.Populate(sink); return sink.ConstructedGeometry; }
public static SqlGeometry ReprojectTo(this SqlGeometry geom, ProjectionInfo destination) { Func <double[], double[]> reprojectionFunc = SqlGeometryReprojection.Identity; // Defines the starting coordiante system ProjectionInfo pStart = ProjectionInfo.FromEpsgCode(geom.STSrid.Value); // Defines the starting coordiante system ProjectionInfo pEnd = destination; reprojectionFunc = pts => SqlGeometryReprojection.ReprojectPoint(pts, 0, pStart, pEnd); GeometryToGeometrySink sink = new GeometryToGeometrySink(destination.AuthorityCode, pts => reprojectionFunc(pts)); geom.Populate(sink); return(sink.ConstructedGeometry); }