/// <summary> /// Initializes the transform using the parameters from the specified coordinate system information /// </summary> /// <param name="projInfo">A ProjectionInfo class contains all the standard and custom parameters needed to initialize this transform</param> protected override void OnInit(ProjectionInfo projInfo) { Phi0 = projInfo.GetPhi0(); if (Math.Abs(Math.Abs(Phi0) - HalfPi) < EPS10) { _mode = Phi0 < 0 ? Modes.SouthPole : Modes.NorthPole; _sinph0 = Phi0 < 0 ? -1: 1; _cosph0 = 0; } else if (Math.Abs(Phi0) < EPS10) { _mode = Modes.Equitorial; _sinph0 = 0; _cosph0 = 1; } else { _mode = Modes.Oblique; _sinph0 = Math.Sin(Phi0); _cosph0 = Math.Cos(Phi0); } if (Es == 0) { return; } _en = Proj.Enfn(Es); if (projInfo.Parameters.ContainsKey("guam")) { _M1 = Proj.Mlfn(Phi0, _sinph0, _cosph0, _en); _isGuam = true; } else { switch (_mode) { case Modes.NorthPole: _Mp = Proj.Mlfn(HalfPi, 1, 0, _en); break; case Modes.SouthPole: _Mp = Proj.Mlfn(-HalfPi, -1, 0, _en); break; case Modes.Equitorial: case Modes.Oblique: _N1 = 1 / Math.Sqrt(1 - Es * _sinph0 * _sinph0); _g = _sinph0 * (_He = E / Math.Sqrt(OneEs)); _He *= _cosph0; break; } } }
/// <summary> /// Initializes the parameters from the projection info /// </summary> /// <param name="proj">The projection information used to control this transform</param> public void Init(ProjectionInfo proj) { // Setup protected values common to all the projections that inherit from this projection Es = proj.GeographicInfo.Datum.Spheroid.EccentricitySquared(); if (proj.LatitudeOfOrigin != null) { Phi0 = proj.GetPhi0(); } if (proj.CentralMeridian != null) { Lam0 = proj.GetLam0(); } if (proj.FalseEasting != null) { X0 = proj.FalseEasting.Value; } if (proj.FalseNorthing != null) { Y0 = proj.FalseNorthing.Value; } K0 = proj.ScaleFactor; A = proj.GeographicInfo.Datum.Spheroid.EquatorialRadius; E = proj.GeographicInfo.Datum.Spheroid.Eccentricity(); Ra = 1 / A; OneEs = 1 - Es; ROneEs = 1 / OneEs; ToMeter = 1; FromMeter = 1; //_datumParams = proj.GeographicInfo.Datum.ToWGS84; if (proj.Unit != null) { ToMeter = proj.Unit.Meters; FromMeter = 1 / proj.Unit.Meters; } if (Es != 0) { IsElliptical = true; } OnInit(proj); }
/// <summary> /// Initializes the transform using the parameters from the specified coordinate system information /// </summary> /// <param name="projInfo">A ProjectionInfo class contains all the standard and custom parameters needed to initialize this transform</param> protected override void OnInit(ProjectionInfo projInfo) { /* read some Parameters, * here Latitude Truescale */ double ts = 0; if (projInfo.StandardParallel1 != null) { ts = projInfo.StandardParallel1.Value * Math.PI / 180; } _C_x = ts; /* we want Bessel as fixed ellipsoid */ A = 6377397.155; E = Math.Sqrt(Es = 0.006674372230614); /* if latitude of projection center is not set, use 49d30'N */ Phi0 = projInfo.LatitudeOfOrigin != null?projInfo.GetPhi0() : 0.863937979737193; /* if center long is not set use 42d30'E of Ferro - 17d40' for Ferro */ /* that will correspond to using longitudes relative to greenwich */ /* as input and output, instead of lat/long relative to Ferro */ Lam0 = projInfo.CentralMeridian != null?projInfo.GetLam0() : 0.7417649320975901 - 0.308341501185665; /* if scale not set default to 0.9999 */ K0 = projInfo.CentralMeridian != null?projInfo.GetLam0() : 0.9999; if (!projInfo.Parameters.ContainsKey("czech")) { return; } int temp = projInfo.ParamI("czech"); if (temp != 0) { _czech = true; } }
/// <summary> /// Initializes the transform using the parameters from the specified coordinate system information /// </summary> /// <param name="projInfo">A ProjectionInfo class contains all the standard and custom parameters needed to initialize this transform</param> protected override void OnInit(ProjectionInfo projInfo) { double sinphi; double degreesToRadians = projInfo.GeographicInfo.Unit.Radians; _phi1 = projInfo.GetPhi1(); if (projInfo.StandardParallel2 != null) { _phi2 = projInfo.GetPhi2(); } else { _phi2 = _phi1; _phi1 = projInfo.GetPhi0(); } if (Math.Abs(_phi1 + _phi2) < EPS10) { throw new ProjectionException(21); } _n = sinphi = Math.Sin(_phi1); double cosphi = Math.Cos(_phi1); bool secant = Math.Abs(_phi1 - _phi2) >= EPS10; _ellipse = projInfo.GeographicInfo.Datum.Spheroid.IsOblate(); if (_ellipse) { double m1 = Proj.Msfn(sinphi, cosphi, Es); double ml1 = Proj.Tsfn(_phi1, sinphi, E); if (secant) { sinphi = Math.Sin(_phi2); _n = Math.Log(m1 / Proj.Msfn(sinphi, Math.Cos(_phi2), Es)); _n = _n / Math.Log(ml1 / Proj.Tsfn(_phi2, sinphi, E)); } _rho0 = m1 * Math.Pow(ml1, -_n) / _n; _c = _rho0; if (Math.Abs(Math.Abs(Phi0) - HalfPi) < EPS10) { _rho0 = 0; } else { _rho0 *= Math.Pow(Proj.Tsfn(Phi0, Math.Sin(Phi0), E), _n); } } else { if (secant) { _n = Math.Log(cosphi / Math.Cos(_phi2)) / Math.Log(Math.Tan(Math.PI / 4 + .5 * _phi2) / Math.Tan(Math.PI / 4 + .5 * _phi1)); _c = cosphi * Math.Pow(Math.Tan(Math.PI / 4 + .5 * _phi1), _n) / _n; } if (Math.Abs(Math.Abs(Phi0) - HalfPi) < EPS10) { _rho0 = 0; } else { _rho0 = _c * Math.Pow(Math.Tan(Math.PI / 4 + .5 * Phi0), -_n); } } }