inline void e_inverse(T const& xy_x, T const& xy_y, T& lp_lon, T& lp_lat, Par const& par, ProjParm const& proj_parm) { T c; if ((c = boost::math::hypot(xy_x, xy_y)) < epsilon10) { lp_lat = par.phi0; lp_lon = 0.; return; } if (proj_parm.mode == obliq || proj_parm.mode == equit) { T const x2 = xy_x * par.a; T const y2 = xy_y * par.a; //T const lat1 = par.phi0; //T const lon1 = par.lam0; T const azi1 = atan2(x2, y2); T const s12 = sqrt(x2 * x2 + y2 * y2); formula::result_direct<T> const dir = formula::vincenty_direct < T, true >::apply(par.lam0, par.phi0, s12, azi1, proj_parm.spheroid); lp_lat = dir.lat2; lp_lon = dir.lon2; lp_lon -= par.lam0; } else { /* Polar */ lp_lat = pj_inv_mlfn(proj_parm.mode == n_pole ? proj_parm.Mp - c : proj_parm.Mp + c, par.es, proj_parm.en); lp_lon = atan2(xy_x, proj_parm.mode == n_pole ? -xy_y : xy_y); } }
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 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 e_guam_inv(T const& xy_x, T const& xy_y, T& lp_lon, T& lp_lat, Par const& par, ProjParm const& proj_parm) { T x2, t = 0.0; int i; x2 = 0.5 * xy_x * xy_x; lp_lat = par.phi0; for (i = 0; i < 3; ++i) { t = par.e * sin(lp_lat); lp_lat = pj_inv_mlfn(proj_parm.M1 + xy_y - x2 * tan(lp_lat) * (t = sqrt(1. - t * t)), par.es, proj_parm.en); } lp_lon = xy_x * t / cos(lp_lat); }
static LP e_inverse (XY xy, PJ *P) { /* Ellipsoidal, inverse */ LP lp = {0.0,0.0}; struct pj_opaque *Q = P->opaque; double s, rh; rh = hypot(xy.x, xy.y = Q->am1 - xy.y); lp.phi = pj_inv_mlfn(P->ctx, Q->am1 + Q->m1 - rh, P->es, Q->en); if ((s = fabs(lp.phi)) < M_HALFPI) { s = sin(lp.phi); lp.lam = rh * atan2(xy.x, xy.y) * sqrt(1. - P->es * s * s) / cos(lp.phi); } else if (fabs(s - M_HALFPI) <= EPS10) lp.lam = 0.; else I_ERROR; return lp; }
inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const { if ((this->m_proj_parm.rho = boost::math::hypot(xy_x, xy_y = this->m_proj_parm.rho0 - xy_y)) != 0.0 ) { if (this->m_proj_parm.n < 0.) { this->m_proj_parm.rho = -this->m_proj_parm.rho; xy_x = -xy_x; xy_y = -xy_y; } lp_lat = this->m_proj_parm.c - this->m_proj_parm.rho; if (this->m_proj_parm.ellips) lp_lat = pj_inv_mlfn(lp_lat, this->m_par.es, this->m_proj_parm.en); lp_lon = atan2(xy_x, xy_y) / this->m_proj_parm.n; } else { lp_lon = 0.; lp_lat = this->m_proj_parm.n > 0. ? HALFPI : - HALFPI; } }
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); }
static LP e_inverse (XY xy, PJ *P) { /* Ellipsoidal, inverse */ double n, t, r, dd, d2, tn, ph1; LP lp = {0.0, 0.0}; struct pj_opaque *Q = P->opaque; ph1 = pj_inv_mlfn (P->ctx, Q->m0 + xy.y, P->es, Q->en); tn = tan (ph1); t = tn*tn; n = sin (ph1); r = 1. / (1. - P->es * n * n); n = sqrt (r); r *= (1. - P->es) * n; dd = xy.x / n; d2 = dd * dd; lp.phi = ph1 - (n * tn / r) * d2 * (.5 - (1. + 3. * t) * d2 * C3); lp.lam = dd * (1. + t * d2 * (-C4 + (1. + 3. * t) * d2 * C5)) / cos (ph1); return lp; }
static PJ_LP e_inverse (PJ_XY xy, PJ *P) { /* Ellipsoidal, inverse */ PJ_LP lp = {0.0,0.0}; struct pj_opaque *Q = static_cast<struct pj_opaque*>(P->opaque); double s, rh; rh = hypot(xy.x, xy.y = Q->am1 - xy.y); lp.phi = pj_inv_mlfn(P->ctx, Q->am1 + Q->m1 - rh, P->es, Q->en); if ((s = fabs(lp.phi)) < M_HALFPI) { s = sin(lp.phi); lp.lam = rh * atan2(xy.x, xy.y) * sqrt(1. - P->es * s * s) / cos(lp.phi); } else if (fabs(s - M_HALFPI) <= EPS10) lp.lam = 0.; else { proj_errno_set(P, PJD_ERR_TOLERANCE_CONDITION); return lp; } return lp; }
static LP e_inverse (XY xy, PJ *P) { /* Ellipsoidal, inverse */ LP lp = {0.0,0.0}; struct pj_opaque *Q = P->opaque; if ((Q->rho = hypot(xy.x, xy.y = Q->rho0 - xy.y)) != 0.0 ) { if (Q->n < 0.) { Q->rho = -Q->rho; xy.x = -xy.x; xy.y = -xy.y; } lp.phi = Q->c - Q->rho; if (Q->ellips) lp.phi = pj_inv_mlfn(P->ctx, lp.phi, P->es, Q->en); lp.lam = atan2(xy.x, xy.y) / Q->n; } else { lp.lam = 0.; lp.phi = Q->n > 0. ? M_HALFPI : -M_HALFPI; } return lp; }
static PJ_LP lcca_e_inverse (PJ_XY xy, PJ *P) { /* Ellipsoidal, inverse */ PJ_LP lp = {0.0,0.0}; struct pj_opaque *Q = static_cast<struct pj_opaque*>(P->opaque); double theta, dr, S, dif; int i; xy.x /= P->k0; xy.y /= P->k0; theta = atan2(xy.x , Q->r0 - xy.y); dr = xy.y - xy.x * tan(0.5 * theta); lp.lam = theta / Q->l; S = dr; for (i = MAX_ITER; i ; --i) { S -= (dif = (fS(S, Q->C) - dr) / fSp(S, Q->C)); if (fabs(dif) < DEL_TOL) break; } if (!i) { proj_errno_set(P, PJD_ERR_TOLERANCE_CONDITION); return lp; } lp.phi = pj_inv_mlfn(P->ctx, S + Q->M0, P->es, Q->en); return lp; }