Пример #1
0
        public string Encode(FlightRadarData fd, Radar radar, int cnt)
        {
            EncodedData data = new EncodedData();

            //Radar encoding

            /*data.InitialRadar();
             * data.AppendData("0000000000");
             * data.AppendData(Convert.ToString(radar.ID, 16), "00");
             * data.AppendData(dmsToHex(ddToDms(radar.Position.Lat)));
             * data.AppendData(dmsToHex(ddToDms(radar.Position.Lng)));*/

            data.AppendData(cnt.ToString());
            short  positionX = (short)((fd.point.Lng - radar.Position.Lng) * 480);
            short  positionY = (short)((fd.point.Lat - radar.Position.Lat) * 480);
            double speed     = fd.speed;
            double bearing   = fd.bearing;
            short  speedX    = (short)(speed * Math.Sin(bearing * Math.PI / 180));
            short  speedY    = (short)(speed * Math.Cos(bearing * Math.PI / 180));

            data.AppendData(Convert.ToString(positionX, 16).PadLeft(4, '0'));
            data.AppendData(Convert.ToString(positionY, 16).PadLeft(4, '0'));
            data.AppendData(Convert.ToString(speedX, 16).PadLeft(4, '0'));
            data.AppendData(Convert.ToString(speedY, 16).PadLeft(4, '0'));
            data.AppendData(Convert.ToString(fd.Id, 16).PadLeft(4, '0'));
            data.AppendData(Convert.ToString(fd.identification, 16).PadLeft(2, '0'));
            data.AppendData(Convert.ToString(radar.ID, 16));
            return("02" + data.ToString());
        }
Пример #2
0
        public string encodeRadar(Radar radar)
        {
            EncodedData data = new EncodedData();

            //Radar encoding
            data.InitialRadar();
            data.AppendData("0000000000");
            data.AppendData(Convert.ToString(radar.ID, 16), "00");
            data.AppendData(dmsToHex(ddToDms(radar.Position.Lat)));
            data.AppendData(dmsToHex(ddToDms(radar.Position.Lng)));
            return(data.ToString());
        }