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)); }
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)); }
/// <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)); }
/// <summary> /// Geocentric to Geocentric transformation /// </summary> /// <param name="source"></param> /// <param name="target"></param> /// <returns></returns> private static ICoordinateTransformation CreateGeoc2Geoc(IGeocentricCoordinateSystem source, IGeocentricCoordinateSystem target) { ConcatenatedTransform mathTransform = new ConcatenatedTransform(); if ((source.HorizontalDatum.Wgs84Parameters != null) && !source.HorizontalDatum.Wgs84Parameters.HasZeroValuesOnly) { mathTransform.CoordinateTransformationList.Add(new CoordinateTransformation(((target.HorizontalDatum.Wgs84Parameters == null) || target.HorizontalDatum.Wgs84Parameters.HasZeroValuesOnly) ? target : GeocentricCoordinateSystem.WGS84, source, TransformType.Transformation, new DatumTransform(source.HorizontalDatum.Wgs84Parameters), "", "", -1L, "", "")); } if ((target.HorizontalDatum.Wgs84Parameters != null) && !target.HorizontalDatum.Wgs84Parameters.HasZeroValuesOnly) { mathTransform.CoordinateTransformationList.Add(new CoordinateTransformation(((source.HorizontalDatum.Wgs84Parameters == null) || source.HorizontalDatum.Wgs84Parameters.HasZeroValuesOnly) ? source : GeocentricCoordinateSystem.WGS84, target, TransformType.Transformation, new DatumTransform(target.HorizontalDatum.Wgs84Parameters).Inverse(), "", "", -1L, "", "")); } if (mathTransform.CoordinateTransformationList.Count == 1) { return(new CoordinateTransformation(source, target, TransformType.ConversionAndTransformation, mathTransform.CoordinateTransformationList[0].MathTransform, "", "", -1L, "", "")); } return(new CoordinateTransformation(source, target, TransformType.ConversionAndTransformation, mathTransform, "", "", -1L, "", "")); }
/// <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 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); }
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); }
/// <summary> /// Geocentric to Geocentric transformation /// </summary> /// <param name="source"></param> /// <param name="target"></param> /// <returns></returns> private static ICoordinateTransformation CreateGeoc2Geoc(IGeocentricCoordinateSystem source, IGeocentricCoordinateSystem target) { ConcatenatedTransform mathTransform = new ConcatenatedTransform(); if ((source.HorizontalDatum.Wgs84Parameters != null) && !source.HorizontalDatum.Wgs84Parameters.HasZeroValuesOnly) { mathTransform.CoordinateTransformationList.Add(new CoordinateTransformation(((target.HorizontalDatum.Wgs84Parameters == null) || target.HorizontalDatum.Wgs84Parameters.HasZeroValuesOnly) ? target : GeocentricCoordinateSystem.WGS84, source, TransformType.Transformation, new DatumTransform(source.HorizontalDatum.Wgs84Parameters), "", "", -1L, "", "")); } if ((target.HorizontalDatum.Wgs84Parameters != null) && !target.HorizontalDatum.Wgs84Parameters.HasZeroValuesOnly) { mathTransform.CoordinateTransformationList.Add(new CoordinateTransformation(((source.HorizontalDatum.Wgs84Parameters == null) || source.HorizontalDatum.Wgs84Parameters.HasZeroValuesOnly) ? source : GeocentricCoordinateSystem.WGS84, target, TransformType.Transformation, new DatumTransform(target.HorizontalDatum.Wgs84Parameters).Inverse(), "", "", -1L, "", "")); } if (mathTransform.CoordinateTransformationList.Count == 1) { return new CoordinateTransformation(source, target, TransformType.ConversionAndTransformation, mathTransform.CoordinateTransformationList[0].MathTransform, "", "", -1L, "", ""); } return new CoordinateTransformation(source, target, TransformType.ConversionAndTransformation, mathTransform, "", "", -1L, "", ""); }