Esempio n. 1
0
        // confirms that user would like to remove the album, returns true if yes,
        //false otherwise
        public bool ConfirmRemoveLP(LP x)
        {
            bool remove;

            while (true)
            {
                Console.WriteLine("Are you sure you want to remove this album?:\nID: {0}, Title: {1}, Artist: {2}, " +
                                  "Release Year: {3}", x.GetID(), x.GetTitle(), x.GetArtist(), x.GetReleaseYear());
                Console.WriteLine();
                Console.Write("enter \"Y\" to REMOVE or \"N\" to CANCEL:  ");
                string YorN = Console.ReadLine().ToLower();
                Console.WriteLine();

                if (YorN == "y")
                {
                    remove = true;
                    break;
                }

                else if (YorN == "n")
                {
                    remove = false;
                    break;
                }

                else
                {
                    Console.WriteLine("Invalid entry, please Try again");
                    continue;
                }
            }

            Console.WriteLine();
            return(remove);
        }
Esempio n. 2
0
        // spheroid
        XY s_forward(LP lp)
        {
            XY xy;

            xy.x = xy.y = 0;

            xy.y = lp.phi - phi1;
            if (Math.Abs(xy.y) < EPS8)
            {
                xy.x = lp.lam * cosphi1;
            }
            else
            {
                xy.x = Proj.FORTPI + 0.5 * lp.phi;
                if (Math.Abs(xy.x) < EPS8 || Math.Abs(Math.Abs(xy.x) - Proj.HALFPI) < EPS8)
                {
                    xy.x = 0.0;
                }
                else
                {
                    xy.x = lp.lam * xy.y / Math.Log(Math.Tan(xy.x) / tanphi1);
                }
            }

            return(xy);
        }
Esempio n. 3
0
        public override Function Diff()
        {
            Boolean Lconst = false;

            if (LP.Diff().ToString() == "0")
            {
                Lconst = true;
            }
            Boolean Rconst = false;

            if (RP.Diff().ToString() == "0")
            {
                Rconst = true;
            }
            if ((Lconst == true) && (Rconst == true))
            {
                return(new Const(0));
            }
            if (Lconst == true)
            {
                return(new Mul(new Pow(LP, RP), new Ln(LP)));
            }
            if (Rconst == true)
            {
                return(new Mul(new Pow(LP, new Minus(RP, new Const(1))), RP));
            }
            return(new Sum(new Mul(RP, new Mul(LP.Diff(), new Pow(LP, new Minus(RP, new Const(1))))), new Mul(RP.Diff(), new Mul(new Pow(LP, RP), new Ln(LP)))));
        }
Esempio n. 4
0
        /// <summary>
        ///     Print the object's XML to the XmlWriter.
        /// </summary>
        /// <param name="objWriter">XmlTextWriter to write with.</param>
        /// <param name="objCulture">Culture in which to print.</param>
        /// <param name="strLanguageToPrint">Language in which to print</param>
        public void Print(XmlTextWriter objWriter, CultureInfo objCulture, string strLanguageToPrint)
        {
            if (!AllowPrint || objWriter == null)
            {
                return;
            }
            objWriter.WriteStartElement("quality");
            objWriter.WriteElementString("guid", InternalId);
            objWriter.WriteElementString("sourceid", SourceIDString);
            objWriter.WriteElementString("name", DisplayNameShort(strLanguageToPrint));
            objWriter.WriteElementString("fullname", DisplayName(strLanguageToPrint));
            objWriter.WriteElementString("formattedname", FormattedDisplayName(objCulture, strLanguageToPrint));
            objWriter.WriteElementString("extra", _objCharacter.TranslateExtra(Extra, strLanguageToPrint));
            objWriter.WriteElementString("lp", LP.ToString(objCulture));
            objWriter.WriteElementString("cost", Cost.ToString(_objCharacter.Options.NuyenFormat, objCulture));
            var strLifestyleQualityType = Type.ToString();

            if (strLanguageToPrint != GlobalOptions.DefaultLanguage)
            {
                XPathNavigator objNode = _objCharacter.LoadDataXPath("lifestyles.xml", strLanguageToPrint)
                                         .SelectSingleNode("/chummer/categories/category[. = " + strLifestyleQualityType.CleanXPath() + "]");
                strLifestyleQualityType = objNode?.SelectSingleNode("@translate")?.Value ?? strLifestyleQualityType;
            }

            objWriter.WriteElementString("lifestylequalitytype", strLifestyleQualityType);
            objWriter.WriteElementString("lifestylequalitytype_english", Type.ToString());
            objWriter.WriteElementString("lifestylequalitysource", OriginSource.ToString());
            objWriter.WriteElementString("source", _objCharacter.LanguageBookShort(Source, strLanguageToPrint));
            objWriter.WriteElementString("page", DisplayPage(strLanguageToPrint));
            if (GlobalOptions.PrintNotes)
            {
                objWriter.WriteElementString("notes", Notes);
            }
            objWriter.WriteEndElement();
        }
Esempio n. 5
0
        // spheroid
        XY s_forward(LP lp)
        {
            XY xy;

            xy.x = xy.y = 0;

            lp.lam = lp.lam + lam0;
            if (Math.Abs(Math.Abs(lp.phi) - Proj.HALFPI) <= EPS10)
            {
                Proj.pj_ctx_set_errno(ctx, -20); return(xy);
            }

            xy.x = lp.lam;
            xy.y = Math.Log(Math.Tan(Proj.FORTPI + 0.5 * lp.phi));

            double oy = Math.Log(Math.Tan(Proj.FORTPI + 0.5 * PT_O_PHI));

            double l1 = (xy.y - oy) * Math.Tan(ROTATION_ANGLE);
            double l2 = -xy.x - l1 + PT_O_LAMBDA;

            double ry = l2 * Math.Cos(ROTATION_ANGLE) * Math.Sin(ROTATION_ANGLE) + xy.y;

            ry = Proj.HALFPI - 2.0 * Math.Atan(Math.Exp(-ry));

            xy.x = PT_O_LINE - Proj.RAD_TO_DEG * (ry - PT_O_PHI) * DEG_TO_LINE / Math.Cos(ROTATION_ANGLE);
            xy.y = PT_O_STATION + Proj.RAD_TO_DEG * (ry - lp.phi) * DEG_TO_STATION / Math.Sin(ROTATION_ANGLE);

            a  = 1;
            x0 = 0;
            y0 = 0;

            return(xy);
        }
Esempio n. 6
0
        // ellipsoid
        XY e_forward(LP lp)
        {
            XY xy;

            xy.x = xy.y = 0;

            double sphi2 = Math.Sin(lp.phi);
            double c     = Math.Cos(lp.phi) * sphi2;

            sphi2 *= sphi2;
            double phis = lp.phi - c * (As + sphi2 * (Bs + sphi2 * (Cs + sphi2 * Ds)));
            double z    = xy.y = Math.Atan2(Math.Tan(phis), Math.Cos(lp.lam));
            double n    = xy.x = Atanh(Math.Cos(phis) * Math.Sin(lp.lam));

            for (int b = 0, i = 2; i <= 8; i += 2, ++b)
            {
                double tz = i * z;
                double tn = i * n;
                xy.y += beta[b] * Math.Sin(tz) * Math.Cosh(tn);
                xy.x += beta[b] * Math.Cos(tz) * Math.Sinh(tn);
            }
            xy.y *= K;
            xy.x *= K;
            return(xy);
        }
Esempio n. 7
0
        // spheroid
        XY s_forward(LP lp)
        {
            XY xy;

            xy.x = xy.y = 0;

            double p = C_p * Math.Sin(lp.phi);
            double s = lp.phi * lp.phi;

            lp.phi *= 0.615709 + s * (0.00909953 + s * 0.0046292);

            int i = NITER;

            for (; i > 0; i--)
            {
                double c = Math.Cos(lp.phi);
                s = Math.Sin(lp.phi);
                double V = (lp.phi + s * (c - 1.0) - p) / (1.0 + c * (c - 1.0) - s * s);
                lp.phi -= V;
                if (Math.Abs(V) < EPS)
                {
                    break;
                }
            }

            if (i == 0)
            {
                lp.phi = lp.phi < 0?-PI_DIV_3:PI_DIV_3;
            }

            xy.x = C_x * lp.lam * (Math.Cos(lp.phi) - 0.5);
            xy.y = C_y * Math.Sin(lp.phi);

            return(xy);
        }
Esempio n. 8
0
        // ellipsoid & spheroid
        XY e_forward(LP lp)
        {
            XY xy;

            xy.x = xy.y = 0;
            double rho = 0.0;

            if (Math.Abs(Math.Abs(lp.phi) - Proj.HALFPI) < EPS10)
            {
                if ((lp.phi * n) <= 0.0)
                {
                    Proj.pj_ctx_set_errno(ctx, -20); return(xy);
                }
                rho = 0.0;
            }
            else
            {
                rho = c * (ellips?Math.Pow(Proj.pj_tsfn(lp.phi, Math.Sin(lp.phi), e), n):Math.Pow(Math.Tan(Proj.FORTPI + 0.5 * lp.phi), -n));
            }

            lp.lam *= n;
            xy.x    = k0 * (rho * Math.Sin(lp.lam));
            xy.y    = k0 * (rho0 - rho * Math.Cos(lp.lam));

            return(xy);
        }
Esempio n. 9
0
		// ellipse
		XY e_forward(LP lp)
		{
			XY xy;
			xy.x=xy.y=0;

			// Fail if our longitude is more than 90 degrees from the
			// central meridian since the results are essentially garbage.
			// Is error -20 really an appropriate return value?
			//
			// http://trac.osgeo.org/proj/ticket/5
			if(lp.lam<-Proj.HALFPI||lp.lam>Proj.HALFPI)
			{
				xy.x=Libc.HUGE_VAL;
				xy.y=Libc.HUGE_VAL;
				Proj.pj_ctx_set_errno(ctx, -14);

				return xy;
			}

			double sinphi=Math.Sin(lp.phi);
			double cosphi=Math.Cos(lp.phi);
			double t=Math.Abs(cosphi)>1e-10?sinphi/cosphi:0.0;
			t*=t;
			double al=cosphi*lp.lam;
			double als=al*al;
			al/=Math.Sqrt(1.0-es*sinphi*sinphi);
			double n=esp*cosphi*cosphi;

			xy.x=k0*al*(FC1+FC3*als*(1.0-t+n+FC5*als*(5.0+t*(t-18.0)+n*(14.0-58.0*t)+FC7*als*(61.0+t*(t*(179.0-t)-479.0)))));

			xy.y=k0*(Proj.pj_mlfn(lp.phi, sinphi, cosphi, en)-ml0+sinphi*al*lp.lam*FC2*(1.0+FC4*als*(5.0-t+n*(9.0+4.0*n)+
				FC6*als*(61.0+t*(t-58.0)+n*(270.0-330*t)+FC8*als*(1385.0+t*(t*(543.0-t)-3111.0))))));

			return xy;
		}
Esempio n. 10
0
        // spheroid
        XY s_forward(LP lp)
        {
            XY xy;
            xy.x=xy.y=0;

            double cosphi=Math.Cos(lp.phi);
            double coslam=Math.Cos(lp.lam);

            switch(mode)
            {
                case ortho_mode.EQUIT:
                    if(cosphi*coslam<-EPS10) { Proj.pj_ctx_set_errno(ctx, -20); return xy; }
                    xy.y=Math.Sin(lp.phi);
                    break;
                case ortho_mode.OBLIQ:
                    double sinphi=Math.Sin(lp.phi);
                    if(sinph0*sinphi+cosph0*cosphi*coslam<-EPS10) { Proj.pj_ctx_set_errno(ctx, -20); return xy; }
                    xy.y=cosph0*sinphi-sinph0*cosphi*coslam;
                    break;
                case ortho_mode.N_POLE:
                    coslam=-coslam;
                    if(Math.Abs(lp.phi-phi0)-EPS10>Proj.HALFPI) { Proj.pj_ctx_set_errno(ctx, -20); return xy; }
                    xy.y=cosphi*coslam;
                    break;
                case ortho_mode.S_POLE:
                    if(Math.Abs(lp.phi-phi0)-EPS10>Proj.HALFPI) { Proj.pj_ctx_set_errno(ctx, -20); return xy; }
                    xy.y=cosphi*coslam;
                    break;
            }
            xy.x=cosphi*Math.Sin(lp.lam);

            return xy;
        }
Esempio n. 11
0
        // spheroid
        XY s_forward(LP lp)
        {
            XY xy;

            xy.x = xy.y = 0;

            // Calculation of the three components of the vector from satellite to
            // position on earth surface (lon,lat).
            double tmp = Math.Cos(lp.phi);
            double Vx  = Math.Cos(lp.lam) * tmp;
            double Vy  = Math.Sin(lp.lam) * tmp;
            double Vz  = Math.Sin(lp.phi);

            // Check visibility.
            if (((radius_g - Vx) * Vx - Vy * Vy - Vz * Vz) < 0.0)
            {
                Proj.pj_ctx_set_errno(ctx, -20); return(xy);
            }

            // Calculation based on view angles from satellite.
            tmp = radius_g - Vx;
            if (flip_axis)
            {
                xy.x = radius_g_1 * Math.Atan(Vy / Libc.hypot(Vz, tmp));
                xy.y = radius_g_1 * Math.Atan(Vz / tmp);
            }
            else
            {
                xy.x = radius_g_1 * Math.Atan(Vy / tmp);
                xy.y = radius_g_1 * Math.Atan(Vz / Libc.hypot(Vy, tmp));
            }

            return(xy);
        }
Esempio n. 12
0
        // spheroid
        XY s_forward(LP lp)
        {
            XY xy;

            xy.x = xy.y = 0;

            double k = C3 * Math.Sin(lp.phi);
            double t;

            for (int i = MAX_ITER; i > 0; i--)
            {
                t = lp.phi / C2;
                double V = (C1 * Math.Sin(t) + Math.Sin(lp.phi) - k) / (C1_2 * Math.Cos(t) + Math.Cos(lp.phi));
                lp.phi -= V;
                if (Math.Abs(V) < LOOP_TOL)
                {
                    break;
                }
            }

            t    = lp.phi / C2;
            xy.x = C_x * lp.lam * (1.0 + 3.0 * Math.Cos(lp.phi) / Math.Cos(t));
            xy.y = C_y * Math.Sin(t);

            return(xy);
        }
Esempio n. 13
0
        //removes LP by ID
        // locates LP in Repo
        // asks user to confirm removal
        // deletes album from AllLPs list
        //Note: if ID does not exist or repo empty (but not null), program will display that it
        //if removing an object but the information is empty
        //specs did not mention to handle this case specifically, but will fix if necessary for the assignment
        public void RemoveLP()
        {
            int x = Viewer.SearchLP(); // will return the interger of the LP ID

            LP LPToBeFound = Repo.ReadById(x);

            if (LPToBeFound == null)
            {
                Console.WriteLine("There was no album in the collection with ID {0}", x);
            }

            else
            {
                Console.WriteLine("you have selected to remove:\nID: {0}, Title: {1}, Artist: {2}, " +
                                  "Release Year: {3}", LPToBeFound.GetID(), LPToBeFound.GetTitle(), LPToBeFound.GetArtist(), LPToBeFound.GetReleaseYear());
                Console.WriteLine("press any key to continue with removal: ");
                Console.ReadKey();
                Console.WriteLine();
                //Repo.Delete(LPToBeFound.GetID());

                if (Viewer.ConfirmRemoveLP(LPToBeFound))
                {
                    Repo.Delete(LPToBeFound.GetID());
                    Console.WriteLine("{0} has been deleted", LPToBeFound.GetTitle());
                }

                else
                {
                    Console.WriteLine("Removal has been cancelled");
                }
            }
        }
Esempio n. 14
0
        // spheroid
        XY s_forward(LP lp)
        {
            XY xy;

            xy.x = xy.y = 0;

            double c = 0.5 * lp.lam;
            double d = Math.Acos(Math.Cos(lp.phi) * Math.Cos(c));

            if (d != 0)          // basic Aitoff
            {
                xy.y  = 1.0 / Math.Sin(d);
                xy.x  = 2.0 * d * Math.Cos(lp.phi) * Math.Sin(c) * xy.y;
                xy.y *= d * Math.Sin(lp.phi);
            }
            else
            {
                xy.x = xy.y = 0;
            }

            if (mode)            // Winkel Tripel
            {
                xy.x = (xy.x + lp.lam * cosphi1) * 0.5;
                xy.y = (xy.y + lp.phi) * 0.5;
            }

            return(xy);
        }
Esempio n. 15
0
        // sphere
        XY s_forward(LP lp)
        {
            XY xy;

            xy.x = xy.y = 0;

            double sp  = Math.Sin(lp.phi);
            double cp  = Math.Cos(lp.phi);
            double dl1 = lp.lam + dlam2;
            double dl2 = lp.lam - dlam2;
            double z1  = Proj.aacos(ctx, sp1 * sp + cp1 * cp * Math.Cos(dl1));
            double z2  = Proj.aacos(ctx, sp2 * sp + cp2 * cp * Math.Cos(dl2));

            z1 *= z1;
            z2 *= z2;
            double t = z1 - z2;

            xy.x = r2z0 * t;
            t    = z02 - t;
            xy.y = r2z0 * Proj.asqrt(4.0 * z02 * z2 - t * t);
            if ((ccs * sp - cp * (cs * Math.Sin(dl1) - sc * Math.Sin(dl2))) < 0.0)
            {
                xy.y = -xy.y;
            }

            return(xy);
        }
Esempio n. 16
0
        // ellipsoid
        XY e_forward(LP lp)
        {
            XY xy;

            xy.x = xy.y = 0;

            COMPLEX p;

            lp.phi = (lp.phi - phi0) * RAD_TO_SEC5;

            int i = tpsi.Length - 1;
            int C = i;

            for (p.r = tpsi[C--]; i > 0; i--)
            {
                p.r = tpsi[C--] + lp.phi * p.r;
            }

            p.r *= lp.phi;
            p.i  = lp.lam;
            p    = p.pj_zpoly1(bf, bf.Length - 1);
            xy.x = p.i;
            xy.y = p.r;

            return(xy);
        }
Esempio n. 17
0
        static bool Init()
        {
            bool                 result               = false;
            LPListener           listener             = null;
            ServerMessageHandler serverMessageHandler = null;

            serverMessageHandler = new ServerMessageHandler();
            if (LOG_ERROR(serverMessageHandler != null))
            {
                goto Exit0;
            }

            result = LP.Init(EPlatform.Pc, true, serverMessageHandler);
            if (ERROR(result))
            {
                goto Exit0;
            }

            listener = LP.NetModule.CreateListener(IPAddress.Parse("127.0.0.1"), 7777, serverMessageHandler);
            if (LOG_ERROR(listener != null))
            {
                goto Exit0;
            }

            result = listener.Start();
            if (LOG_ERROR(result))
            {
                goto Exit0;
            }

            return(true);

Exit0:
            return(false);
        }
Esempio n. 18
0
        // spheroid
        XY s_forward(LP lp)
        {
            XY xy;

            xy.x = xy.y = 0;

            if (Math.Abs(Math.Abs(lp.phi) - Proj.HALFPI) < TOL)
            {
                xy.x = 0;
                xy.y = lp.phi < 0?-2.0:2.0;
            }
            else
            {
                lp.phi = Math.Sin(lp.phi);
                double v = a1 * Math.Pow((1.0 + lp.phi) / (1.0 - lp.phi), hrw);
                lp.lam *= rw;
                double c = 0.5 * (v + 1.0 / v) + Math.Cos(lp.lam);
                if (c < TOL)
                {
                    Proj.pj_ctx_set_errno(ctx, -20); return(xy);
                }
                xy.x = 2.0 * Math.Sin(lp.lam) / c;
                xy.y = (v - 1.0 / v) / c;
            }

            return(xy);
        }
Esempio n. 19
0
        /// <summary>
        /// Print the object's XML to the XmlWriter.
        /// </summary>
        /// <param name="objWriter">XmlTextWriter to write with.</param>
        /// <param name="objCulture">Culture in which to print.</param>
        /// <param name="strLanguageToPrint">Language in which to print</param>
        public void Print(XmlTextWriter objWriter, CultureInfo objCulture, string strLanguageToPrint)
        {
            if (!AllowPrint)
            {
                return;
            }
            objWriter.WriteStartElement("quality");
            objWriter.WriteElementString("name", DisplayNameShort(strLanguageToPrint));
            objWriter.WriteElementString("fullname", DisplayName(strLanguageToPrint));
            objWriter.WriteElementString("formattedname", FormattedDisplayName(objCulture, strLanguageToPrint));
            objWriter.WriteElementString("extra", LanguageManager.TranslateExtra(Extra, strLanguageToPrint));
            objWriter.WriteElementString("lp", LP.ToString(objCulture));
            objWriter.WriteElementString("cost", Cost.ToString(_objCharacter.Options.NuyenFormat, objCulture));
            string strLifestyleQualityType = Type.ToString();

            if (strLanguageToPrint != GlobalOptions.DefaultLanguage)
            {
                XmlNode objNode = XmlManager.Load("lifestyles.xml", strLanguageToPrint).SelectSingleNode("/chummer/categories/category[. = \"" + strLifestyleQualityType + "\"]");
                strLifestyleQualityType = objNode?.Attributes?["translate"]?.InnerText ?? strLifestyleQualityType;
            }
            objWriter.WriteElementString("lifestylequalitytype", strLifestyleQualityType);
            objWriter.WriteElementString("lifestylequalitytype_english", Type.ToString());
            objWriter.WriteElementString("lifestylequalitysource", OriginSource.ToString());
            objWriter.WriteElementString("source", CommonFunctions.LanguageBookShort(Source, strLanguageToPrint));
            objWriter.WriteElementString("page", Page(strLanguageToPrint));
            if (_objCharacter.Options.PrintNotes)
            {
                objWriter.WriteElementString("notes", Notes);
            }
            objWriter.WriteEndElement();
        }
Esempio n. 20
0
 public static LP pj_gauss(projCtx ctx, LP elp, GAUSS en)
 {
     LP slp;
     slp.phi=2.0*Math.Atan(en.K*Math.Pow(Math.Tan(0.5*elp.phi+Proj.FORTPI), en.C)*srat(en.e*Math.Sin(elp.phi), en.ratexp))-Proj.HALFPI;
     slp.lam=en.C*elp.lam;
     return slp;
 }
Esempio n. 21
0
        // spheroid
        XY s_forward(LP lp)
        {
            XY xy;

            xy.x = xy.y = 0;

            double theta = lp.phi;

            if (Math.Abs(Math.Abs(lp.phi) - Proj.HALFPI) >= EPS)
            {
                double c = Math.Sin(theta) * Proj.PI;
                for (int i = NITER; i > 0; i--)
                {
                    double th1 = (theta + Math.Sin(theta) - c) / (1.0 + Math.Cos(theta));
                    theta -= th1;
                    if (Math.Abs(th1) < EPS)
                    {
                        break;
                    }
                }
                theta *= 0.5;
                xy.x   = FXC * lp.lam / (1.0 / Math.Cos(lp.phi) + FXC2 / Math.Cos(theta));
            }

            xy.y = FYC * (lp.phi + FYC2 * Math.Sin(theta));

            return(xy);
        }
Esempio n. 22
0
        // spheroid
        XY s_forward(LP lp)
        {
            XY xy;
            xy.x=xy.y=0;

            double sinphi=Math.Sin(lp.phi);
            double cosphi=Math.Cos(lp.phi);
            double coslam=Math.Cos(lp.lam);

            switch(mode)
            {
                case gnom_mode.EQUIT: xy.y=cosphi*coslam; break;
                case gnom_mode.OBLIQ: xy.y=sinph0*sinphi+cosph0*cosphi*coslam; break;
                case gnom_mode.S_POLE: xy.y=-sinphi; break;
                case gnom_mode.N_POLE: xy.y=sinphi; break;
            }

            if(xy.y<=EPS10) { Proj.pj_ctx_set_errno(ctx, -20); return xy; }

            xy.x=(xy.y=1.0/xy.y)*cosphi*Math.Sin(lp.lam);

            switch(mode)
            {
                case gnom_mode.EQUIT: xy.y*=sinphi; break;
                case gnom_mode.OBLIQ: xy.y*=cosph0*sinphi-sinph0*cosphi*coslam; break;
                case gnom_mode.N_POLE: coslam=-coslam; goto case gnom_mode.S_POLE;
                case gnom_mode.S_POLE: xy.y*=cosphi*coslam; break;
            }

            return xy;
        }
Esempio n. 23
0
        private LP MapLPRecord(string line, StringBuilder trace)
        {
            var record = new LP();

            string[] fields = line.Split(_separator);

            trace.Append($"Reading field: MeterPointCode.{_newLine}");
            record.MeterPointCode = Helper.ConvertToInt(fields[0]);

            trace.Append($"Reading field: SerialNumber.{_newLine}");
            record.SerialNumber = Helper.ConvertToInt(fields[1]);

            trace.Append($"Reading field: PlantCode.{_newLine}");
            record.PlantCode = fields[2];

            trace.Append($"Reading field: DateTime.{_newLine}");
            record.DateTime = Helper.ConvertToDateTimeFromCSV(fields[3]);

            trace.Append($"Reading field: DataType.{_newLine}");
            record.DataType = Helper.ConvertToDataType(fields[4]);

            trace.Append($"Reading field: DataValue.{_newLine}");
            record.DataValue = Helper.ConvertToDecimal(fields[5]);

            trace.Append($"Reading field: Units.{_newLine}");
            record.Units = Helper.ConvertToUnits(fields[6]);

            trace.Append($"Reading field: Status.{_newLine}");
            record.Status = Helper.ConvertToBool(fields[7]);

            return(record);
        }
Esempio n. 24
0
 XY forward(LP lp)
 {
     XY xy;
     xy.x=lp.lam*Proj.RAD_TO_DEG/a;
     xy.y=lp.phi*Proj.RAD_TO_DEG/a;
     return xy;
 }
Esempio n. 25
0
        // ellipsoid
        XY e_rhealpix_forward(LP lp)
        {
            lp.phi = auth_lat(this, lp.phi, false);
            XY xy = healpix_sphere(lp);

            return(combine_caps(xy.x, xy.y, north_square, south_square, false));
        }
Esempio n. 26
0
        // spheroid
        XY s_forward(LP lp)
        {
            XY xy;

            xy.x = xy.y = 0;

            double k = 2.0 * Math.Sin(lp.phi);
            double V = lp.phi * lp.phi;

            lp.phi *= 1.00371 + V * (-0.0935382 + V * -0.011412);

            for (int i = MAX_ITER; i > 0; i--)
            {
                V       = (lp.phi + Math.Sin(lp.phi) - k) / (1.0 + Math.Cos(lp.phi));
                lp.phi -= V;
                if (Math.Abs(V) < LOOP_TOL)
                {
                    break;
                }
            }

            xy.x = 0.5 * lp.lam * (1.0 + Math.Cos(lp.phi));
            xy.y = lp.phi;
            return(xy);
        }
Esempio n. 27
0
        public static LP pj_inv_gauss(projCtx ctx, LP slp, GAUSS en)
        {
            const int MAX_ITER = 20;
            LP        elp;

            elp.phi = 0;

            elp.lam = slp.lam / en.C;
            double num = Math.Pow(Math.Tan(0.5 * slp.phi + Proj.FORTPI) / en.K, 1.0 / en.C);

            int i = MAX_ITER;

            for (; i > 0; i--)
            {
                elp.phi = 2.0 * Math.Atan(num * srat(en.e * Math.Sin(slp.phi), -0.5 * en.e)) - Proj.HALFPI;
                if (Math.Abs(elp.phi - slp.phi) < TOL14)
                {
                    break;
                }
                slp.phi = elp.phi;
            }

            // convergence failed
            if (i == 0)
            {
                Proj.pj_ctx_set_errno(ctx, -17);
            }
            return(elp);
        }
Esempio n. 28
0
        // spheroid
        XY s_forward(LP lp)
        {
            XY xy;

            xy.x = xy.y = 0;

            int i = NITER;

            double c = Math.Sin(lp.phi) * (lp.phi < 0.0?CS:CN);

            for (; i > 0; i--)
            {
                double th1 = (lp.phi + Math.Sin(lp.phi) - c) / (1.0 + Math.Cos(lp.phi));
                lp.phi -= th1;
                if (Math.Abs(th1) < EPS)
                {
                    break;
                }
            }

            lp.phi *= 0.5;

            xy.x = FXC * lp.lam * Math.Cos(lp.phi);
            xy.y = Math.Sin(lp.phi) * (lp.phi < 0.0?FYCS:FYCN);

            return(xy);
        }
Esempio n. 29
0
        // spheroid
        protected XY s_forward(LP lp)
        {
            XY xy;

            xy.x = xy.y = 0;

            double k = C_p * Math.Sin(lp.phi);
            int    i = MAX_ITER;

            for (; i > 0; i--)
            {
                double V = (lp.phi + Math.Sin(lp.phi) - k) / (1.0 + Math.Cos(lp.phi));
                lp.phi -= V;
                if (Math.Abs(V) < LOOP_TOL)
                {
                    break;
                }
            }

            if (i == 0)
            {
                lp.phi = (lp.phi < 0.0)?-Proj.HALFPI:Proj.HALFPI;
            }
            else
            {
                lp.phi *= 0.5;
            }

            xy.x = C_x * lp.lam * Math.Cos(lp.phi);
            xy.y = C_y * Math.Sin(lp.phi);

            return(xy);
        }
Esempio n. 30
0
        // ellipsoid & spheroid
        XY e_forward(LP lp)
        {
            XY xy;

            xy.x = xy.y = 0;

            double V1     = A * Math.Log(Math.Tan(Proj.FORTPI + 0.5 * lp.phi));
            double t      = e * Math.Sin(lp.phi);
            double V2     = 0.5 * e * A * Math.Log((1.0 + t) / (1.0 - t));
            double ps     = 2.0 * (Math.Atan(Math.Exp(V1 - V2 + C)) - Proj.FORTPI);
            double I1     = ps - p0s;
            double cosps  = Math.Cos(ps);
            double cosps2 = cosps * cosps;
            double sinps  = Math.Sin(ps);
            double sinps2 = sinps * sinps;
            double I4     = A * cosps;
            double I2     = 0.5 * A * I4 * sinps;
            double I3     = I2 * A * A * (5.0 * cosps2 - sinps2) / 12.0;
            double I6     = I4 * A * A;
            double I5     = I6 * (cosps2 - sinps2) / 6.0;

            I6  *= A * A * (5.0 * cosps2 * cosps2 + sinps2 * (sinps2 - 18.0 * cosps2)) / 120.0;
            t    = lp.lam * lp.lam;
            xy.x = kRg * lp.lam * (I4 + t * (I5 + t * I6));
            xy.y = kRg * (I1 + t * (I2 + t * I3));
            double x2 = xy.x * xy.x;
            double y2 = xy.y * xy.y;

            V1    = 3.0 * xy.x * y2 - xy.x * x2;
            V2    = xy.y * y2 - 3.0 * x2 * xy.y;
            xy.x += Ca * V1 + Cb * V2;
            xy.y += Ca * V2 - Cb * V1;

            return(xy);
        }
Esempio n. 31
0
        // spheroid
        protected XY s_forward(LP lp)
        {
            XY xy;

            xy.x = xy.y = 0;

            xy.y = bacn?Proj.HALFPI * Math.Sin(lp.phi):lp.phi;
            double ax = Math.Abs(lp.lam);

            if (ax >= EPS)
            {
                if (ortl && ax >= Proj.HALFPI)
                {
                    xy.x = Math.Sqrt(HLFPI2 - lp.phi * lp.phi + EPS) + ax - Proj.HALFPI;
                }
                else
                {
                    double f = 0.5 * (HLFPI2 / ax + ax);
                    xy.x = ax - f + Math.Sqrt(f * f - xy.y * xy.y);
                }
                if (lp.lam < 0.0)
                {
                    xy.x = -xy.x;
                }
            }
            else
            {
                xy.x = 0.0;
            }

            return(xy);
        }
Esempio n. 32
0
        // Return the HEALPix projection of the longitude-latitude point lp on
        // the unit sphere.
        protected XY healpix_sphere(LP lp)
        {
            double lam  = lp.lam;
            double phi  = lp.phi;
            double phi0 = Math.Asin(2.0 / 3.0);

            XY xy;

            // equatorial region
            if (Math.Abs(phi) <= phi0)
            {
                xy.x = lam;
                xy.y = 3.0 * Math.PI / 8.0 * Math.Sin(phi);
            }
            else
            {
                double sigma = Math.Sqrt(3.0 * (1 - Math.Abs(Math.Sin(phi))));
                double cn    = Math.Floor(2 * lam / Math.PI + 2);
                if (cn >= 4)
                {
                    cn = 3;
                }

                double lamc = -3 * Math.PI / 4 + (Math.PI / 2) * cn;
                xy.x = lamc + (lam - lamc) * sigma;
                xy.y = pj_sign(phi) * Math.PI / 4 * (2 - sigma);
            }

            return(xy);
        }
Esempio n. 33
0
        public static bool Test_ClientMessageHandler()
        {
            bool                 result               = false;
            LPConnector          connector            = null;
            ClientMessageHandler clientMessageHandler = null;

            clientMessageHandler = new ClientMessageHandler();
            if (LOG_ERROR(clientMessageHandler != null))
            {
                goto Exit0;
            }

            result = LP.Init(EPlatform.Pc, true, clientMessageHandler);
            if (ERROR(result))
            {
                goto Exit0;
            }

            connector = LP.NetModule.CreateConnector(clientMessageHandler);
            if (LOG_ERROR(connector != null))
            {
                goto Exit0;
            }

            result = connector.Start("127.0.0.1", 7777);
            if (LOG_ERROR(result))
            {
                goto Exit0;
            }

Exit0:
            return(true);
        }
Esempio n. 34
0
        // spheroid
        XY s_forward(LP lp)
        {
            XY xy;
            xy.x=xy.y=0;

            double p=C_p*Math.Sin(lp.phi);
            double s=lp.phi*lp.phi;
            lp.phi*=0.615709+s*(0.00909953+s*0.0046292);

            int i=NITER;
            for(; i>0; i--)
            {
                double c=Math.Cos(lp.phi);
                s=Math.Sin(lp.phi);
                double V=(lp.phi+s*(c-1.0)-p)/(1.0+c*(c-1.0)-s*s);
                lp.phi-=V;
                if(Math.Abs(V)<EPS) break;
            }

            if(i==0) lp.phi=lp.phi<0?-PI_DIV_3:PI_DIV_3;

            xy.x=C_x*lp.lam*(Math.Cos(lp.phi)-0.5);
            xy.y=C_y*Math.Sin(lp.phi);

            return xy;
        }
Esempio n. 35
0
        // spheroid
        XY s_forward(LP lp)
        {
            XY xy;

            xy.x = xy.y = 0;

            double p = B * Math.Sin(lp.phi);

            lp.phi *= 1.10265779;

            int i = NITER;

            for (; i > 0; i--)
            {
                double r = Math.Sqrt(1.0 + lp.phi * lp.phi);
                double V = ((A - r) * lp.phi - Math.Log(lp.phi + r) - p) / (A - 2.0 * r);
                lp.phi -= V;
                if (Math.Abs(V) < EPS)
                {
                    break;
                }
            }

            if (i == 0)
            {
                lp.phi = p < 0.0?-CON_POLE:CON_POLE;
            }

            xy.x = C_x * lp.lam * (D - Math.Sqrt(1.0 + lp.phi * lp.phi));
            xy.y = C_y * lp.phi;

            return(xy);
        }
Esempio n. 36
0
        public void Initialize(ArraySet arraySet, int baseRows, int maximumColumns, Solver solver, int segments)
        {
            this.arraySet = arraySet;
            if (baseRows > arraySet.maxSolverRows || maximumColumns > arraySet.maxSolverCols)
            {
                arraySet.maxSolverRows = Math.Max(baseRows, arraySet.maxSolverRows);
                arraySet.maxSolverCols = Math.Max(maximumColumns, arraySet.maxSolverCols);
                arraySet.RecreateSolverArrays();
            }

            this.solver   = solver;
            this.segments = segments;
            cRows         = baseRows;
            cCols         = 0;

            for (int i = 0; i <= cRows; i++)
            {
                arraySet.rowScale[i] = 1.0;
            }

            if (lp == null)
            {
                lp = new LP(cRows, maximumColumns, arraySet, solver.CalculationOptions.MaxRedecompose);
            }
            else
            {
                lp.Initialize(cRows, maximumColumns, arraySet, solver.CalculationOptions.MaxRedecompose);
            }

            compactSolution = null;
            sort            = null;
            needsDual       = false;
            needsQuadratic  = false;
            maximizeColumn  = -1;
        }
Esempio n. 37
0
        // spheroid
        XY s_forward(LP lp)
        {
            XY xy;
            xy.x=xy.y=0;

            double p=C_p*Math.Sin(lp.phi);
            double V=lp.phi*lp.phi;
            lp.phi*=0.895168+V*(0.0218849+V*0.00826809);

            int i=NITER;
            for(; i>0; i--)
            {
                double c=Math.Cos(lp.phi);
                double s=Math.Sin(lp.phi);
                lp.phi-=V=(lp.phi+s*(c+2.0)-p)/(1.0+c*(c+2.0)-s*s);
                if(Math.Abs(V)<EPS) break;
            }

            if(i==0)
            {
                xy.x=C_x*lp.lam;
                xy.y=lp.phi<0.0?-C_y:C_y;
            }
            else
            {
                xy.x=C_x*lp.lam*(1.0+Math.Cos(lp.phi));
                xy.y=C_y*Math.Sin(lp.phi);
            }

            return xy;
        }
Esempio n. 38
0
		// spheroid
		XY t_forward(LP lp)
		{
			double cosphi=Math.Cos(lp.phi);
			double coslam=Math.Cos(lp.lam);
			lp.lam=Proj.adjlon(Proj.aatan2(cosphi*Math.Sin(lp.lam), Math.Sin(lp.phi))+lamp);
			lp.phi=Proj.aasin(ctx, -cosphi*coslam);

			return link.fwd(lp);
		}
Esempio n. 39
0
        // spheroid
        XY s_forward(LP lp)
        {
            XY xy;
            xy.x=xy.y=0;

            xy.y=C_y*lp.phi;
            xy.x=C_x*lp.lam*(A+Proj.asqrt(1.0-B*lp.phi*lp.phi));
            return xy;
        }
Esempio n. 40
0
        // spheroid
        XY s_forward(LP lp)
        {
            XY xy;
            xy.x=xy.y=0;

            xy.x=rc*lp.lam;
            xy.y=lp.phi-phi0;
            return xy;
        }
Esempio n. 41
0
        // spheroid
        XY s_forward(LP lp)
        {
            XY xy;
            xy.x=xy.y=0;

            xy.x=FC*lp.lam*(1.0-RP*Math.Abs(lp.phi));
            xy.y=FC*lp.phi;
            return xy;
        }
Esempio n. 42
0
		// ellipsoid
		XY e_forward(LP lp)
		{
			XY xy;
			xy.x = xy.y = 0;

			if (lp.phi > Proj.HALFPI) lp.phi = Proj.HALFPI;
			else if (lp.phi < -Proj.HALFPI) lp.phi = -Proj.HALFPI;

			double lampp = lp.phi >= 0.0 ? Proj.HALFPI : PI_HALFPI;
			double tanphi = Math.Tan(lp.phi);

			int l;
			double lamt = 0, lamdp = 0;
			for (int nn = 0; ;)
			{
				double sav = lampp;

				double lamtp = lp.lam + p22 * lampp;
				double cl = Math.Cos(lamtp);
				if (Math.Abs(cl) < TOL) lamtp -= TOL;
				double fac = lampp - Math.Sin(lampp) * (cl < 0.0 ? -Proj.HALFPI : Proj.HALFPI);

				for (l = 50; l != 0; --l)
				{
					lamt = lp.lam + p22 * sav;
					double c = Math.Cos(lamt);
					if (Math.Abs(c) < TOL) lamt -= TOL;
					double xlam = (one_es * tanphi * sa + Math.Sin(lamt) * ca) / c;
					lamdp = Math.Atan(xlam) + fac;
					if (Math.Abs(Math.Abs(sav) - Math.Abs(lamdp)) < TOL) break;

					sav = lamdp;
				}

				if (l == 0 || ++nn >= 3 || (lamdp > rlm && lamdp < rlm2)) break;

				if (lamdp <= rlm) lampp = TWOPI_HALFPI;
				else if (lamdp >= rlm2) lampp = Proj.HALFPI;
			}

			if (l != 0)
			{
				double sp = Math.Sin(lp.phi);
				double phidp = Proj.aasin(ctx, (one_es * ca * sp - sa * Math.Cos(lp.phi) * Math.Sin(lamt)) / Math.Sqrt(1.0 - es * sp * sp));
				double tanph = Math.Log(Math.Tan(Proj.FORTPI + 0.5 * phidp));
				double sd = Math.Sin(lamdp);
				double sdsq = sd * sd;
				double s = p22 * sa * Math.Cos(lamdp) * Math.Sqrt((1.0 + t * sdsq) / ((1.0 + w * sdsq) * (1.0 + q * sdsq)));
				double d = Math.Sqrt(xj * xj + s * s);
				xy.x = b * lamdp + a2 * Math.Sin(2.0 * lamdp) + a4 * Math.Sin(lamdp * 4.0) - tanph * s / d;
				xy.y = c1 * sd + c3 * Math.Sin(lamdp * 3.0) + tanph * xj / d;
			}
			else xy.x = xy.y = Libc.HUGE_VAL;

			return xy;
		}
Esempio n. 43
0
        XY forward(LP lp)
        {
            XY xy;
            xy.x=xy.y=0;

            xy.x=lp.lam;
            xy.y=lp.phi;

            return xy;
        }
Esempio n. 44
0
		// spheroid
		XY s_forward(LP lp)
		{
			XY xy;

			double phi2 = lp.phi * lp.phi;
			xy.x = lp.lam;
			xy.y = lp.phi * (K1 + phi2 * phi2 * (K2 + phi2 * (K3 + K4 * phi2)));

			return xy;
		}
Esempio n. 45
0
        // spheroid
        XY s_forward(LP lp)
        {
            XY xy;
            xy.x=xy.y=0;

            xy.x=C*lp.lam*(A-B*Math.Sqrt(1.0+D*lp.phi*lp.phi));
            xy.y=C*lp.phi;

            return xy;
        }
Esempio n. 46
0
        // spheroid
        XY s_forward(LP lp)
        {
            XY xy;
            xy.x=xy.y=0;

            xy.x=0.5*lp.lam*(cosphi1+Math.Cos(lp.phi));
            xy.y=lp.phi;

            return xy;
        }
Esempio n. 47
0
		// spheroid
		XY o_forward(LP lp)
		{
			double coslam=Math.Cos(lp.lam);
			double sinphi=Math.Sin(lp.phi);
			double cosphi=Math.Cos(lp.phi);
			lp.lam=Proj.adjlon(Proj.aatan2(cosphi*Math.Sin(lp.lam), sphip*cosphi*coslam+cphip*sinphi)+lamp);
			lp.phi=Proj.aasin(ctx, sphip*sinphi-cphip*cosphi*coslam);

			return link.fwd(lp);
		}
Esempio n. 48
0
        // spheroid
        XY s_forward(LP lp)
        {
            XY xy;
            xy.x=xy.y=0;

            xy.x=C*lp.lam*(1.0-A*lp.phi*lp.phi);
            xy.y=C*lp.phi;

            return xy;
        }
Esempio n. 49
0
        // sphere
        XY s_forward(LP lp)
        {
            XY xy;
            xy.x=xy.y=0;

            xy.x=0.5*lp.lam*(1.0+Math.Sqrt(Math.Cos(lp.phi)));
            xy.y=lp.phi/(Math.Cos(0.5*lp.phi)*Math.Cos(SIXTH*lp.lam));

            return xy;
        }
Esempio n. 50
0
        // spheroid
        XY s_forward(LP lp)
        {
            XY xy;
            xy.x=xy.y=0;

            xy.x=XF*(1.0+Math.Cos(lp.phi))*lp.lam;
            xy.y=YF*lp.phi;

            return xy;
        }
Esempio n. 51
0
        // spheroid
        XY s_forward(LP lp)
        {
            XY xy;
            xy.x=xy.y=0;

            xy.x=0.5*lp.lam*(1.0+Math.Cos(lp.phi));
            xy.y=2.0*(lp.phi-Math.Tan(0.5*lp.phi));

            return xy;
        }
Esempio n. 52
0
        // spheroid
        XY s_forward(LP lp)
        {
            XY xy;
            xy.x=xy.y=0;

            xy.x=rk0*Math.Cos(lp.phi)*Math.Sin(lp.lam);
            xy.y=k0*(Math.Atan2(Math.Tan(lp.phi), Math.Cos(lp.lam))-phi0);

            return xy;
        }
Esempio n. 53
0
        // sphere
        XY s_forward(LP lp)
        {
            XY xy;
            xy.x=xy.y=0;

            lp.phi=Proj.aasin(ctx, n*Math.Sin(lp.phi));
            xy.x=C_x*lp.lam*Math.Cos(lp.phi);
            xy.y=C_y*lp.phi;
            return xy;
        }
Esempio n. 54
0
        // spheroid
        XY s_forward(LP lp)
        {
            XY xy;
            xy.x=xy.y=0;

            xy.x=XF*lp.lam;
            xy.y=YF*Math.Tan(0.5*lp.phi);

            return xy;
        }
Esempio n. 55
0
        // spheroid
        XY s_forward(LP lp)
        {
            XY xy;
            xy.x=xy.y=0;

            xy.x=Math.Tan(0.5*lp.phi);
            xy.y=1.819152*xy.x;
            xy.x=0.819152*lp.lam*Proj.asqrt(1-xy.x*xy.x);
            return xy;
        }
Esempio n. 56
0
        // spheroid
        XY s_forward(LP lp)
        {
            XY xy;
            xy.x=xy.y=0;

            double t=Math.Cos(lp.phi);
            xy.x=lp.lam*t/(n+n1*t);
            xy.y=n*lp.phi+n1*Math.Sin(lp.phi);

            return xy;
        }
Esempio n. 57
0
        // spheroid
        XY s_forward(LP lp)
        {
            XY xy;
            xy.x=xy.y=0;

            lp.phi=Math.Asin(CS*Math.Sin(lp.phi));
            xy.x=FXC*lp.lam*(2.0*Math.Cos(C23*lp.phi)-1.0);
            xy.y=FYC*Math.Sin(C13*lp.phi);

            return xy;
        }
Esempio n. 58
0
        // spheroid
        XY s_forward(LP lp)
        {
            XY xy;
            xy.x=xy.y=0;

            lp.phi*=THIRD;
            xy.x=XM*lp.lam*(2.0*Math.Cos(lp.phi+lp.phi)-1.0);
            xy.y=YM*Math.Sin(lp.phi);

            return xy;
        }
Esempio n. 59
0
        // ellipsoid
        XY e_forward(LP lp)
        {
            XY xy;
            xy.x=xy.y=0;

            if(Math.Abs(Math.Abs(lp.phi)-Proj.HALFPI)<=EPS10) { Proj.pj_ctx_set_errno(ctx, -20); return xy; }
            xy.x=k0*lp.lam;
            xy.y=-k0*Math.Log(Proj.pj_tsfn(lp.phi, Math.Sin(lp.phi), e));

            return xy;
        }
Esempio n. 60
0
        // spheroid
        XY s_forward(LP lp)
        {
            XY xy;
            xy.x=xy.y=0;

            xy.y=lp.phi;
            xy.x=lp.lam;
            lp.lam=Math.Abs(lp.lam);
            xy.x*=Math.Cos((C0+lp.lam*(C1+lp.lam*lp.lam*C3))*(lp.phi*(D1+D5*lp.phi*lp.phi*lp.phi*lp.phi)));

            return xy;
        }