public override PJ Init() { // get name of projection to be translated string name = Proj.pj_param_s(ctx, parameters, "o_proj"); if (name == null || name == "") { Proj.pj_ctx_set_errno(ctx, -26); return(null); } link = Proj.GetPJ(name); if (link == null) { Proj.pj_ctx_set_errno(ctx, -5); return(null); } // copy existing header into new es = 0.0; // force to spherical link.parameters = parameters; link.ctx = ctx; link.over = over; link.geoc = geoc; link.a = a; link.es = es; link.ra = ra; link.lam0 = lam0; link.phi0 = phi0; link.x0 = x0; link.y0 = y0; link.k0 = k0; // force spherical earth link.one_es = link.rone_es = 1.0; link.es = link.e = 0.0; link = link.Init(); if (link == null) { return(null); } double phip = 0; if (Proj.pj_param_t(ctx, parameters, "o_alpha")) { double lamc = Proj.pj_param_r(ctx, parameters, "o_lon_c"); double phic = Proj.pj_param_r(ctx, parameters, "o_lat_c"); double alpha = Proj.pj_param_r(ctx, parameters, "o_alpha"); //if(Math.Abs(phic)<=TOL10||Math.Abs(Math.Abs(phic)-HALFPI)<=TOL10||Math.Abs(Math.Abs(alpha)-HALFPI)<=TOL10) if (Math.Abs(Math.Abs(phic) - Proj.HALFPI) <= TOL) { Proj.pj_ctx_set_errno(ctx, -32); return(null); } lamp = lamc + Proj.aatan2(-Math.Cos(alpha), -Math.Sin(alpha) * Math.Sin(phic)); phip = Proj.aasin(ctx, Math.Cos(phic) * Math.Sin(alpha)); } else if (Proj.pj_param_t(ctx, parameters, "o_lat_p")) { // specified new pole lamp = Proj.pj_param_r(ctx, parameters, "o_lon_p"); phip = Proj.pj_param_r(ctx, parameters, "o_lat_p"); } else { // specified new "equator" points double lam1 = Proj.pj_param_r(ctx, parameters, "o_lon_1"); double phi1 = Proj.pj_param_r(ctx, parameters, "o_lat_1"); double lam2 = Proj.pj_param_r(ctx, parameters, "o_lon_2"); double phi2 = Proj.pj_param_r(ctx, parameters, "o_lat_2"); double con = Math.Abs(phi1); if (Math.Abs(phi1 - phi2) <= TOL || con <= TOL || Math.Abs(con - Proj.HALFPI) <= TOL || Math.Abs(Math.Abs(phi2) - Proj.HALFPI) <= TOL) { Proj.pj_ctx_set_errno(ctx, -33); return(null); } lamp = Math.Atan2(Math.Cos(phi1) * Math.Sin(phi2) * Math.Cos(lam1) - Math.Sin(phi1) * Math.Cos(phi2) * Math.Cos(lam2), Math.Sin(phi1) * Math.Cos(phi2) * Math.Sin(lam2) - Math.Cos(phi1) * Math.Sin(phi2) * Math.Sin(lam1)); phip = Math.Atan(-Math.Cos(lamp - lam1) / Math.Tan(phi1)); } if (Math.Abs(phip) > TOL) { // oblique cphip = Math.Cos(phip); sphip = Math.Sin(phip); fwd = o_forward; inv = link.inv != null?o_inverse:(LP_XY_PJ)null; } else { // transverse fwd = t_forward; inv = link.inv != null?t_inverse:(LP_XY_PJ)null; } return(this); }