private static ICoordinateTransformation Proj2Proj(IProjectedCoordinateSystem source, IProjectedCoordinateSystem target) { ConcatenatedTransform mathTransform = new ConcatenatedTransform(); CoordinateTransformationFactory factory = new CoordinateTransformationFactory(); mathTransform.CoordinateTransformationList.Add(factory.CreateFromCoordinateSystems(source, source.GeographicCoordinateSystem)); mathTransform.CoordinateTransformationList.Add(factory.CreateFromCoordinateSystems(source.GeographicCoordinateSystem, target.GeographicCoordinateSystem)); mathTransform.CoordinateTransformationList.Add(factory.CreateFromCoordinateSystems(target.GeographicCoordinateSystem, target)); return new CoordinateTransformation(source, target, TransformType.Transformation, mathTransform, string.Empty, string.Empty, -1L, string.Empty, string.Empty); }
/// <summary> /// Geographic to geographic transformation /// </summary> /// <remarks>Adds a datum shift if nessesary</remarks> /// <param name="source"></param> /// <param name="target"></param> /// <returns></returns> private ICoordinateTransformation CreateGeog2Geog(IGeographicCoordinateSystem source, IGeographicCoordinateSystem target) { if (source.HorizontalDatum.EqualParams(target.HorizontalDatum)) { return new CoordinateTransformation(source, target, TransformType.Conversion, new Topology.CoordinateSystems.Transformations.GeographicTransform(source, target), string.Empty, string.Empty, -1L, string.Empty, string.Empty); } CoordinateTransformationFactory factory = new CoordinateTransformationFactory(); CoordinateSystemFactory factory2 = new CoordinateSystemFactory(); IGeocentricCoordinateSystem targetCS = factory2.CreateGeocentricCoordinateSystem(source.HorizontalDatum.Name + " Geocentric", source.HorizontalDatum, LinearUnit.Metre, source.PrimeMeridian); IGeocentricCoordinateSystem system2 = factory2.CreateGeocentricCoordinateSystem(target.HorizontalDatum.Name + " Geocentric", target.HorizontalDatum, LinearUnit.Metre, source.PrimeMeridian); ConcatenatedTransform mathTransform = new ConcatenatedTransform(); mathTransform.CoordinateTransformationList.Add(factory.CreateFromCoordinateSystems(source, targetCS)); mathTransform.CoordinateTransformationList.Add(factory.CreateFromCoordinateSystems(targetCS, system2)); mathTransform.CoordinateTransformationList.Add(factory.CreateFromCoordinateSystems(system2, target)); return new CoordinateTransformation(source, target, TransformType.Transformation, mathTransform, string.Empty, string.Empty, -1L, string.Empty, string.Empty); }
private static ICoordinateTransformation Proj2Geog(IProjectedCoordinateSystem source, IGeographicCoordinateSystem target) { if (source.GeographicCoordinateSystem.EqualParams(target)) { return new CoordinateTransformation(source, target, TransformType.Transformation, CreateCoordinateOperation(source.Projection, source.GeographicCoordinateSystem.HorizontalDatum.Ellipsoid).Inverse(), string.Empty, string.Empty, -1L, string.Empty, string.Empty); } ConcatenatedTransform mathTransform = new ConcatenatedTransform(); CoordinateTransformationFactory factory = new CoordinateTransformationFactory(); mathTransform.CoordinateTransformationList.Add(factory.CreateFromCoordinateSystems(source, source.GeographicCoordinateSystem)); mathTransform.CoordinateTransformationList.Add(factory.CreateFromCoordinateSystems(source.GeographicCoordinateSystem, target)); return new CoordinateTransformation(source, target, TransformType.Transformation, mathTransform, string.Empty, string.Empty, -1L, string.Empty, string.Empty); }