private static ICoordinateTransformation Proj2Geog(IProjectedCoordinateSystem source, IGeographicCoordinateSystem target) { if (source.GeographicCoordinateSystem.EqualParams(target)) { IMathTransform mathTransform = CreateCoordinateOperation(source.Projection, source.GeographicCoordinateSystem.HorizontalDatum.Ellipsoid, source.LinearUnit).Inverse(); return(new CoordinateTransformation(source, target, TransformType.Transformation, mathTransform, String.Empty, String.Empty, -1, String.Empty, String.Empty)); } else { // Geographic coordinatesystems differ - Create concatenated transform ConcatenatedTransform ct = new ConcatenatedTransform(); CoordinateTransformationFactory ctFac = new CoordinateTransformationFactory(); ct.CoordinateTransformationList.Add(ctFac.CreateFromCoordinateSystems(source, source.GeographicCoordinateSystem)); ct.CoordinateTransformationList.Add(ctFac.CreateFromCoordinateSystems(source.GeographicCoordinateSystem, target)); return(new CoordinateTransformation(source, target, TransformType.Transformation, ct, String.Empty, String.Empty, -1, String.Empty, String.Empty)); } }
private static ICoordinateTransformation Proj2Proj(IProjectedCoordinateSystem source, IProjectedCoordinateSystem target) { var ct = new ConcatenatedTransform(); var ctFac = new CoordinateTransformationFactory(); //First transform from projection to geographic ct.CoordinateTransformationList.Add(ctFac.CreateFromCoordinateSystems(source, source.GeographicCoordinateSystem)); //Transform geographic to geographic: var geogToGeog = ctFac.CreateFromCoordinateSystems(source.GeographicCoordinateSystem, target.GeographicCoordinateSystem); if (geogToGeog != null) { ct.CoordinateTransformationList.Add(geogToGeog); } //Transform to new projection ct.CoordinateTransformationList.Add(ctFac.CreateFromCoordinateSystems(target.GeographicCoordinateSystem, target)); return(new CoordinateTransformation(source, target, TransformType.Transformation, ct, String.Empty, String.Empty, -1, String.Empty, String.Empty)); }
/// <summary> /// Creates transformation from source coordinate system to specified target system which is the fitted one /// </summary> /// <param name="source"></param> /// <param name="target"></param> /// <returns></returns> private static ICoordinateTransformation Any2Fitt(ICoordinateSystem source, IFittedCoordinateSystem target) { //Transform form base system of fitted to target coordinate system - use invered math transform IMathTransform invMt = CreateFittedTransform(target).Inverse(); //case when source system is equal to base system of the fitted if (target.BaseCoordinateSystem.EqualParams(source)) { //Transform form base system of fitted to target coordinate system return(CreateTransform(source, target, TransformType.Transformation, invMt)); } ConcatenatedTransform ct = new ConcatenatedTransform(); //First transform from source to base system of fitted CoordinateTransformationFactory ctFac = new CoordinateTransformationFactory(); ct.CoordinateTransformationList.Add(ctFac.CreateFromCoordinateSystems(source, target.BaseCoordinateSystem)); //Transform form base system of fitted to target coordinate system - use invered math transform ct.CoordinateTransformationList.Add(CreateTransform(target.BaseCoordinateSystem, target, TransformType.Transformation, invMt)); return(CreateTransform(source, target, TransformType.Transformation, ct)); }
/// <summary> /// Creates transformation from fitted coordinate system to the target one /// </summary> /// <param name="source"></param> /// <param name="target"></param> /// <returns></returns> private static ICoordinateTransformation Fitt2Any(IFittedCoordinateSystem source, ICoordinateSystem target) { //transform from fitted to base system of fitted (which is equal to target) IMathTransform mt = CreateFittedTransform(source); //case when target system is equal to base system of the fitted if (source.BaseCoordinateSystem.EqualParams(target)) { //Transform form base system of fitted to target coordinate system return(CreateTransform(source, target, TransformType.Transformation, mt)); } //Transform form base system of fitted to target coordinate system ConcatenatedTransform ct = new ConcatenatedTransform(); ct.CoordinateTransformationList.Add(CreateTransform(source, source.BaseCoordinateSystem, TransformType.Transformation, mt)); //Transform form base system of fitted to target coordinate system CoordinateTransformationFactory ctFac = new CoordinateTransformationFactory(); ct.CoordinateTransformationList.Add(ctFac.CreateFromCoordinateSystems(source.BaseCoordinateSystem, target)); return(CreateTransform(source, target, TransformType.Transformation, ct)); }