void setup_cea(Parameters& par, par_cea& proj_parm) { double t = 0; if (pj_param(par.params, "tlat_ts").i && (par.k0 = cos(t = pj_param(par.params, "rlat_ts").f)) < 0.) throw proj_exception(-24); if (par.es) { t = sin(t); par.k0 /= sqrt(1. - par.es * t * t); par.e = sqrt(par.es); if (!pj_authset(par.es, proj_parm.apa)) throw proj_exception(0); proj_parm.qp = pj_qsfn(1., par.e, par.one_es); } else { } }
inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const { double phip, lamp, phipp, lampp, cp, esp, con, delp; int i; phipp = 2. * (atan(exp(xy_y / this->m_proj_parm.kR)) - FORTPI); lampp = xy_x / this->m_proj_parm.kR; cp = cos(phipp); phip = aasin(this->m_proj_parm.cosp0 * sin(phipp) + this->m_proj_parm.sinp0 * cp * cos(lampp)); lamp = aasin(cp * sin(lampp) / cos(phip)); con = (this->m_proj_parm.K - log(tan(FORTPI + 0.5 * phip)))/this->m_proj_parm.c; for (i = NITER; i ; --i) { esp = this->m_par.e * sin(phip); delp = (con + log(tan(FORTPI + 0.5 * phip)) - this->m_proj_parm.hlf_e * log((1. + esp)/(1. - esp)) ) * (1. - esp * esp) * cos(phip) * this->m_par.rone_es; phip -= delp; if (fabs(delp) < EPS) break; } if (i) { lp_lat = phip; lp_lon = lamp / this->m_proj_parm.c; } else throw proj_exception(); }
void setup_eqdc(Parameters& par, par_eqdc& proj_parm) { double cosphi, sinphi; int secant; proj_parm.phi1 = pj_param(par.params, "rlat_1").f; proj_parm.phi2 = pj_param(par.params, "rlat_2").f; if (fabs(proj_parm.phi1 + proj_parm.phi2) < EPS10) throw proj_exception(-21); pj_enfn(par.es, proj_parm.en); proj_parm.n = sinphi = sin(proj_parm.phi1); cosphi = cos(proj_parm.phi1); secant = fabs(proj_parm.phi1 - proj_parm.phi2) >= EPS10; if( (proj_parm.ellips = (par.es > 0.)) ) { double ml1, m1; m1 = pj_msfn(sinphi, cosphi, par.es); ml1 = pj_mlfn(proj_parm.phi1, sinphi, cosphi, proj_parm.en); if (secant) { /* secant cone */ sinphi = sin(proj_parm.phi2); cosphi = cos(proj_parm.phi2); proj_parm.n = (m1 - pj_msfn(sinphi, cosphi, par.es)) / (pj_mlfn(proj_parm.phi2, sinphi, cosphi, proj_parm.en) - ml1); } proj_parm.c = ml1 + m1 / proj_parm.n; proj_parm.rho0 = proj_parm.c - pj_mlfn(par.phi0, sin(par.phi0), cos(par.phi0), proj_parm.en); } else { if (secant) proj_parm.n = (cosphi - cos(proj_parm.phi2)) / (proj_parm.phi2 - proj_parm.phi1); proj_parm.c = proj_parm.phi1 + cos(proj_parm.phi1) / proj_parm.n; proj_parm.rho0 = proj_parm.c - par.phi0; } // par.inv = e_inverse; // par.fwd = e_forward; // par.spc = fac; }
inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const { double cosz=0.0, rh, sinz=0.0; rh = boost::math::hypot(xy_x, xy_y); if ((lp_lat = rh * .5 ) > 1.) throw proj_exception();; lp_lat = 2. * asin(lp_lat); if (this->m_proj_parm.mode == OBLIQ || this->m_proj_parm.mode == EQUIT) { sinz = sin(lp_lat); cosz = cos(lp_lat); } switch (this->m_proj_parm.mode) { case EQUIT: lp_lat = fabs(rh) <= EPS10 ? 0. : asin(xy_y * sinz / rh); xy_x *= sinz; xy_y = cosz * rh; break; case OBLIQ: lp_lat = fabs(rh) <= EPS10 ? this->m_par.phi0 : asin(cosz * this->m_proj_parm.sinb1 + xy_y * sinz * this->m_proj_parm.cosb1 / rh); xy_x *= sinz * this->m_proj_parm.cosb1; xy_y = (cosz - sin(lp_lat) * this->m_proj_parm.sinb1) * rh; break; case N_POLE: xy_y = -xy_y; lp_lat = HALFPI - lp_lat; break; case S_POLE: lp_lat -= HALFPI; break; } lp_lon = (xy_y == 0. && (this->m_proj_parm.mode == EQUIT || this->m_proj_parm.mode == OBLIQ)) ? 0. : atan2(xy_x, xy_y); }
void setup_tpeqd(Parameters& par, par_tpeqd& proj_parm) { double lam_1, lam_2, phi_1, phi_2, A12, pp; /* get control point locations */ phi_1 = pj_param(par.params, "rlat_1").f; lam_1 = pj_param(par.params, "rlon_1").f; phi_2 = pj_param(par.params, "rlat_2").f; lam_2 = pj_param(par.params, "rlon_2").f; if (phi_1 == phi_2 && lam_1 == lam_2) throw proj_exception(-25); par.lam0 = adjlon(0.5 * (lam_1 + lam_2)); proj_parm.dlam2 = adjlon(lam_2 - lam_1); proj_parm.cp1 = cos(phi_1); proj_parm.cp2 = cos(phi_2); proj_parm.sp1 = sin(phi_1); proj_parm.sp2 = sin(phi_2); proj_parm.cs = proj_parm.cp1 * proj_parm.sp2; proj_parm.sc = proj_parm.sp1 * proj_parm.cp2; proj_parm.ccs = proj_parm.cp1 * proj_parm.cp2 * sin(proj_parm.dlam2); proj_parm.z02 = aacos(proj_parm.sp1 * proj_parm.sp2 + proj_parm.cp1 * proj_parm.cp2 * cos(proj_parm.dlam2)); proj_parm.hz0 = .5 * proj_parm.z02; A12 = atan2(proj_parm.cp2 * sin(proj_parm.dlam2), proj_parm.cp1 * proj_parm.sp2 - proj_parm.sp1 * proj_parm.cp2 * cos(proj_parm.dlam2)); proj_parm.ca = cos(pp = aasin(proj_parm.cp1 * sin(A12))); proj_parm.sa = sin(pp); proj_parm.lp = adjlon(atan2(proj_parm.cp1 * cos(A12), proj_parm.sp1) - proj_parm.hz0); proj_parm.dlam2 *= .5; proj_parm.lamc = HALFPI - atan2(sin(A12) * proj_parm.sp1, cos(A12)) - proj_parm.dlam2; proj_parm.thz0 = tan(proj_parm.hz0); proj_parm.rhshz0 = .5 / sin(proj_parm.hz0); proj_parm.r2z0 = 0.5 / proj_parm.z02; proj_parm.z02 *= proj_parm.z02; // par.inv = s_inverse; // par.fwd = s_forward; par.es = 0.; }
inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const { double t, c0, c1, c2, c3, al, r2, r, m, d, ay, x2, y2; x2 = xy_x * xy_x; if ((ay = fabs(xy_y)) < TOL) { lp_lat = 0.; t = x2 * x2 + TPISQ * (x2 + HPISQ); lp_lon = fabs(xy_x) <= TOL ? 0. : .5 * (x2 - PISQ + sqrt(t)) / xy_x; return; } y2 = xy_y * xy_y; r = x2 + y2; r2 = r * r; c1 = - PI * ay * (r + PISQ); c3 = r2 + TWOPI * (ay * r + PI * (y2 + PI * (ay + HALFPI))); c2 = c1 + PISQ * (r - 3. * y2); c0 = PI * ay; c2 /= c3; al = c1 / c3 - THIRD * c2 * c2; m = 2. * sqrt(-THIRD * al); d = C2_27 * c2 * c2 * c2 + (c0 * c0 - THIRD * c2 * c1) / c3; if (((t = fabs(d = 3. * d / (al * m))) - TOL) <= 1.) { d = t > 1. ? (d > 0. ? 0. : PI) : acos(d); lp_lat = PI * (m * cos(d * THIRD + PI4_3) - THIRD * c2); if (xy_y < 0.) lp_lat = -lp_lat; t = r2 + TPISQ * (x2 - y2 + HPISQ); lp_lon = fabs(xy_x) <= TOL ? 0. : .5 * (r - PISQ + (t <= 0. ? 0. : sqrt(t))) / xy_x; } else throw proj_exception();; }
void setup_loxim(Parameters& par, par_loxim& proj_parm) { proj_parm.phi1 = pj_param(par.params, "rlat_1").f; if ((proj_parm.cosphi1 = cos(proj_parm.phi1)) < EPS) throw proj_exception(-22); proj_parm.tanphi1 = tan(FORTPI + 0.5 * proj_parm.phi1); // par.inv = s_inverse; // par.fwd = s_forward; par.es = 0.; }
void setup_gn_sinu(Parameters& par, par_gn_sinu& proj_parm) { if (pj_param(par.params, "tn").i && pj_param(par.params, "tm").i) { proj_parm.n = pj_param(par.params, "dn").f; proj_parm.m = pj_param(par.params, "dm").f; } else throw proj_exception(-99); setup(par, proj_parm); }
inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const { double sinlam, coslam, cosphi, sinphi, t, s, Krho, cosz; sinlam = sin(lp_lon); coslam = cos(lp_lon); switch (this->m_proj_parm.mode) { case EQUIT: case OBLIQ: sinphi = sin(lp_lat); cosphi = cos(lp_lat); cosz = cosphi * coslam; if (this->m_proj_parm.mode == OBLIQ) cosz = this->m_proj_parm.sinph0 * sinphi + this->m_proj_parm.cosph0 * cosz; if (!this->m_proj_parm.no_cut && cosz < -EPS) throw proj_exception();; if (fabs(s = 1. - cosz) > EPS) { t = 0.5 * (1. + cosz); Krho = -log(t)/s - this->m_proj_parm.Cb / t; } else Krho = 0.5 - this->m_proj_parm.Cb; xy_x = Krho * cosphi * sinlam; if (this->m_proj_parm.mode == OBLIQ) xy_y = Krho * (this->m_proj_parm.cosph0 * sinphi - this->m_proj_parm.sinph0 * cosphi * coslam); else xy_y = Krho * sinphi; break; case S_POLE: case N_POLE: lp_lat = fabs(this->m_proj_parm.p_halfpi - lp_lat); if (!this->m_proj_parm.no_cut && (lp_lat - EPS) > HALFPI) throw proj_exception();; if ((lp_lat *= 0.5) > EPS) { t = tan(lp_lat); Krho = -2.*(log(cos(lp_lat)) / t + t * this->m_proj_parm.Cb); xy_x = Krho * sinlam; xy_y = Krho * coslam; if (this->m_proj_parm.mode == N_POLE) xy_y = -xy_y; } else xy_x = xy_y = 0.; } }
inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const { double th; th = xy_y * ( xy_y < 0. ? RYCS : RYCN); if (fabs(th) > 1.) if (fabs(th) > ONETOL) throw proj_exception(); else th = th > 0. ? HALFPI : - HALFPI; else th = asin(th); lp_lon = RXC * xy_x / cos(th); th += th; lp_lat = (th + sin(th)) * (xy_y < 0. ? RCS : RCN); if (fabs(lp_lat) > 1.) if (fabs(lp_lat) > ONETOL) throw proj_exception(); else lp_lat = lp_lat > 0. ? HALFPI : - HALFPI; else lp_lat = asin(lp_lat); }
inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const { double t; lp_lat = RYC * xy_y; if (fabs(lp_lat) > 1.) { if (fabs(lp_lat) > ONETOL) throw proj_exception(); else if (lp_lat < 0.) { t = -1.; lp_lat = -PI; } else { t = 1.; lp_lat = PI; } } else lp_lat = 2. * asin(t = lp_lat); lp_lon = RXC * xy_x / (1. + 2. * cos(lp_lat)/cos(0.5 * lp_lat)); lp_lat = RC * (t + sin(lp_lat)); if (fabs(lp_lat) > 1.) if (fabs(lp_lat) > ONETOL) throw proj_exception(); else lp_lat = lp_lat < 0. ? -HALFPI : HALFPI; else lp_lat = asin(lp_lat); }
void setup_fouc_s(Parameters& par, par_fouc_s& proj_parm) { proj_parm.n = pj_param(par.params, "dn").f; if (proj_parm.n < 0. || proj_parm.n > 1.) throw proj_exception(-99); proj_parm.n1 = 1. - proj_parm.n; par.es = 0; // par.inv = s_inverse; // par.fwd = s_forward; }
void setup_lcca(Parameters& par, par_lcca& proj_parm) { double s2p0, N0, R0, tan0, tan20; pj_enfn(par.es, proj_parm.en); if (!pj_param(par.params, "tlat_0").i) throw proj_exception(50); if (par.phi0 == 0.) throw proj_exception(51); proj_parm.l = sin(par.phi0); proj_parm.M0 = pj_mlfn(par.phi0, proj_parm.l, cos(par.phi0), proj_parm.en); s2p0 = proj_parm.l * proj_parm.l; R0 = 1. / (1. - par.es * s2p0); N0 = sqrt(R0); R0 *= par.one_es * N0; tan0 = tan(par.phi0); tan20 = tan0 * tan0; proj_parm.r0 = N0 / tan0; proj_parm.C = 1. / (6. * R0 * N0); // par.inv = e_inverse; // par.fwd = e_forward; }
inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const { double s; if ((s = fabs(lp_lat = pj_inv_mlfn(xy_y, this->m_par.es, this->m_proj_parm.en))) < HALFPI) { s = sin(lp_lat); lp_lon = xy_x * sqrt(1. - this->m_par.es * s * s) / cos(lp_lat); } else if ((s - EPS10) < HALFPI) lp_lon = 0.; else throw proj_exception();; return; }
inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const { double rh; rh = boost::math::hypot(xy_x, xy_y = this->m_proj_parm.cphi1 - xy_y); lp_lat = this->m_proj_parm.cphi1 + this->m_proj_parm.phi1 - rh; if (fabs(lp_lat) > HALFPI) throw proj_exception();; if (fabs(fabs(lp_lat) - HALFPI) <= EPS10) lp_lon = 0.; else lp_lon = rh * atan2(xy_x, xy_y) / cos(lp_lat); }
inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const { double t; if ((t = fabs(xy_y *= this->m_par.k0)) - EPS <= 1.) { if (t >= 1.) lp_lat = xy_y < 0. ? -HALFPI : HALFPI; else lp_lat = asin(xy_y); lp_lon = xy_x / this->m_par.k0; } else throw proj_exception();; }
inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const { lp_lat = xy_y / FYC - 1.; if (fabs(lp_lat = 1. - lp_lat * lp_lat) < 1.) lp_lat = asin(lp_lat); else if (fabs(lp_lat) > ONEEPS) throw proj_exception(); else lp_lat = lp_lat < 0. ? -HALFPI : HALFPI; if ((lp_lon = 1. - sin(lp_lat)) <= 0.) lp_lon = 0.; else lp_lon = xy_x / (FXC * sqrt(lp_lon)); }
inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const { lp_lon = xy_x / (FXC * ( lp_lat = 2. - fabs(xy_y) / FYC) ); lp_lat = (4. - lp_lat * lp_lat) * C13; if (fabs(lp_lat) >= 1.) { if (fabs(lp_lat) > ONEEPS) throw proj_exception(); else lp_lat = lp_lat < 0. ? -HALFPI : HALFPI; } else lp_lat = asin(lp_lat); if (xy_y < 0) lp_lat = -lp_lat; }
inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const { double s, rh; rh = boost::math::hypot(xy_x, xy_y = this->m_proj_parm.am1 - xy_y); lp_lat = pj_inv_mlfn(this->m_proj_parm.am1 + this->m_proj_parm.m1 - rh, this->m_par.es, this->m_proj_parm.en); if ((s = fabs(lp_lat)) < HALFPI) { s = sin(lp_lat); lp_lon = rh * atan2(xy_x, xy_y) * sqrt(1. - this->m_par.es * s * s) / cos(lp_lat); } else if (fabs(s - HALFPI) <= EPS10) lp_lon = 0.; else throw proj_exception();; }
inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const { double coslam, sinlam, sinphi, q, sinb=0.0, cosb=0.0, b=0.0; coslam = cos(lp_lon); sinlam = sin(lp_lon); sinphi = sin(lp_lat); q = pj_qsfn(sinphi, this->m_par.e, this->m_par.one_es); if (this->m_proj_parm.mode == OBLIQ || this->m_proj_parm.mode == EQUIT) { sinb = q / this->m_proj_parm.qp; cosb = sqrt(1. - sinb * sinb); } switch (this->m_proj_parm.mode) { case OBLIQ: b = 1. + this->m_proj_parm.sinb1 * sinb + this->m_proj_parm.cosb1 * cosb * coslam; break; case EQUIT: b = 1. + cosb * coslam; break; case N_POLE: b = HALFPI + lp_lat; q = this->m_proj_parm.qp - q; break; case S_POLE: b = lp_lat - HALFPI; q = this->m_proj_parm.qp + q; break; } if (fabs(b) < EPS10) throw proj_exception();; switch (this->m_proj_parm.mode) { case OBLIQ: xy_y = this->m_proj_parm.ymf * ( b = sqrt(2. / b) ) * (this->m_proj_parm.cosb1 * sinb - this->m_proj_parm.sinb1 * cosb * coslam); goto eqcon; break; case EQUIT: xy_y = (b = sqrt(2. / (1. + cosb * coslam))) * sinb * this->m_proj_parm.ymf; eqcon: xy_x = this->m_proj_parm.xmf * b * cosb * sinlam; break; case N_POLE: case S_POLE: if (q >= 0.) { xy_x = (b = sqrt(q)) * sinlam; xy_y = coslam * (this->m_proj_parm.mode == S_POLE ? b : -b); } else xy_x = xy_y = 0.; break; } }
inline double aacos(double v) { double av = 0; if ((av = geometry::math::abs(v)) >= 1.0) { if (av > aasincos::ONE_TOL) { throw proj_exception(-19); } return (v < 0.0 ? PI : 0.0); } return acos(v); }
inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const { double v, c; if (fabs(fabs(lp_lat) - HALFPI) < TOL) { xy_x = 0; xy_y = lp_lat < 0 ? -2. : 2.; } else { lp_lat = sin(lp_lat); v = this->m_proj_parm.a1 * pow((1. + lp_lat)/(1. - lp_lat), this->m_proj_parm.hrw); if ((c = 0.5 * (v + 1./v) + cos(lp_lon *= this->m_proj_parm.rw)) < TOL) throw proj_exception();; xy_x = 2. * sin(lp_lon) / c; xy_y = (v - 1./v) / c; } }
inline double pj_inv_mlfn(double arg, double es, const double *en) { double s, t, phi, k = 1./(1.-es); int i; phi = arg; for (i = MAX_ITER; i ; --i) { /* rarely goes over 2 iterations */ s = sin(phi); t = 1. - es * s * s; phi -= t = (pj_mlfn(phi, s, cos(phi), en) - arg) * (t * sqrt(t)) * k; if (geometry::math::abs(t) < EPS) return phi; } throw proj_exception(-17); return phi; }
inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const { double coslam, cosphi, sinphi; sinphi = sin(lp_lat); cosphi = cos(lp_lat); coslam = cos(lp_lon); switch (this->m_proj_parm.mode) { case OBLIQ: xy_y = this->m_proj_parm.sinph0 * sinphi + this->m_proj_parm.cosph0 * cosphi * coslam; break; case EQUIT: xy_y = cosphi * coslam; break; case S_POLE: xy_y = - sinphi; break; case N_POLE: xy_y = sinphi; break; } if (xy_y < this->m_proj_parm.rp) throw proj_exception();; xy_y = this->m_proj_parm.pn1 / (this->m_proj_parm.p - xy_y); xy_x = xy_y * cosphi * sin(lp_lon); switch (this->m_proj_parm.mode) { case OBLIQ: xy_y *= (this->m_proj_parm.cosph0 * sinphi - this->m_proj_parm.sinph0 * cosphi * coslam); break; case EQUIT: xy_y *= sinphi; break; case N_POLE: coslam = - coslam; case S_POLE: xy_y *= cosphi * coslam; break; } if (this->m_proj_parm.tilt) { double yt, ba; yt = xy_y * this->m_proj_parm.cg + xy_x * this->m_proj_parm.sg; ba = 1. / (yt * this->m_proj_parm.sw * this->m_proj_parm.h + this->m_proj_parm.cw); xy_x = (xy_x * this->m_proj_parm.cg - xy_y * this->m_proj_parm.sg) * this->m_proj_parm.cw * ba; xy_y = yt * ba; } }
inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const { double theta, dr, S, dif; int i; xy_x /= this->m_par.k0; xy_y /= this->m_par.k0; theta = atan2(xy_x , this->m_proj_parm.r0 - xy_y); dr = xy_y - xy_x * tan(0.5 * theta); lp_lon = theta / this->m_proj_parm.l; S = dr; for (i = MAX_ITER; i ; --i) { S -= (dif = (fS(S, this->m_proj_parm.C) - dr) / fSp(S, this->m_proj_parm.C)); if (fabs(dif) < DEL_TOL) break; } if (!i) throw proj_exception(); lp_lat = pj_inv_mlfn(S + this->m_proj_parm.M0, this->m_par.es, this->m_proj_parm.en); }
inline double pj_phi2(double ts, double e) { double eccnth, Phi, con, dphi; int i; eccnth = .5 * e; Phi = HALFPI - 2. * atan (ts); i = phi2::N_ITER; do { con = e * sin (Phi); dphi = HALFPI - 2. * atan (ts * pow((1. - con) / (1. + con), eccnth)) - Phi; Phi += dphi; } while ( fabs(dphi) > phi2::TOL && --i); if (i <= 0) throw proj_exception(-18); return Phi; }
inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const { double rh, cosc, sinc; if ((sinc = (rh = boost::math::hypot(xy_x, xy_y))) > 1.) { if ((sinc - 1.) > EPS10) throw proj_exception();; sinc = 1.; } cosc = sqrt(1. - sinc * sinc); /* in this range OK */ if (fabs(rh) <= EPS10) { lp_lat = this->m_par.phi0; lp_lon = 0.0; } else { switch (this->m_proj_parm.mode) { case N_POLE: xy_y = -xy_y; lp_lat = acos(sinc); break; case S_POLE: lp_lat = - acos(sinc); break; case EQUIT: lp_lat = xy_y * sinc / rh; xy_x *= sinc; xy_y = cosc * rh; goto sinchk; case OBLIQ: lp_lat = cosc * this->m_proj_parm.sinph0 + xy_y * sinc * this->m_proj_parm.cosph0 /rh; xy_y = (cosc - this->m_proj_parm.sinph0 * lp_lat) * rh; xy_x *= sinc * this->m_proj_parm.cosph0; sinchk: if (fabs(lp_lat) >= 1.) lp_lat = lp_lat < 0. ? -HALFPI : HALFPI; else lp_lat = asin(lp_lat); break; } lp_lon = (xy_y == 0. && (this->m_proj_parm.mode == OBLIQ || this->m_proj_parm.mode == EQUIT)) ? (xy_x == 0. ? 0. : xy_x < 0. ? -HALFPI : HALFPI) : atan2(xy_x, xy_y); } return; }
void setup_cea(Parameters& par, par_cea& proj_parm) { double t = 0; if (pj_param(par.params, "tlat_ts").i && (par.k0 = cos(t = pj_param(par.params, "rlat_ts").f)) < 0.) throw proj_exception(-24); if (par.es) { t = sin(t); par.k0 /= sqrt(1. - par.es * t * t); par.e = sqrt(par.es); pj_authset(par.es, proj_parm.apa); proj_parm.qp = pj_qsfn(1., par.e, par.one_es); // par.inv = e_inverse; // par.fwd = e_forward; } else { // par.inv = s_inverse; // par.fwd = s_forward; } }
inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const { double rh, cosz, sinz; if (this->m_proj_parm.tilt) { double bm, bq, yt; yt = 1./(this->m_proj_parm.pn1 - xy_y * this->m_proj_parm.sw); bm = this->m_proj_parm.pn1 * xy_x * yt; bq = this->m_proj_parm.pn1 * xy_y * this->m_proj_parm.cw * yt; xy_x = bm * this->m_proj_parm.cg + bq * this->m_proj_parm.sg; xy_y = bq * this->m_proj_parm.cg - bm * this->m_proj_parm.sg; } rh = boost::math::hypot(xy_x, xy_y); if ((sinz = 1. - rh * rh * this->m_proj_parm.pfact) < 0.) throw proj_exception();; sinz = (this->m_proj_parm.p - sqrt(sinz)) / (this->m_proj_parm.pn1 / rh + rh / this->m_proj_parm.pn1); cosz = sqrt(1. - sinz * sinz); if (fabs(rh) <= EPS10) { lp_lon = 0.; lp_lat = this->m_par.phi0; } else { switch (this->m_proj_parm.mode) { case OBLIQ: lp_lat = asin(cosz * this->m_proj_parm.sinph0 + xy_y * sinz * this->m_proj_parm.cosph0 / rh); xy_y = (cosz - this->m_proj_parm.sinph0 * sin(lp_lat)) * rh; xy_x *= sinz * this->m_proj_parm.cosph0; break; case EQUIT: lp_lat = asin(xy_y * sinz / rh); xy_y = cosz * rh; xy_x *= sinz; break; case N_POLE: lp_lat = asin(cosz); xy_y = -xy_y; break; case S_POLE: lp_lat = - asin(cosz); break; } lp_lon = atan2(xy_x, xy_y); } }
void setup_oea(Parameters& par, par_oea& proj_parm) { if (((proj_parm.n = pj_param(par.params, "dn").f) <= 0.) || ((proj_parm.m = pj_param(par.params, "dm").f) <= 0.)) throw proj_exception(-39); else { proj_parm.theta = pj_param(par.params, "rtheta").f; proj_parm.sp0 = sin(par.phi0); proj_parm.cp0 = cos(par.phi0); proj_parm.rn = 1./ proj_parm.n; proj_parm.rm = 1./ proj_parm.m; proj_parm.two_r_n = 2. * proj_parm.rn; proj_parm.two_r_m = 2. * proj_parm.rm; proj_parm.hm = 0.5 * proj_parm.m; proj_parm.hn = 0.5 * proj_parm.n; // par.fwd = s_forward; // par.inv = s_inverse; par.es = 0.; } }