private static IMathTransform CreateCoordinateOperation(IGeocentricCoordinateSystem geo) { List<ProjectionParameter> parameterList = new List<ProjectionParameter>(2); parameterList.Add(new ProjectionParameter("semi_major", geo.HorizontalDatum.Ellipsoid.SemiMajorAxis)); parameterList.Add(new ProjectionParameter("semi_minor", geo.HorizontalDatum.Ellipsoid.SemiMinorAxis)); return new GeocentricTransform(parameterList); }
/// <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)) { //No datum shift needed return(new CoordinateTransformation(source, target, TransformType.Conversion, new GeographicTransform(source, target), String.Empty, String.Empty, -1, String.Empty, String.Empty)); } else { //Create datum shift //Convert to geocentric, perform shift and return to geographic CoordinateTransformationFactory ctFac = new CoordinateTransformationFactory(); CoordinateSystemFactory cFac = new CoordinateSystemFactory(); IGeocentricCoordinateSystem sourceCentric = cFac.CreateGeocentricCoordinateSystem(source.HorizontalDatum.Name + " Geocentric", source.HorizontalDatum, LinearUnit.Metre, source.PrimeMeridian); IGeocentricCoordinateSystem targetCentric = cFac.CreateGeocentricCoordinateSystem(target.HorizontalDatum.Name + " Geocentric", target.HorizontalDatum, LinearUnit.Metre, source.PrimeMeridian); ConcatenatedTransform ct = new ConcatenatedTransform(); ct.CoordinateTransformationList.Add(ctFac.CreateFromCoordinateSystems(source, sourceCentric)); ct.CoordinateTransformationList.Add(ctFac.CreateFromCoordinateSystems(sourceCentric, targetCentric)); ct.CoordinateTransformationList.Add(ctFac.CreateFromCoordinateSystems(targetCentric, target)); return(new CoordinateTransformation(source, target, TransformType.Transformation, ct, String.Empty, String.Empty, -1, String.Empty, String.Empty)); } }
private void TestGeocentric() { CoordinateSystemFactory cFac = new CoordinateSystemFactory(); IGeographicCoordinateSystem gcs = cFac.CreateGeographicCoordinateSystem("WGS84", AngularUnit.Degrees, HorizontalDatum.WGS84, PrimeMeridian.Greenwich, new AxisInfo("Lon", AxisOrientationEnum.East), new AxisInfo("Lat", AxisOrientationEnum.North)); IGeocentricCoordinateSystem geoccs = cFac.CreateGeocentricCoordinateSystem("WGS84 geocentric", gcs.HorizontalDatum, LinearUnit.Metre, PrimeMeridian.Greenwich); ICoordinateTransformation trans = new CoordinateTransformationFactory().CreateFromCoordinateSystems(gcs, geoccs); var pGeo = new Coordinate(2.12955, 53.80939444, 73); var pGc = Transform(trans.MathTransform, pGeo); trans.MathTransform.Invert(); var pGeo2 = Transform(trans.MathTransform, pGc); trans.MathTransform.Invert(); result.Text += PrintResultTable(gcs, geoccs, pGeo, pGc, new Coordinate(3771793.97, 140253.34, 5124304.35), pGeo2, "Geocentric test"); return; }
private static IMathTransform CreateCoordinateOperation(IGeocentricCoordinateSystem geo) { List <ProjectionParameter> parameterList = new List <ProjectionParameter>(2); parameterList.Add(new ProjectionParameter("semi_major", geo.HorizontalDatum.Ellipsoid.SemiMajorAxis)); parameterList.Add(new ProjectionParameter("semi_minor", geo.HorizontalDatum.Ellipsoid.SemiMinorAxis)); return(new GeocentricTransform(parameterList)); }
private static ICoordinateTransformation Geoc2Geog(IGeocentricCoordinateSystem source, IGeographicCoordinateSystem target) { IMathTransform geocMathTransform = CreateCoordinateOperation(source).Inverse(); if (source.PrimeMeridian.EqualParams(target.PrimeMeridian)) { return(new CoordinateTransformation(source, target, TransformType.Conversion, geocMathTransform, String.Empty, String.Empty, -1, String.Empty, String.Empty)); } else { var ct = new ConcatenatedTransform(); ct.CoordinateTransformationList.Add(new CoordinateTransformation(source, target, TransformType.Conversion, geocMathTransform, String.Empty, String.Empty, -1, String.Empty, String.Empty)); ct.CoordinateTransformationList.Add(new CoordinateTransformation(source, target, TransformType.Transformation, new PrimeMeridianTransform(source.PrimeMeridian, target.PrimeMeridian), String.Empty, String.Empty, -1, String.Empty, String.Empty)); return(new CoordinateTransformation(source, target, TransformType.Conversion, ct, String.Empty, String.Empty, -1, String.Empty, String.Empty)); } }
public void TestGeocentric() { CoordinateSystemFactory cFac = new CoordinateSystemFactory(); IGeographicCoordinateSystem gcs = cFac.CreateGeographicCoordinateSystem("ETRF89 Geographic", AngularUnit.Degrees, HorizontalDatum.ETRF89, PrimeMeridian.Greenwich, new AxisInfo("East", AxisOrientationEnum.East), new AxisInfo("North", AxisOrientationEnum.North)); IGeocentricCoordinateSystem gcenCs = cFac.CreateGeocentricCoordinateSystem("ETRF89 Geocentric", HorizontalDatum.ETRF89, LinearUnit.Metre, PrimeMeridian.Greenwich); CoordinateTransformationFactory gtFac = new CoordinateTransformationFactory(); ICoordinateTransformation ct = gtFac.CreateFromCoordinateSystems(gcs, gcenCs); double[] pExpected = new double[] { 2 + 7.0 / 60 + 46.38 / 3600, 53 + 48.0 / 60 + 33.82 / 3600 }; // Point.FromDMS(2, 7, 46.38, 53, 48, 33.82); double[] pExpected3D = new double[] { pExpected[0], pExpected[1], 73.0 }; double[] p0 = new double[] { 3771793.97, 140253.34, 5124304.35 }; double[] p1 = ct.MathTransform.Transform(pExpected3D) as double[]; double[] p2 = ct.MathTransform.Inverse().Transform(p1) as double[]; Assert.IsTrue(ToleranceLessThan(p1, p0, 0.01)); Assert.IsTrue(ToleranceLessThan(p2, pExpected, 0.00001)); }
/// <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, "", "")); }
private static IMathTransform CreateCoordinateOperation(IGeocentricCoordinateSystem geo) { var parameterList = new List <ProjectionParameter>(2); var ellipsoid = geo.HorizontalDatum.Ellipsoid; //var toMeter = ellipsoid.AxisUnit.MetersPerUnit; if (parameterList.Find((p) => p.Name.ToLowerInvariant().Replace(' ', '_').Equals("semi_major")) == null) { parameterList.Add(new ProjectionParameter("semi_major", /*toMeter * */ ellipsoid.SemiMajorAxis)); } if (parameterList.Find((p) => p.Name.ToLowerInvariant().Replace(' ', '_').Equals("semi_minor")) == null) { parameterList.Add(new ProjectionParameter("semi_minor", /*toMeter * */ ellipsoid.SemiMinorAxis)); } return(new GeocentricTransform(parameterList)); }
/// <summary> /// Geocentric to Geocentric transformation /// </summary> /// <param name="source"></param> /// <param name="target"></param> /// <returns></returns> private static ICoordinateTransformation CreateGeoc2Geoc(IGeocentricCoordinateSystem source, IGeocentricCoordinateSystem target) { var ct = new ConcatenatedTransform(); //Does source has a datum different from WGS84 and is there a shift specified? if (source.HorizontalDatum.Wgs84Parameters != null && !source.HorizontalDatum.Wgs84Parameters.HasZeroValuesOnly) { ct.CoordinateTransformationList.Add( new CoordinateTransformation( ((target.HorizontalDatum.Wgs84Parameters == null || target.HorizontalDatum.Wgs84Parameters.HasZeroValuesOnly) ? target : GeocentricCoordinateSystem.WGS84), source, TransformType.Transformation, new DatumTransform(source.HorizontalDatum.Wgs84Parameters) , "", "", -1, "", "")); } //Does target has a datum different from WGS84 and is there a shift specified? if (target.HorizontalDatum.Wgs84Parameters != null && !target.HorizontalDatum.Wgs84Parameters.HasZeroValuesOnly) { ct.CoordinateTransformationList.Add( new CoordinateTransformation( ((source.HorizontalDatum.Wgs84Parameters == null || source.HorizontalDatum.Wgs84Parameters.HasZeroValuesOnly) ? source : GeocentricCoordinateSystem.WGS84), target, TransformType.Transformation, new DatumTransform(target.HorizontalDatum.Wgs84Parameters).Inverse() , "", "", -1, "", "")); } //If we don't have a transformation in this list, return null if (ct.CoordinateTransformationList.Count == 0) { return(null); } //If we only have one shift, lets just return the datumshift from/to wgs84 if (ct.CoordinateTransformationList.Count == 1) { return(new CoordinateTransformation(source, target, TransformType.ConversionAndTransformation, ct.CoordinateTransformationList[0].MathTransform, "", "", -1, "", "")); } return(new CoordinateTransformation(source, target, TransformType.ConversionAndTransformation, ct, "", "", -1, "", "")); }
public void TestGeocentric() { CoordinateSystemFactory cFac = new CoordinateSystemFactory(); IGeographicCoordinateSystem gcs = cFac.CreateGeographicCoordinateSystem("ETRF89 Geographic", AngularUnit.Degrees, HorizontalDatum.ETRF89, PrimeMeridian.Greenwich, new AxisInfo("East", AxisOrientation.East), new AxisInfo("North", AxisOrientation.North)); IGeocentricCoordinateSystem gcenCs = cFac.CreateGeocentricCoordinateSystem("ETRF89 Geocentric", HorizontalDatum.ETRF89, LinearUnit.Metre, PrimeMeridian.Greenwich); CoordinateTransformationFactory gtFac = new CoordinateTransformationFactory(); ICoordinateTransformation ct = gtFac.CreateFromCoordinateSystems(gcs, gcenCs); Point pExpected = Point.FromDMS(2, 7, 46.38, 53, 48, 33.82); Point3D pExpected3D = new Point3D(pExpected.X, pExpected.Y, 73.0); Point3D p0 = new Point3D(3771793.97, 140253.34, 5124304.35); Point3D p1 = ct.MathTransform.Transform(pExpected3D) as Point3D; Point3D p2 = ct.MathTransform.Inverse().Transform(p1) as Point3D; Assert.IsTrue(toleranceLessThan(p1, p0, 0.01)); Assert.IsTrue(toleranceLessThan(p2, pExpected, 0.00001)); }
private static ICoordinateTransformation Geoc2Geog(IGeocentricCoordinateSystem source, IGeographicCoordinateSystem target) { IMathTransform geocMathTransform = CreateCoordinateOperation(source).Inverse(); return(new CoordinateTransformation(source, target, TransformType.Conversion, geocMathTransform, String.Empty, String.Empty, -1, String.Empty, String.Empty)); }
private static ICoordinateTransformation Geog2Geoc(IGeographicCoordinateSystem source, IGeocentricCoordinateSystem target) { return(new CoordinateTransformation(source, target, TransformType.Conversion, CreateCoordinateOperation(target), string.Empty, string.Empty, -1L, string.Empty, string.Empty)); }
private static ICoordinateTransformation Geog2Geoc(IGeographicCoordinateSystem source, IGeocentricCoordinateSystem target) { IMathTransform geocMathTransform = CreateCoordinateOperation(target); if (source.PrimeMeridian.EqualParams(target.PrimeMeridian)) { return new CoordinateTransformation(source, target, TransformType.Conversion, geocMathTransform, String.Empty, String.Empty, -1, String.Empty, String.Empty); } else { var ct = new ConcatenatedTransform(); ct.CoordinateTransformationList.Add(new CoordinateTransformation(source, target, TransformType.Transformation, new PrimeMeridianTransform(source.PrimeMeridian, target.PrimeMeridian), String.Empty, String.Empty, -1, String.Empty, String.Empty)); ct.CoordinateTransformationList.Add(new CoordinateTransformation(source, target, TransformType.Conversion, geocMathTransform, String.Empty, String.Empty, -1, String.Empty, String.Empty)); return new CoordinateTransformation(source, target, TransformType.Conversion, ct, String.Empty, String.Empty, -1, String.Empty, String.Empty); } }
private static ICoordinateTransformation Geog2Geoc(IGeographicCoordinateSystem source, IGeocentricCoordinateSystem target) { IMathTransform geocMathTransform = CreateCoordinateOperation(target); return new CoordinateTransformation(source, target, TransformType.Conversion, geocMathTransform, String.Empty, String.Empty, -1, 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 ct = new ConcatenatedTransform(); //Does source has a datum different from WGS84 and is there a shift specified? if (source.HorizontalDatum.Wgs84Parameters != null && !source.HorizontalDatum.Wgs84Parameters.HasZeroValuesOnly) ct.CoordinateTransformationList.Add( new CoordinateTransformation( ((target.HorizontalDatum.Wgs84Parameters == null || target.HorizontalDatum.Wgs84Parameters.HasZeroValuesOnly) ? target : GeocentricCoordinateSystem.WGS84), source, TransformType.Transformation, new DatumTransform(source.HorizontalDatum.Wgs84Parameters) , "", "", -1, "", "")); //Does target has a datum different from WGS84 and is there a shift specified? if (target.HorizontalDatum.Wgs84Parameters != null && !target.HorizontalDatum.Wgs84Parameters.HasZeroValuesOnly) ct.CoordinateTransformationList.Add( new CoordinateTransformation( ((source.HorizontalDatum.Wgs84Parameters == null || source.HorizontalDatum.Wgs84Parameters.HasZeroValuesOnly) ? source : GeocentricCoordinateSystem.WGS84), target, TransformType.Transformation, new DatumTransform(target.HorizontalDatum.Wgs84Parameters).Inverse() , "", "", -1, "", "")); if (ct.CoordinateTransformationList.Count == 1) //Since we only have one shift, lets just return the datumshift from/to wgs84 return new CoordinateTransformation(source, target, TransformType.ConversionAndTransformation, ct.CoordinateTransformationList[0].MathTransform, "", "", -1, "", ""); else return new CoordinateTransformation(source, target, TransformType.ConversionAndTransformation, ct, "", "", -1, "", ""); }
private static ICoordinateTransformation Geog2Geoc(IGeographicCoordinateSystem source, IGeocentricCoordinateSystem target) { return new CoordinateTransformation(source, target, TransformType.Conversion, CreateCoordinateOperation(target), 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, "", ""); }
public static void WriteGeocentricCoordinateSystem(IGeocentricCoordinateSystem geocentricCoordinateSystem, IndentedTextWriter writer) { throw new NotImplementedException(); }
private static IMathTransform CreateCoordinateOperation(IGeocentricCoordinateSystem geo) { var parameterList = new List<ProjectionParameter>(2); var ellipsoid = geo.HorizontalDatum.Ellipsoid; //var toMeter = ellipsoid.AxisUnit.MetersPerUnit; if (parameterList.Find((p) => p.Name.ToLowerInvariant().Replace(' ', '_').Equals("semi_major")) == null) parameterList.Add(new ProjectionParameter("semi_major", /*toMeter * */ellipsoid.SemiMajorAxis)); if (parameterList.Find((p) => p.Name.ToLowerInvariant().Replace(' ', '_').Equals("semi_minor")) == null) parameterList.Add(new ProjectionParameter("semi_minor", /*toMeter * */ellipsoid.SemiMinorAxis)); return new GeocentricTransform(parameterList); }
public void TestDatumTransform() { CoordinateSystemFactory cFac = new CoordinateSystemFactory(); //Define datums HorizontalDatum wgs72 = HorizontalDatum.WGS72; HorizontalDatum ed50 = HorizontalDatum.ED50; //Define geographic coordinate systems IGeographicCoordinateSystem gcsWGS72 = cFac.CreateGeographicCoordinateSystem("WGS72 Geographic", AngularUnit.Degrees, wgs72, PrimeMeridian.Greenwich, new AxisInfo("East", AxisOrientationEnum.East), new AxisInfo("North", AxisOrientationEnum.North)); IGeographicCoordinateSystem gcsWGS84 = cFac.CreateGeographicCoordinateSystem("WGS84 Geographic", AngularUnit.Degrees, HorizontalDatum.WGS84, PrimeMeridian.Greenwich, new AxisInfo("East", AxisOrientationEnum.East), new AxisInfo("North", AxisOrientationEnum.North)); IGeographicCoordinateSystem gcsED50 = cFac.CreateGeographicCoordinateSystem("ED50 Geographic", AngularUnit.Degrees, ed50, PrimeMeridian.Greenwich, new AxisInfo("East", AxisOrientationEnum.East), new AxisInfo("North", AxisOrientationEnum.North)); //Define geocentric coordinate systems IGeocentricCoordinateSystem gcenCsWGS72 = cFac.CreateGeocentricCoordinateSystem("WGS72 Geocentric", wgs72, LinearUnit.Metre, PrimeMeridian.Greenwich); IGeocentricCoordinateSystem gcenCsWGS84 = cFac.CreateGeocentricCoordinateSystem("WGS84 Geocentric", HorizontalDatum.WGS84, LinearUnit.Metre, PrimeMeridian.Greenwich); IGeocentricCoordinateSystem gcenCsED50 = cFac.CreateGeocentricCoordinateSystem("ED50 Geocentric", ed50, LinearUnit.Metre, PrimeMeridian.Greenwich); //Define projections List <ProjectionParameter> parameters = new List <ProjectionParameter>(5); parameters.Add(new ProjectionParameter("latitude_of_origin", 0)); parameters.Add(new ProjectionParameter("central_meridian", 9)); parameters.Add(new ProjectionParameter("scale_factor", 0.9996)); parameters.Add(new ProjectionParameter("false_easting", 500000)); parameters.Add(new ProjectionParameter("false_northing", 0)); IProjection projection = cFac.CreateProjection("Transverse Mercator", "Transverse_Mercator", parameters); IProjectedCoordinateSystem utmED50 = cFac.CreateProjectedCoordinateSystem("ED50 UTM Zone 32N", gcsED50, projection, LinearUnit.Metre, new AxisInfo("East", AxisOrientationEnum.East), new AxisInfo("North", AxisOrientationEnum.North)); IProjectedCoordinateSystem utmWGS84 = cFac.CreateProjectedCoordinateSystem("WGS84 UTM Zone 32N", gcsWGS84, projection, LinearUnit.Metre, new AxisInfo("East", AxisOrientationEnum.East), new AxisInfo("North", AxisOrientationEnum.North)); //Set TOWGS84 parameters wgs72.Wgs84Parameters = new Wgs84ConversionInfo(0, 0, 4.5, 0, 0, 0.554, 0.219); ed50.Wgs84Parameters = new Wgs84ConversionInfo(-81.0703, -89.3603, -115.7526, -0.48488, -0.02436, -0.41321, -0.540645); //Parameters for Denmark //Set up coordinate transformations CoordinateTransformationFactory ctFac = new CoordinateTransformationFactory(); ICoordinateTransformation ctForw = ctFac.CreateFromCoordinateSystems(gcsWGS72, gcenCsWGS72); //Geographic->Geocentric (WGS72) ICoordinateTransformation ctWGS84_Gcen2Geo = ctFac.CreateFromCoordinateSystems(gcenCsWGS84, gcsWGS84); //Geocentric->Geographic (WGS84) ICoordinateTransformation ctWGS84_Geo2UTM = ctFac.CreateFromCoordinateSystems(gcsWGS84, utmWGS84); //UTM ->Geographic (WGS84) ICoordinateTransformation ctED50_UTM2Geo = ctFac.CreateFromCoordinateSystems(utmED50, gcsED50); //UTM ->Geographic (ED50) ICoordinateTransformation ctED50_Geo2Gcen = ctFac.CreateFromCoordinateSystems(gcsED50, gcenCsED50); //Geographic->Geocentric (ED50) //Test datum-shift from WGS72 to WGS84 //Point3D pGeoCenWGS72 = ctForw.MathTransform.Transform(pLongLatWGS72) as Point3D; double[] pGeoCenWGS72 = new double[] { 3657660.66, 255768.55, 5201382.11 }; ICoordinateTransformation geocen_ed50_2_Wgs84 = ctFac.CreateFromCoordinateSystems(gcenCsWGS72, gcenCsWGS84); double[] pGeoCenWGS84 = geocen_ed50_2_Wgs84.MathTransform.Transform(pGeoCenWGS72); //Point3D pGeoCenWGS84 = wgs72.Wgs84Parameters.Apply(pGeoCenWGS72); Assert.IsTrue(ToleranceLessThan(new double[] { 3657660.78, 255778.43, 5201387.75 }, pGeoCenWGS84, 0.01)); ICoordinateTransformation utm_ed50_2_Wgs84 = ctFac.CreateFromCoordinateSystems(utmED50, utmWGS84); double[] pUTMED50 = new double[] { 600000, 6100000 }; double[] pUTMWGS84 = utm_ed50_2_Wgs84.MathTransform.Transform(pUTMED50); Assert.IsTrue(ToleranceLessThan(new double[] { 599928.6, 6099790.2 }, pUTMWGS84, 0.1)); //Perform reverse ICoordinateTransformation utm_Wgs84_2_Ed50 = ctFac.CreateFromCoordinateSystems(utmWGS84, utmED50); pUTMED50 = utm_Wgs84_2_Ed50.MathTransform.Transform(pUTMWGS84); Assert.IsTrue(ToleranceLessThan(new double[] { 600000, 6100000 }, pUTMED50, 0.1)); //Assert.IsTrue(Math.Abs((pUTMWGS84 as Point3D).Z - 36.35) < 0.5); //Point pExpected = Point.FromDMS(2, 7, 46.38, 53, 48, 33.82); //ED50_to_WGS84_Denmark: datum.Wgs84Parameters = new Wgs84ConversionInfo(-89.5, -93.8, 127.6, 0, 0, 4.5, 1.2); }
private int HashGeocentricCoordinateSystem(IGeocentricCoordinateSystem sys) { return(sys.HorizontalDatum.GetHashCode() ^ sys.PrimeMeridian.GetHashCode() ^ sys.Dimension.GetHashCode() ^ sys.LinearUnit.GetHashCode()); }