예제 #1
0
파일: Common.cs 프로젝트: helios57/anrl
        /// <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 Parcours importFromDxf(string filepath)
        {
            Parcours parcours = new Parcours();

            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]);
                            ForbiddenZone forbiddenZone = new ForbiddenZone();
                            for (int j = 0; j < numberOfVertexes; j++)
                            {
                                forbiddenZone.AddGpsPoint(new GpsPoint(double.Parse(lines[i + (j * 4) + 18]) * 1000, double.Parse(lines[i + (j * 4) + 16]) * 1000, GpsPointFormatImport.Swiss));
                            }
                            parcours.ForbiddenZones.Add(forbiddenZone);
                        }
                    }
                    else if (lines[i + 5] == "  8" && lines[i + 6].Contains("STARTPOINT-"))
                    {
                        Gate g = new Gate(new GpsPoint(double.Parse(lines[i + 18]) * 1000, double.Parse(lines[i + 16]) * 1000, GpsPointFormatImport.Swiss),
                                     new GpsPoint(double.Parse(lines[i + 22]) * 1000, double.Parse(lines[i + 20]) * 1000, GpsPointFormatImport.Swiss));

                        int gatenr = int.Parse(lines[i + 6].Substring(11, 1)) - 1;
                        // ToDo: add gate
                        //parcours.addGate(g, gatenr, 0);
                    }
                    else if (lines[i + 5] == "  8" && lines[i + 6].Contains("ENDPOINT-"))
                    {
                        Gate g = new Gate(new GpsPoint(double.Parse(lines[i + 18]) * 1000, double.Parse(lines[i + 16]) * 1000, GpsPointFormatImport.Swiss),
                                     new GpsPoint(double.Parse(lines[i + 22]) * 1000, double.Parse(lines[i + 20]) * 1000, GpsPointFormatImport.Swiss));

                        int gatenr = int.Parse(lines[i + 6].Substring(9, 1)) - 1;
                        // ToDo: add gate
                        //parcours.addGate(g, gatenr, 1);
                        //parcours.gates[gatenr, 1] = g;
                    }
                    else if (lines[i + 5] == "  8" && lines[i + 6].Contains("NBLINE"))
                    {
                        if (lines[i + 9] == " 90" && double.Parse(lines[10]) == 2)
                        {
                            parcours.NbLine = new Gate(new GpsPoint(double.Parse(lines[i + 18]) * 1000, double.Parse(lines[i + 16]) * 1000, GpsPointFormatImport.Swiss),
                                new GpsPoint(double.Parse(lines[i + 22]) * 1000, double.Parse(lines[i + 20]) * 1000, GpsPointFormatImport.Swiss));
                        }
                    }
                }
            }
            return parcours;
        }
예제 #2
0
 public void Add(ForbiddenZone item)
 {
     items.Add(item);
 }
예제 #3
0
 public bool Contains(ForbiddenZone item)
 {
     return items.Contains(item);
 }
예제 #4
0
 public void Remove(ForbiddenZone item)
 {
     items.Remove(item);
 }