Example #1
0
        public override PJ Init()
        {
            es = 0.0;

            try
            {
                sinu = new PJ_sinu();
                moll = new PJ_moll();
            }
            catch
            {
                return(null);
            }

            sinu.es  = 0;
            sinu.ctx = ctx;
            moll.ctx = ctx;

            sinu = sinu.Init();
            moll = moll.Init();
            if (sinu == null || moll == null)
            {
                return(null);
            }

            fwd = s_forward;
            inv = s_inverse;

            return(this);
        }
Example #2
0
        public override PJ Init()
        {
            es=0.0;

            try
            {
                sinu=new PJ_sinu();
                moll=new PJ_moll();
            }
            catch
            {
                return null;
            }

            sinu.es=0;
            sinu.ctx=ctx;
            moll.ctx=ctx;

            sinu=sinu.Init();
            moll=moll.Init();
            if(sinu==null||moll==null) return null;

            fwd=s_forward;
            inv=s_inverse;

            return this;
        }
Example #3
0
        //  Zones:
        //
        //    -180            -40                       180
        //      +--------------+-------------------------+    Zones 1,2,9,10,11 & 12:
        //      |1             |2                        |      Mollweide projection
        //      |              |                         |
        //      +--------------+-------------------------+    Zones 3,4,5,6,7 & 8:
        //      |3             |4                        |      Sinusoidal projection
        //      |              |                         |
        //    0 +-------+------+-+-----------+-----------+
        //      |5      |6       |7          |8          |
        //      |       |        |           |           |
        //      +-------+--------+-----------+-----------+
        //      |9      |10      |11         |12         |
        //      |       |        |           |           |
        //      +-------+--------+-----------+-----------+
        //    -180    -100      -20         80          180

        bool SETUP(int n, PJ proj, double x_0, double y_0, double lon_0)
        {
            if (proj == null)
            {
                return(false);
            }
            pj[n - 1] = proj.Init();
            if (pj[n - 1] == null)
            {
                return(false);
            }

            pj[n - 1].x0   = x_0;
            pj[n - 1].y0   = y_0;
            pj[n - 1].lam0 = lon_0;

            return(true);
        }
Example #4
0
        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);
        }
		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:(Func<XY, LP>)null;
			}
			else
			{ // transverse
				fwd=t_forward;
				inv=link.inv!=null?t_inverse:(Func<XY, LP>)null;
			}

			return this;
		}
Example #6
0
        //  Zones:
        //
        //    -180            -40                       180
        //      +--------------+-------------------------+    Zones 1,2,9,10,11 & 12:
        //      |1             |2                        |      Mollweide projection
        //      |              |                         |
        //      +--------------+-------------------------+    Zones 3,4,5,6,7 & 8:
        //      |3             |4                        |      Sinusoidal projection
        //      |              |                         |
        //    0 +-------+------+-+-----------+-----------+
        //      |5      |6       |7          |8          |
        //      |       |        |           |           |
        //      +-------+--------+-----------+-----------+
        //      |9      |10      |11         |12         |
        //      |       |        |           |           |
        //      +-------+--------+-----------+-----------+
        //    -180    -100      -20         80          180
        bool SETUP(int n, PJ proj, double x_0, double y_0, double lon_0)
        {
            if(proj==null) return false;
            pj[n-1]=proj.Init();
            if(pj[n-1]==null) return false;

            pj[n-1].x0=x_0;
            pj[n-1].y0=y_0;
            pj[n-1].lam0=lon_0;

            return true;
        }