public static List <Geometry> Project(this List <Geometry> values, CoordinateReferenceSystemBase sourceSrs, CoordinateReferenceSystemBase targetSrs) { List <Geometry> result = new List <Geometry>(values.Count); if (sourceSrs.Ellipsoid.AreTheSame(targetSrs.Ellipsoid)) { for (int i = 0; i < values.Count; i++) { var c1 = values[i].Transform(p => sourceSrs.ToGeodetic(p), SridHelper.GeodeticWGS84); result.Add(c1.Transform(p => targetSrs.FromGeodetic(p), targetSrs.Srid)); } } else { for (int i = 0; i < values.Count; i++) { var c1 = values[i].Transform(p => sourceSrs.ToGeodetic(p), SridHelper.GeodeticWGS84); result.Add(c1.Transform(p => targetSrs.FromGeodetic(p, sourceSrs.Ellipsoid), targetSrs.Srid)); } } return(result); }
public static List <IShape> Project(List <IShape> values, CoordinateReferenceSystemBase sourceSrs, CoordinateReferenceSystemBase targetSrs) { List <IShape> result = new List <IShape>(values.Count); if (sourceSrs.Ellipsoid.AreTheSame(targetSrs.Ellipsoid)) { for (int i = 0; i < values.Count; i++) { var c1 = values[i].Transform(p => sourceSrs.ToGeodetic(p)); result.Add(c1.Transform(p => targetSrs.FromGeodetic(p))); } } else { for (int i = 0; i < values.Count; i++) { var c1 = values[i].Transform(p => sourceSrs.ToGeodetic(p)); result.Add(c1.Transform(p => targetSrs.FromGeodetic(p, sourceSrs.Ellipsoid))); } } return(result); }
public static Task <ShapefileDataSource <object> > Create(string shapeFileName, string spatialColumnName, int srid, Encoding encoding, CoordinateReferenceSystemBase targetCrs, string labelColumnName = null) { return(Task.Run <ShapefileDataSource <object> >(() => { var sourcePrj = IRI.Ket.ShapefileFormat.Shapefile.GetPrjFileName(shapeFileName); if (!System.IO.File.Exists(sourcePrj)) { throw new System.IO.FileNotFoundException($"prj file not found. {sourcePrj}"); } var sourceCrs = new ShapefileFormat.Prj.PrjFile(sourcePrj).AsMapProjection(); Func <Point, Point> func = null; if (sourceCrs.Ellipsoid.AreTheSame(targetCrs.Ellipsoid)) { func = new Func <Point, Point>(p => (Point)targetCrs.FromGeodetic(sourceCrs.ToGeodetic(p))); } else { func = new Func <Point, Point>(p => (Point)targetCrs.FromGeodetic(sourceCrs.ToGeodetic(p), sourceCrs.Ellipsoid)); } return new ShapefileDataSource <object>(shapeFileName, spatialColumnName, srid, encoding, true, labelColumnName, func); })); }
public static IPoint Project(this IPoint point, CoordinateReferenceSystemBase sourceSrs, CoordinateReferenceSystemBase targetSrs) { if (sourceSrs.Ellipsoid.AreTheSame(targetSrs.Ellipsoid)) { var c1 = sourceSrs.ToGeodetic(point); return(targetSrs.FromGeodetic(c1)); } else { var c1 = sourceSrs.ToGeodetic(point); return(targetSrs.FromGeodetic(c1, sourceSrs.Ellipsoid)); } }