NASAExplorer.Services.HorizonInterface.GetCoordinates C# (CSharp) Method

GetCoordinates() public method

public GetCoordinates ( int Id ) : List
Id int
return List
        public List<Coord> GetCoordinates(int Id)
        {
            List<Coord> loc = new List<Coord>();
            string buffer = "";
            List<string> stopString = new List<string>();

            stopString.Add("$$SOE");
            stopString.Add("$$EOE");

            buffer = Conn.ReadUntil(">");
            Conn.Write(String.Format("{0}\n", Id));

            for (int i = 0; i <= _cmds.Count - 1; i++)
            {
                buffer += Conn.Read();//(_cmds[i].Key, 100);
                Conn.WriteLine(_cmds[i].Value);
            }

            buffer += Conn.Read();
            buffer = buffer.Split(stopString.ToArray(), StringSplitOptions.RemoveEmptyEntries)[1];

            foreach (string set in Regex.Split(buffer.Trim(), "\r\n"))
            {
                string[] element = set.Split(',');
                if (element.Length > 0)
                {
                    Coord temp = new Coord();

                    temp.X = double.Parse(element[2]);
                    temp.Y = double.Parse(element[3]);
                    temp.Z = double.Parse(element[4]);

                    loc.Add(temp);
                }
            }
            /*
            TcpClient client = new TcpClient(HOST, PORT);
            TelnetStream conn = new TelnetStream(client.GetStream());

            conn.SetRemoteMode(TelnetOption.Echo, false);
            Expector expect = new Expector(conn);

            expect.Expect("Horizons>");
            expect.SendLine(String.Format("{0}\n", Id));

            for (var i = 0; i <= 14; i++)
            {
                expect.Expect(_cmds[i].Key);
                expect.SendLine(_cmds[i].Value);
            }
            */
            return loc;
        }

Usage Example

Example #1
0
        public JsonResult GetCoordsByDate(DateTime start, DateTime end, int id = 399)
        {
            HorizonInterface horizon = new HorizonInterface(start, end);
            var xyz = horizon.GetCoordinates(id);

            return Json(xyz, JsonRequestBehavior.AllowGet);
        }
All Usage Examples Of NASAExplorer.Services.HorizonInterface::GetCoordinates