public void Write(Helmert7Transformation helmert) { if (helmert == null) { throw new ArgumentNullException("helmert"); } Contract.EndContractBlock(); Write(WktKeyword.ToWgs84); WriteOpenParenthesis(); WriteValue(helmert.Delta.X); WriteComma(); WriteValue(helmert.Delta.Y); WriteComma(); WriteValue(helmert.Delta.Z); WriteComma(); WriteValue(helmert.RotationArcSeconds.X); WriteComma(); WriteValue(helmert.RotationArcSeconds.Y); WriteComma(); WriteValue(helmert.RotationArcSeconds.Z); WriteComma(); WriteValue(helmert.ScaleDeltaPartsPerMillion); WriteCloseParenthesis(); }
public IDatumGeodetic ReadHorizontalDatumFromParams() { Contract.Ensures(Contract.Result <IDatumGeodetic>() != null); IAuthorityTag authority = null; var name = String.Empty; ISpheroidInfo spheroid = null; Helmert7Transformation toWgs84 = null; IPrimeMeridianInfo primeMeridian = null; foreach (var parameter in ReadParams()) { if (parameter is IAuthorityTag) { authority = (IAuthorityTag)parameter; } else if (parameter is string) { name = (string)parameter; } else if (parameter is ISpheroidInfo) { spheroid = (ISpheroidInfo)parameter; } else if (parameter is Helmert7Transformation) { toWgs84 = (Helmert7Transformation)parameter; } else if (parameter is IPrimeMeridianInfo) { primeMeridian = (IPrimeMeridianInfo)parameter; // NOTE: this may not happen due to the spec... but just in case? } } if (null != authority) { var datum = Options.GetDatum(authority) as IDatumGeodetic; if (null != datum) { return(datum); } } if (spheroid == null) { if (Options.ThrowOnError) { throw new WktParseExceptioncs("Horizontal Datum", "No spheroid."); } spheroid = OgcSpheroid.DefaultWgs84; } return(new OgcDatumHorizontal( name, spheroid, primeMeridian, toWgs84, authority )); }
private static StaticCoordinateOperationCompiler.StepCompilationResult CreateCoordinateFrameRotationTransformation(TransformationCompilationParams opData) { Contract.Requires(opData != null); Vector3 translation, rotation; double scale; if (!ExtractHelmertParams(opData, out translation, out rotation, out scale)) { return(null); } return(CreateHelmertStep(opData, Helmert7Transformation.CreateCoordinateFrameRotationFormat(translation, rotation, scale))); }
static Proj4Datum() { DefaultDatums = Array.AsReadOnly(new[] { new Proj4Datum("WGS84", Proj4Spheroid.GetSpheroid("WGS84"), Helmert7Transformation.IdentityTransformation), new Proj4Datum( "GGRS87", Proj4Spheroid.GetSpheroid("GRS80"), new Helmert7Transformation(new Vector3(-199.87, 74.79, 246.62)) ), new Proj4Datum( "NAD83", Proj4Spheroid.GetSpheroid("GRS80"), Helmert7Transformation.IdentityTransformation, matchExplicitly: true ), new Proj4Datum( "NAD27", Proj4Spheroid.GetSpheroid("clrk66"), null, matchExplicitly: true ), new Proj4Datum( "potsdam", Proj4Spheroid.GetSpheroid("bessel"), new Helmert7Transformation(new Vector3(606.0, 23.0, 413.0)) ), new Proj4Datum( "carthage", Proj4Spheroid.GetSpheroid("clrk80"), new Helmert7Transformation(new Vector3(-263.0, 6.0, 431.0)) ), new Proj4Datum( "hermannskogel", Proj4Spheroid.GetSpheroid("bessel"), new Helmert7Transformation(new Vector3(653.0, -212.0, 449.0)) ), new Proj4Datum( "ire65", Proj4Spheroid.GetSpheroid("mod_airy"), Helmert7Transformation.CreatePositionVectorFormat(new Vector3(482.530, -130.596, 564.557), new Vector3(-1.042, -0.214, -0.631), 8.15) ), new Proj4Datum( "nzgd49", Proj4Spheroid.GetSpheroid("intl"), Helmert7Transformation.CreatePositionVectorFormat(new Vector3(59.47, -5.04, 187.44), new Vector3(0.47, -0.1, 1.024), -4.5993), supported: false, matchExplicitly: true ), new Proj4Datum( "OSGB36", Proj4Spheroid.GetSpheroid("airy"), Helmert7Transformation.CreatePositionVectorFormat(new Vector3(446.448, -125.157, 542.060), new Vector3(0.1502, 0.2470, 0.8421), -20.4894), supported: false ) }); }
/// <summary> /// Constructs a horizontal datum. /// </summary> /// <param name="name">The name.</param> /// <param name="spheroid">The spheroid of the datum.</param> /// <param name="primeMeridian">The prime meridian of the datum.</param> /// <param name="transform">The transformation for conversions to WGS84.</param> /// <param name="authority">The authority.</param> public OgcDatumHorizontal( string name, ISpheroidInfo spheroid, IPrimeMeridianInfo primeMeridian, Helmert7Transformation transform, IAuthorityTag authority = null ) : base(name, OgcDatumType.None, authority) { if (null == spheroid) throw new ArgumentNullException("spheroid"); Contract.Requires(name != null); Spheroid = spheroid; PrimeMeridian = primeMeridian; BasicWgs84Transformation = transform; }
/// <summary> /// Constructs a new Proj4 datum object. /// </summary> /// <param name="name">The Proj4 datum name.</param> /// <param name="spheroid">The ellipse for this datum.</param> /// <param name="toWgs84">A transformation to WGS84.</param> /// <param name="supported">Indicates if this datum is supported by Proj4.</param> /// <param name="matchExplicitly">Indicated is this datum must be matched explicitly by name only.</param> private Proj4Datum( string name, Proj4Spheroid spheroid, Helmert7Transformation toWgs84, bool supported = true, bool matchExplicitly = false ) { Contract.Requires(!String.IsNullOrEmpty(name)); Name = name; _spheroid = spheroid; _toWgs84 = toWgs84; _supported = supported; _matchExplicitly = matchExplicitly; }
private bool ComputationallyEqual(Helmert7Transformation a, Helmert7Transformation b) { if (a == b) { return(true); } if (a == null || b == null) { return(false); } return(a.Equals(b)); throw new NotImplementedException(); }
public void EpsgExample2432InverseTest() { var wgs72 = new Point3(3657660.66, 255768.55, 5201382.11); var wgs84 = new Point3(3657660.78, 255778.43, 5201387.75); var transform = Helmert7Transformation.CreateCoordinateFrameRotationFormat( new Vector3(0, 0, 4.5), new Vector3(0, 0, 0.000002685868), 0.219 ); var result = transform.GetInverse().TransformValue(wgs84); Assert.AreEqual(wgs72.X, result.X, 0.7); Assert.AreEqual(wgs72.Y, result.Y, 10); Assert.AreEqual(wgs72.Z, result.Z, 0.0009); }
/// <summary> /// Constructs a horizontal datum. /// </summary> /// <param name="name">The name.</param> /// <param name="spheroid">The spheroid of the datum.</param> /// <param name="primeMeridian">The prime meridian of the datum.</param> /// <param name="transform">The transformation for conversions to WGS84.</param> /// <param name="authority">The authority.</param> public OgcDatumHorizontal( string name, ISpheroidInfo spheroid, IPrimeMeridianInfo primeMeridian, Helmert7Transformation transform, IAuthorityTag authority = null ) : base(name, OgcDatumType.None, authority) { if (null == spheroid) { throw new ArgumentNullException("spheroid"); } Contract.Requires(name != null); Spheroid = spheroid; PrimeMeridian = primeMeridian; BasicWgs84Transformation = transform; }
private static StaticCoordinateOperationCompiler.StepCompilationResult CreateHelmertStep(TransformationCompilationParams opData, Helmert7Transformation helmert) { Contract.Requires(opData != null); Contract.Requires(helmert != null); if (opData.StepParams.RelatedInputCrs is ICrsGeocentric && opData.StepParams.RelatedOutputCrs is ICrsGeocentric) { return(new StaticCoordinateOperationCompiler.StepCompilationResult( opData.StepParams, opData.StepParams.RelatedOutputCrsUnit ?? opData.StepParams.RelatedInputCrsUnit ?? opData.StepParams.InputUnit, helmert)); } var spheroidFrom = ExtractSpheroid(opData.StepParams.RelatedInputCrs) ?? ExtractSpheroid(opData.StepParams.RelatedOutputCrs); if (null == spheroidFrom) { return(null); } var spheroidTo = ExtractSpheroid(opData.StepParams.RelatedOutputCrs) ?? spheroidFrom; ITransformation transformation = new GeocentricTransformationGeographicWrapper(spheroidFrom, spheroidTo, helmert); var unitConversion = StaticCoordinateOperationCompiler.CreateCoordinateUnitConversion(opData.StepParams.InputUnit, OgcAngularUnit.DefaultRadians); if (null != unitConversion) { transformation = new ConcatenatedTransformation(new[] { unitConversion, transformation }); } return(new StaticCoordinateOperationCompiler.StepCompilationResult( opData.StepParams, OgcAngularUnit.DefaultRadians, transformation)); }
private static StaticCoordinateOperationCompiler.StepCompilationResult CreateHelmertStep(TransformationCompilationParams opData, Helmert7Transformation helmert) { Contract.Requires(opData != null); Contract.Requires(helmert != null); if (opData.StepParams.RelatedInputCrs is ICrsGeocentric && opData.StepParams.RelatedOutputCrs is ICrsGeocentric) return new StaticCoordinateOperationCompiler.StepCompilationResult( opData.StepParams, opData.StepParams.RelatedOutputCrsUnit ?? opData.StepParams.RelatedInputCrsUnit ?? opData.StepParams.InputUnit, helmert); var spheroidFrom = ExtractSpheroid(opData.StepParams.RelatedInputCrs) ?? ExtractSpheroid(opData.StepParams.RelatedOutputCrs); if (null == spheroidFrom) return null; var spheroidTo = ExtractSpheroid(opData.StepParams.RelatedOutputCrs) ?? spheroidFrom; ITransformation transformation = new GeocentricTransformationGeographicWrapper(spheroidFrom, spheroidTo, helmert); var unitConversion = StaticCoordinateOperationCompiler.CreateCoordinateUnitConversion(opData.StepParams.InputUnit, OgcAngularUnit.DefaultRadians); if (null != unitConversion) transformation = new ConcatenatedTransformation(new[] { unitConversion, transformation }); return new StaticCoordinateOperationCompiler.StepCompilationResult( opData.StepParams, OgcAngularUnit.DefaultRadians, transformation); }