/// <summary> /// The inverse transform from linear units to geodetic units /// </summary> /// <param name="xy">The double values for the input x and y values stored in an array</param> /// <param name="lp">The double values for the output lambda and phi values stored in an array</param> protected override void OnInverse(double[] xy, double[] lp) { int i; double phipp = 2 * (Math.Atan(Math.Exp(xy[Y] / _kR)) - FortPi); double lampp = xy[X] / _kR; double cp = Math.Cos(phipp); double phip = Proj.Aasin(_cosp0 * Math.Sin(phipp) + _sinp0 * cp * Math.Cos(lampp)); double lamp = Proj.Aasin(cp * Math.Sin(lampp) / Math.Cos(phip)); double con = (_k - Math.Log(Math.Tan(FortPi + 0.5 * phip))) / _c; for (i = Niter; i > 0; --i) { double esp = E * Math.Sin(phip); double delp = (con + Math.Log(Math.Tan(FortPi + 0.5 * phip)) - _hlfE * Math.Log((1 + esp) / (1 - esp))) * (1 - esp * esp) * Math.Cos(phip) * ROneEs; phip -= delp; if (Math.Abs(delp) < EPS) { break; } } if (i <= 0) { throw new ProjectionException(20); } lp[Phi] = phip; lp[Lambda] = lamp / _c; }
/// <summary> /// The inverse transform from linear units to geodetic units /// </summary> /// <param name="xy">The double values for the input x and y values stored in an array</param> /// <param name="lp">The double values for the output lambda and phi values stored in an array</param> protected override void OnInverse(double[] xy, double[] lp) { lp[Phi] = Proj.Aasin(xy[Y] / _cY); lp[Lambda] = xy[X] / (_cX * Math.Cos(lp[Phi])); lp[Phi] += lp[Phi]; lp[Phi] = Proj.Aasin((lp[Phi] + Math.Sin(lp[Phi])) / _cP); }
/// <summary> /// The inverse transform from linear units to geodetic units /// </summary> /// <param name="xy">The double values for the input x and y values stored in an array</param> /// <param name="lp">The double values for the output lambda and phi values stored in an array</param> protected override void OnInverse(double[] xy, double[] lp) { double c; lp[Phi] = Proj.Aasin(xy[Y] / Cy); lp[Lambda] = xy[X] / (Cx * (1 + (c = Math.Cos(lp[Phi])))); lp[Phi] = Proj.Aasin((lp[Phi] + Math.Sin(lp[Phi]) * (c + 2)) / CP); }
/// <summary> /// Performs the inverse transform from a single coordinate of linear units to the same coordinate in geodetic lambda and /// phi units in the special case where the shape of the earth is being approximated as a perfect sphere. /// </summary> /// <param name="xy">The double linear input x and y values organized into a 1 dimensional array</param> /// <param name="lp">The double geodetic output lambda and phi values organized into a 1 dimensional array</param> protected override void SphericalInverse(double[] xy, double[] lp) { xy[Y] /= _cY; lp[Phi] = _m > 0 ? Proj.Aasin((_m * xy[Y] + Math.Sin(xy[Y])) / _n) : (_n != 1 ? Proj.Aasin(Math.Sin(xy[Y]) / _n) : xy[Y]); lp[Lambda] = xy[X] / (_cX * (_m + Math.Cos(xy[Y]))); }
/// <summary> /// The forward transform from geodetic units to linear units /// </summary> /// <param name="lp">The array of lambda, phi coordinates</param> /// <param name="xy">The array of x, y coordinates</param> protected override void OnForward(double[] lp, double[] xy) { double sp = E * Math.Sin(lp[Phi]); double phip = 2 * Math.Atan(Math.Exp(_c * ( Math.Log(Math.Tan(FortPi + 0.5 * lp[Phi])) - _hlfE * Math.Log((1 + sp) / (1 - sp))) + _k)) - HalfPi; double lamp = _c * lp[Lambda]; double cp = Math.Cos(phip); double phipp = Proj.Aasin(_cosp0 * Math.Sin(phip) - _sinp0 * cp * Math.Cos(lamp)); double lampp = Proj.Aasin(cp * Math.Sin(lamp) / Math.Cos(phipp)); xy[X] = _kR * lampp; xy[Y] = _kR * Math.Log(Math.Tan(FortPi + 0.5 * phipp)); }
/// <summary> /// Performs the inverse transfrom from a single coordinate of linear units to the same coordinate in geodetic units /// </summary> /// <param name="xy">The double linear input x and y values organized into a 1 dimensional array</param> /// <param name="lp">The double geodetic output lambda and phi values organized into a 1 dimensional array</param> protected override void EllipticalInverse(double[] xy, double[] lp) { if (_isGuam) { GuamInverse(xy, lp); } double c; if ((c = Proj.Hypot(xy[X], xy[Y])) < EPS10) { lp[Phi] = Phi0; lp[Lambda] = 0; return; } if (_mode == Modes.Oblique || _mode == Modes.Equitorial) { double az; double cosAz = Math.Cos(az = Math.Atan2(xy[X], xy[Y])); double t = _cosph0 * cosAz; double b = Es * t / OneEs; double a = -b * t; b *= 3 * (1 - a) * _sinph0; double d = c / _N1; double e = d * (1 - d * d * (a * (1 + a) / 6 + b * (1 + 3 * a) * d / 24)); double f = 1 - e * e * (a / 2 + b * e / 6); double psi = Proj.Aasin(_sinph0 * Math.Cos(e) + t * Math.Sin(e)); lp[Lambda] = Proj.Aasin(Math.Sin(az) * Math.Sin(e) / Math.Cos(psi)); if ((t = Math.Abs(psi)) < EPS10) { lp[Phi] = 0; } else if (Math.Abs(t - HalfPi) < 0) { lp[Phi] = HalfPi; } else { lp[Phi] = Math.Atan((1 - Es * f * _sinph0 / Math.Sin(psi)) * Math.Tan(psi) / OneEs); } } else { /* Polar */ lp[Phi] = Proj.InvMlfn(_mode == Modes.NorthPole ? _Mp - c : _Mp + c, Es, _en); lp[Lambda] = Math.Atan2(xy[X], _mode == Modes.NorthPole ? -xy[Y] : xy[Y]); } }
/// <summary> /// Performs the inverse transform from a single coordinate of linear units to the same coordinate in geodetic lambda and /// phi units in the special case where the shape of the earth is being approximated as a perfect sphere. /// </summary> /// <param name="xy">The double linear input x and y values organized into a 1 dimensional array</param> /// <param name="lp">The double geodetic output lambda and phi values organized into a 1 dimensional array</param> protected override void SphericalInverse(double[] xy, double[] lp) { double cRh; if ((cRh = Proj.Hypot(xy[X], xy[Y])) > Math.PI) { if (cRh - EPS10 > Math.PI) { throw new ProjectionException(20); } cRh = Math.PI; } else if (cRh < EPS10) { lp[Phi] = Phi0; lp[Lambda] = 0; return; } if (_mode == Modes.Oblique || _mode == Modes.Equitorial) { double sinc = Math.Sin(cRh); double cosc = Math.Cos(cRh); if (_mode == Modes.Equitorial) { lp[Phi] = Proj.Aasin(xy[Y] * sinc / cRh); xy[X] *= sinc; xy[Y] = cosc * cRh; } else { lp[Phi] = Proj.Aasin(cosc * _sinph0 + xy[Y] * sinc * _cosph0 / cRh); xy[Y] = (cosc - _sinph0 * Math.Sin(lp[Phi])) * cRh; xy[X] *= sinc * _cosph0; } lp[Lambda] = xy[Y] == 0 ? 0 : Math.Atan2(xy[X], xy[Y]); } else if (_mode == Modes.NorthPole) { lp[Phi] = HalfPi - cRh; lp[Lambda] = Math.Atan2(xy[X], -xy[Y]); } else { lp[Phi] = cRh - HalfPi; lp[Lambda] = Math.Atan2(xy[X], xy[Y]); } }
/// <summary> /// The inverse transform from linear units to geodetic units /// </summary> /// <param name="xy">The double values for the input x and y values stored in an array</param> /// <param name="lp">The double values for the output lambda and phi values stored in an array</param> protected override void OnInverse(double[] xy, double[] lp) { xy[Y] /= _cY; double c = Math.Cos(lp[Phi] = _tanMode ? Math.Atan(xy[Y]) : Proj.Aasin(xy[Y])); lp[Phi] /= _cP; lp[Lambda] = xy[X] / (_cX * Math.Cos(lp[Phi] /= _cP)); if (_tanMode) { lp[Lambda] /= c * c; } else { lp[Lambda] *= c; } }
/// <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 phip0; _hlfE = 0.5 * E; double cp = Math.Cos(Phi0); cp *= cp; _c = Math.Sqrt(1 + Es * cp * cp * ROneEs); double sp = Math.Sin(Phi0); _cosp0 = Math.Cos(phip0 = Proj.Aasin(_sinp0 = sp / _c)); sp *= E; _k = Math.Log(Math.Tan(FortPi + 0.5 * phip0)) - _c * ( Math.Log(Math.Tan(FortPi + 0.5 * Phi0)) - _hlfE * Math.Log((1 + sp) / (1 - sp))); _kR = K0 * Math.Sqrt(OneEs) / (1 - sp * sp); }
/// <summary> /// The inverse transform from linear units to geodetic units /// </summary> /// <param name="xy">The double values for the input x and y values stored in an array</param> /// <param name="lp">The double values for the output lambda and phi values stored in an array</param> protected override void OnInverse(double[] xy, double[] lp) { double cz1 = Math.Cos(Proj.Hypot(xy[Y], xy[X] + _hz0)); double cz2 = Math.Cos(Proj.Hypot(xy[Y], xy[X] - _hz0)); double s = cz1 + cz2; double d = cz1 - cz2; lp[Lambda] = -Math.Atan2(d, (s * _thz0)); lp[Phi] = Proj.Aacos(Proj.Hypot(_thz0 * s, d) * _rhshz0); if (xy[Y] < 0) { lp[Phi] = -lp[Phi]; } /* lam--phi now in system relative to P1--P2 base equator */ double sp = Math.Sin(lp[Phi]); double cp = Math.Cos(lp[Phi]); lp[Phi] = Proj.Aasin(_sa * sp + _ca * cp * (s = Math.Cos(lp[Lambda] -= _lp))); lp[Lambda] = Math.Atan2(cp * Math.Sin(lp[Lambda]), _sa * cp * s - _ca * sp) + _lamc; }
/// <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 pp; /* get control point locations */ double phi1 = projInfo.GetPhi1(); double lam1 = projInfo.GetLam1(); double phi2 = projInfo.GetPhi2(); double lam2 = projInfo.GetLam2(); if (phi1 == phi2 && lam1 == lam2) { throw new ProjectionException(-25); } Lam0 = Proj.Adjlon(0.5 * (lam1 + lam2)); _dlam2 = Proj.Adjlon(lam2 - lam1); _cp1 = Math.Cos(phi1); _cp2 = Math.Cos(phi2); _sp1 = Math.Sin(phi1); _sp2 = Math.Sin(phi2); _cs = _cp1 * _sp2; _sc = _sp1 * _cp2; _ccs = _cp1 * _cp2 * Math.Sin(_dlam2); _z02 = Proj.Aacos(_sp1 * _sp2 + _cp1 * _cp2 * Math.Cos(_dlam2)); _hz0 = .5 * _z02; double A12 = Math.Atan2(_cp2 * Math.Sin(_dlam2), _cp1 * _sp2 - _sp1 * _cp2 * Math.Cos(_dlam2)); _ca = Math.Cos(pp = Proj.Aasin(_cp1 * Math.Sin(A12))); _sa = Math.Sin(pp); _lp = Proj.Adjlon(Math.Atan2(_cp1 * Math.Cos(A12), _sp1) - _hz0); _dlam2 *= .5; _lamc = HalfPi - Math.Atan2(Math.Sin(A12) * _sp1, Math.Cos(A12)) - _dlam2; _thz0 = Math.Tan(_hz0); _rhshz0 = .5 / Math.Sin(_hz0); _r2z0 = 0.5 / _z02; _z02 *= _z02; }