Esempio n. 1
0
PJ *PROJECTION(bonne) {
    double c;
    struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque)));
    if (nullptr==Q)
        return pj_default_destructor (P, ENOMEM);
    P->opaque = Q;
    P->destructor = destructor;

    Q->phi1 = pj_param(P->ctx, P->params, "rlat_1").f;
    if (fabs(Q->phi1) < EPS10)
        return destructor (P, PJD_ERR_LAT1_IS_ZERO);

    if (P->es != 0.0) {
        Q->en = pj_enfn(P->es);
        if (nullptr==Q->en)
            return destructor(P, ENOMEM);
        Q->m1 = pj_mlfn(Q->phi1, Q->am1 = sin(Q->phi1),
            c = cos(Q->phi1), Q->en);
        Q->am1 = c / (sqrt(1. - P->es * Q->am1 * Q->am1) * Q->am1);
        P->inv = e_inverse;
        P->fwd = e_forward;
    } else {
        if (fabs(Q->phi1) + EPS10 >= M_HALFPI)
            Q->cphi1 = 0.;
        else
            Q->cphi1 = 1. / tan(Q->phi1);
        P->inv = s_inverse;
        P->fwd = s_forward;
    }
    return P;
}
Esempio n. 2
0
 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;
 }
Esempio n. 3
0
PJ *PROJECTION(lcca) {
    double s2p0, N0, R0, tan0;
    struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque)));
    if (nullptr==Q)
        return pj_default_destructor (P, ENOMEM);
    P->opaque = Q;

    (Q->en = pj_enfn(P->es));
    if (!Q->en)
        return pj_default_destructor (P, ENOMEM);

    if (P->phi0 == 0.) {
        return destructor(P, PJD_ERR_LAT_0_IS_ZERO);
    }
    Q->l = sin(P->phi0);
    Q->M0 = pj_mlfn(P->phi0, Q->l, cos(P->phi0), Q->en);
    s2p0 = Q->l * Q->l;
    R0 = 1. / (1. - P->es * s2p0);
    N0 = sqrt(R0);
    R0 *= P->one_es * N0;
    tan0 = tan(P->phi0);
    Q->r0 = N0 / tan0;
    Q->C = 1. / (6. * R0 * N0);

    P->inv = lcca_e_inverse;
    P->fwd = lcca_e_forward;
    P->destructor = destructor;

    return P;
}
Esempio n. 4
0
PJ *PROJECTION(bonne) {
	double c;
    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
    if (0==Q)
        return freeup_new (P);
    P->opaque = Q;

	Q->phi1 = pj_param(P->ctx, P->params, "rlat_1").f;
	if (fabs(Q->phi1) < EPS10) E_ERROR(-23);
	if (P->es) {
		Q->en = pj_enfn(P->es);
		Q->m1 = pj_mlfn(Q->phi1, Q->am1 = sin(Q->phi1),
			c = cos(Q->phi1), Q->en);
		Q->am1 = c / (sqrt(1. - P->es * Q->am1 * Q->am1) * Q->am1);
		P->inv = e_inverse;
		P->fwd = e_forward;
	} else {
		if (fabs(Q->phi1) + EPS10 >= M_HALFPI)
			Q->cphi1 = 0.;
		else
			Q->cphi1 = 1. / tan(Q->phi1);
		P->inv = s_inverse;
		P->fwd = s_forward;
	}
    return P;
}
Esempio n. 5
0
PJ *PROJECTION(imw_p) {
    double del, sig, s, t, x1, x2, T2, y1, m1, m2, y2;
    int err;
    struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque)));
    if (nullptr==Q)
        return pj_default_destructor (P, ENOMEM);
    P->opaque = Q;

    if (!(Q->en = pj_enfn(P->es))) return pj_default_destructor (P, ENOMEM);
    if( (err = phi12(P, &del, &sig)) != 0) {
        return destructor(P, err);
    }
    if (Q->phi_2 < Q->phi_1) { /* make sure P->phi_1 most southerly */
        del = Q->phi_1;
        Q->phi_1 = Q->phi_2;
        Q->phi_2 = del;
    }
    if (pj_param(P->ctx, P->params, "tlon_1").i)
        Q->lam_1 = pj_param(P->ctx, P->params, "rlon_1").f;
    else { /* use predefined based upon latitude */
        sig = fabs(sig * RAD_TO_DEG);
        if (sig <= 60)      sig = 2.;
        else if (sig <= 76) sig = 4.;
        else                sig = 8.;
        Q->lam_1 = sig * DEG_TO_RAD;
    }
    Q->mode = NONE_IS_ZERO;
    if (Q->phi_1 != 0.0)
        xy(P, Q->phi_1, &x1, &y1, &Q->sphi_1, &Q->R_1);
    else {
        Q->mode = PHI_1_IS_ZERO;
        y1 = 0.;
        x1 = Q->lam_1;
    }
    if (Q->phi_2 != 0.0)
        xy(P, Q->phi_2, &x2, &T2, &Q->sphi_2, &Q->R_2);
    else {
        Q->mode = PHI_2_IS_ZERO;
        T2 = 0.;
        x2 = Q->lam_1;
    }
    m1 = pj_mlfn(Q->phi_1, Q->sphi_1, cos(Q->phi_1), Q->en);
    m2 = pj_mlfn(Q->phi_2, Q->sphi_2, cos(Q->phi_2), Q->en);
    t = m2 - m1;
    s = x2 - x1;
    y2 = sqrt(t * t - s * s) + y1;
    Q->C2 = y2 - T2;
    t = 1. / t;
    Q->P = (m2 * y1 - m1 * y2) * t;
    Q->Q = (y2 - y1) * t;
    Q->Pp = (m2 * x1 - m1 * x2) * t;
    Q->Qp = (x2 - x1) * t;

    P->fwd = e_forward;
    P->inv = e_inverse;
    P->destructor = destructor;

    return P;
}
Esempio n. 6
0
 void setup_sinu(Parameters& par, par_gn_sinu& proj_parm)
 {
         pj_enfn(par.es, proj_parm.en);
 
     if (par.es) {
     // par.inv = e_inverse;
     // par.fwd = e_forward;
     } else {
         proj_parm.n = 1.;
         proj_parm.m = 0.;
         setup(par, proj_parm);
     }
 }
Esempio n. 7
0
PJ *PROJECTION(eqdc) {
    double cosphi, sinphi;
    int secant;

    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
    if (0==Q)
        return pj_default_destructor (P, ENOMEM);
    P->opaque = Q;
    P->destructor = destructor;

    Q->phi1 = pj_param(P->ctx, P->params, "rlat_1").f;
    Q->phi2 = pj_param(P->ctx, P->params, "rlat_2").f;

    if (fabs(Q->phi1 + Q->phi2) < EPS10)
        return pj_default_destructor (P, PJD_ERR_CONIC_LAT_EQUAL);

    if (!(Q->en = pj_enfn(P->es)))
        return pj_default_destructor(P, ENOMEM);

    Q->n = sinphi = sin(Q->phi1);
    cosphi = cos(Q->phi1);
    secant = fabs(Q->phi1 - Q->phi2) >= EPS10;
    if( (Q->ellips = (P->es > 0.)) ) {
        double ml1, m1;

        m1 = pj_msfn(sinphi, cosphi, P->es);
        ml1 = pj_mlfn(Q->phi1, sinphi, cosphi, Q->en);
        if (secant) { /* secant cone */
            sinphi = sin(Q->phi2);
            cosphi = cos(Q->phi2);
            Q->n = (m1 - pj_msfn(sinphi, cosphi, P->es)) /
                (pj_mlfn(Q->phi2, sinphi, cosphi, Q->en) - ml1);
        }
        Q->c = ml1 + m1 / Q->n;
        Q->rho0 = Q->c - pj_mlfn(P->phi0, sin(P->phi0),
            cos(P->phi0), Q->en);
    } else {
        if (secant)
            Q->n = (cosphi - cos(Q->phi2)) / (Q->phi2 - Q->phi1);
        Q->c = Q->phi1 + cos(Q->phi1) / Q->n;
        Q->rho0 = Q->c - P->phi0;
    }

    P->inv = e_inverse;
    P->fwd = e_forward;

    return P;
}
Esempio n. 8
0
PJ *PROJECTION(poly) {
    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
    if (0==Q)
        return freeup_new (P);
    P->opaque = Q;

	if (P->es) {
		if (!(Q->en = pj_enfn(P->es))) E_ERROR_0;
		Q->ml0 = pj_mlfn(P->phi0, sin(P->phi0), cos(P->phi0), Q->en);
		P->inv = e_inverse;
		P->fwd = e_forward;
	} else {
		Q->ml0 = -P->phi0;
		P->inv = s_inverse;
		P->fwd = s_forward;
	}

    return P;
}
Esempio n. 9
0
 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;
 }
Esempio n. 10
0
 void setup_bonne(Parameters& par, par_bonne& proj_parm)
 {
     double c;
     proj_parm.phi1 = pj_param(par.params, "rlat_1").f;
     if (fabs(proj_parm.phi1) < EPS10) throw proj_exception(-23);
     if (par.es) {
         pj_enfn(par.es, proj_parm.en);
         proj_parm.m1 = pj_mlfn(proj_parm.phi1, proj_parm.am1 = sin(proj_parm.phi1),
             c = cos(proj_parm.phi1), proj_parm.en);
         proj_parm.am1 = c / (sqrt(1. - par.es * proj_parm.am1 * proj_parm.am1) * proj_parm.am1);
     // par.inv = e_inverse;
     // par.fwd = e_forward;
     } else {
         if (fabs(proj_parm.phi1) + EPS10 >= HALFPI)
             proj_parm.cphi1 = 0.;
         else
             proj_parm.cphi1 = 1. / tan(proj_parm.phi1);
     // par.inv = s_inverse;
     // par.fwd = s_forward;
     }
 }
Esempio n. 11
0
            inline void setup_lcca(Parameters& par, par_lcca<T>& proj_parm)
            {
                T s2p0, N0, R0, tan0, tan20;

                if (!pj_enfn(par.es, proj_parm.en))
                    BOOST_THROW_EXCEPTION( projection_exception(0) );
                if (!pj_param(par.params, "tlat_0").i)
                    BOOST_THROW_EXCEPTION( projection_exception(50) );
                if (par.phi0 == 0.)
                    BOOST_THROW_EXCEPTION( projection_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);
                boost::ignore_unused(tan20);
            }
Esempio n. 12
0
PJ *PROJECTION(poly) {
    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
    if (0==Q)
        return pj_default_destructor (P, ENOMEM);

    P->opaque = Q;
    P->destructor = destructor;

    if (P->es != 0.0) {
        if (!(Q->en = pj_enfn(P->es)))
            return pj_default_destructor (P, ENOMEM);
        Q->ml0 = pj_mlfn(P->phi0, sin(P->phi0), cos(P->phi0), Q->en);
        P->inv = e_inverse;
        P->fwd = e_forward;
    } else {
        Q->ml0 = -P->phi0;
        P->inv = s_inverse;
        P->fwd = s_forward;
    }

    return P;
}
Esempio n. 13
0
PJ *PROJECTION(cass) {

    /* Spheroidal? */
    if (0==P->es) {
        P->inv = s_inverse;
        P->fwd = s_forward;
        return P;
    }

    /* otherwise it's ellipsoidal */
    P->opaque = pj_calloc (1, sizeof (struct pj_opaque));
    if (0==P->opaque)
        return freeup_new (P);

    P->opaque->en = pj_enfn (P->es);
    if (0==P->opaque->en)
        return freeup_new (P);

    P->opaque->m0 = pj_mlfn (P->phi0,  sin (P->phi0),  cos (P->phi0),  P->opaque->en);
    P->inv = e_inverse;
    P->fwd = e_forward;

    return P;
}