示例#1
0
文件: Parcours.cs 项目: helios57/anrl
 public Parcours()
 {
     InitializeComponent();
     lstParcours.Items.Clear();
     foreach (t_PolygonGroup pg in InformationPool.Client.GetPolygonGroup())
     {
         PolygonGroup PG = new PolygonGroup(pg);
         lstParcours.Items.Add(PG);
     }
 }
示例#2
0
        /// <summary> 
        /// Imports a DxfFile that is in the specified Format. Any changes on the import schema may cause Errors!
        /// </summary>
        /// <param name="filepath"></param>
        public static PolygonGroup importFromDxf(string filepath)
        {
            PolygonGroup g=new PolygonGroup();

            StreamReader sr = new StreamReader(filepath);
            List<string> lineList = new List<string>();
            while (!sr.EndOfStream){lineList.Add(sr.ReadLine());}
            string[] lines = lineList.ToArray();
            for (int i = 1; i < lines.Length; i++) //Looping through Array, starting with 1 (lines[0] is "0")
            {
                //Find Lines Containing a new Element Definition
                if (lines[i] == "LWPOLYLINE" && lines[i - 1] == "  0") //
                {
                    //Reading out Layer ( "8" [\n] layerName) = Type of Element
                    if (lines[i + 5] == "  8" && lines[i + 6].Contains("PROH")) // "Prohibited Zone" = ForbiddenZone
                    {
                        if (lines[i + 9] == " 90")
                        {
                            int numberOfVertexes = int.Parse(lines[i + 10]);
                            Polygon p = new Polygon();
                            p.ID = g.PolygonIdGen++;
                            p.Type = PolygonType.PenaltyZone;

                            for (int j = 0; j < numberOfVertexes; j++)
                            {
                                PolygonPoint point = new PolygonPoint();
                                point.Longitude = (decimal)CHtoWGSlng(double.Parse(lines[i + (j * 4) + 16], NumberFormatInfo.InvariantInfo) * 1000, double.Parse(lines[i + (j * 4) + 18], NumberFormatInfo.InvariantInfo) * 1000);
                                point.Latitude = (decimal)CHtoWGSlat(double.Parse(lines[i + (j * 4) + 16], NumberFormatInfo.InvariantInfo) * 1000, double.Parse(lines[i + (j * 4) + 18], NumberFormatInfo.InvariantInfo) * 1000);
                                point.ID = p.ID;
                                p.Points.Add(point);
                            }
                            g.Polygons.Add(p);
                        }
                    }
                    else if (lines[i + 5] == "  8" && lines[i + 6].Contains("STARTPOINT-"))
                    {
                        Polygon p = new Polygon();
                        p.ID = g.PolygonIdGen++;
                        p.Type = PolygonType.GateStartA;

                        PolygonPoint point = new PolygonPoint();
                        PolygonPoint point2 = new PolygonPoint();

                        point.Longitude = (decimal)CHtoWGSlng(double.Parse(lines[i + 16], NumberFormatInfo.InvariantInfo) * 1000, double.Parse(lines[i + 18], NumberFormatInfo.InvariantInfo) * 1000);
                        point.Latitude = (decimal)CHtoWGSlat(double.Parse(lines[i + 16], NumberFormatInfo.InvariantInfo) * 1000, double.Parse(lines[i + 18], NumberFormatInfo.InvariantInfo) * 1000);
                        point.ID = p.ID;
                        p.Points.Add(point);

                        point2.Longitude = (decimal)CHtoWGSlng(double.Parse(lines[i + 20], NumberFormatInfo.InvariantInfo) * 1000, double.Parse(lines[i + 22], NumberFormatInfo.InvariantInfo) * 1000);
                        point2.Latitude = (decimal)CHtoWGSlat(double.Parse(lines[i + 20], NumberFormatInfo.InvariantInfo) * 1000, double.Parse(lines[i + 22], NumberFormatInfo.InvariantInfo) * 1000);
                        point2.ID = p.ID;
                        p.Points.Add(point2);

                        string gatename = lines[i + 6].Substring(11, 1);
                        g.Polygons.Add(p);
                    }
                    else if (lines[i + 5] == "  8" && lines[i + 6].Contains("ENDPOINT-"))
                    {
                        Polygon p = new Polygon();
                        p.ID = g.PolygonIdGen++;
                        p.Type = PolygonType.GateEndA;

                        PolygonPoint point = new PolygonPoint();
                        PolygonPoint point2 = new PolygonPoint();

                        point.Longitude = (decimal)CHtoWGSlng(double.Parse(lines[i + 16], NumberFormatInfo.InvariantInfo) * 1000, double.Parse(lines[i + 18], NumberFormatInfo.InvariantInfo) * 1000);
                        point.Latitude = (decimal)CHtoWGSlat(double.Parse(lines[i + 16], NumberFormatInfo.InvariantInfo) * 1000, double.Parse(lines[i + 18], NumberFormatInfo.InvariantInfo) * 1000);
                        point.ID = p.ID;
                        p.Points.Add(point);

                        point2.Longitude = (decimal)CHtoWGSlng(double.Parse(lines[i + 20], NumberFormatInfo.InvariantInfo) * 1000, double.Parse(lines[i + 22], NumberFormatInfo.InvariantInfo) * 1000);
                        point2.Latitude = (decimal)CHtoWGSlat(double.Parse(lines[i + 20], NumberFormatInfo.InvariantInfo) * 1000, double.Parse(lines[i + 22], NumberFormatInfo.InvariantInfo) * 1000);
                        point2.ID = p.ID;
                        p.Points.Add(point2);

                        string gatename = lines[i + 6].Substring(9, 1);
                        g.Polygons.Add(p);
                    }
                    else if (lines[i + 5] == "  8" && lines[i + 6].Contains("NBLINE"))
                    {
                        if (lines[i + 9] == " 90" && double.Parse(lines[10], NumberFormatInfo.InvariantInfo) == 2)
                        {
                            Polygon p = new Polygon();
                            p.ID = g.PolygonIdGen++;
                            p.Type = PolygonType.EndLine;

                            PolygonPoint point = new PolygonPoint();
                            PolygonPoint point2 = new PolygonPoint();

                            point.Longitude = (decimal)CHtoWGSlng(double.Parse(lines[i + 16], NumberFormatInfo.InvariantInfo) * 1000, double.Parse(lines[i + 18], NumberFormatInfo.InvariantInfo) * 1000);
                            point.Latitude = (decimal)CHtoWGSlat(double.Parse(lines[i + 16], NumberFormatInfo.InvariantInfo) * 1000, double.Parse(lines[i + 18], NumberFormatInfo.InvariantInfo) * 1000);
                            point.ID = p.ID;
                            p.Points.Add(point);

                            point2.Longitude = (decimal)CHtoWGSlng(double.Parse(lines[i + 20], NumberFormatInfo.InvariantInfo) * 1000, double.Parse(lines[i + 22], NumberFormatInfo.InvariantInfo) * 1000);
                            point2.Latitude = (decimal)CHtoWGSlat(double.Parse(lines[i + 20], NumberFormatInfo.InvariantInfo) * 1000, double.Parse(lines[i + 22], NumberFormatInfo.InvariantInfo) * 1000);
                            point2.ID = p.ID;
                            p.Points.Add(point2);

                            g.Polygons.Add(p);
                        }
                    }
                }
            }
            PolygonGroupToDraw = g;
            return g;
        }
示例#3
0
        public RaceEntry(t_Race Race)
        {
            InformationPool.PilotList.Clear();
            foreach (t_Pilot p in InformationPool.Client.GetPilots())
            {
                InformationPool.PilotList.Add(p);
            }
            this.ID = Race.ID;
            this.Name = Race.Name;
            if (Race.ID_Pilot_0 > 0) this.PilotA = (int)Race.ID_Pilot_0;
            if (Race.ID_Pilot_1 > 0) this.PilotB = (int)Race.ID_Pilot_1;
            if (Race.ID_Pilot_2 > 0) this.PilotC = (int)Race.ID_Pilot_2;
            if (Race.ID_Pilot_3 > 0) this.PilotD = (int)Race.ID_Pilot_3;

            this.Polygons = new PolygonGroup();
            Polygons.ID = (int)Race.ID_PolygonGroup;
            Polygons.Name = Race.ID_PolygonGroup.ToString();
            this.StartTime = (DateTime)Race.TimeStart;
            DateTime EndTime = (DateTime)Race.TimeEnd;
            this.Duration = (decimal)(EndTime - StartTime).TotalMinutes;
        }
示例#4
0
 public RaceEntry(String[] Values)
 {
     this.ID = int.Parse(Values[0]);
     this.Name = Values[1];
     this.PilotA = int.Parse(Values[2]);
     this.PilotB = int.Parse(Values[3]);
     this.PilotC = int.Parse(Values[4]);
     this.PilotD = int.Parse(Values[5]);
     this.Polygons = new PolygonGroup();
     Polygons.Polygons.Add(new Polygon());
     Polygons.Polygons.First().ID = int.Parse(Values[6]);
     this.StartTime = DateTime.Parse(Values[8]);
     DateTime EndTime = DateTime.Parse(Values[7]);
     this.Duration = (decimal)(EndTime - StartTime).TotalMilliseconds;
 }
示例#5
0
 public RaceEntry()
 {
     StartTime = DateTime.Now;
     Polygons = new PolygonGroup();
 }