Exemplo n.º 1
0
        /// <summary>
        /// cTor: populate the record
        /// </summary>
        /// <param name="id">ident (UPPERCASE)</param>
        public aptRec(string icaoName, string rwyIdent, string landElev, string latS, string lonS)
        {
            icao_id = icaoName.ToUpperInvariant( );

            if (rwyIdent.Length < 4)
            {
                return;                   // ERROR cannot use without runway
            }
            rwy_id  = rwyIdent.ToUpperInvariant( );
            rwy_num = rwy_id.Substring(2, 2);
            if (rwyIdent.Length > 4)
            {
                rwy_side = rwy_id.Substring(4, 1);
            }

            string revSide = rwy_side; // can be empty or "C"

            if (rwy_side == "R")
            {
                revSide = "L";              // reverse
            }
            if (rwy_side == "L")
            {
                revSide = "R";              // reverse
            }
            double forward = int.Parse(rwy_num) * 10;
            double reverse = forward.AddDegrees(180); // takes care of the circle overflow

            rev_rwy_ident = $"{icao_id}_RW{(int)Math.Round( reverse / 10 ):00}{revSide}";

            if (!int.TryParse(landElev, out int e))
            {
                return;                                    // ERROR cannot use without valid elevation
            }
            elevation = landElev;

            // translate lat, lon  ;N42395806 , W083260384, E008320987
            if (latS.Length < 9)
            {
                return;                 // ERROR cannot use without Lat
            }
            if (lonS.Length < 10)
            {
                return;                // ERROR cannot use without Lon
            }
            var ll = CnvAptDMS(latS, lonS);

            lat = ll.Lat.ToString( );
            lon = ll.Lon.ToString( );

            ident = $"{icao_id}_{rwy_id}";
        }