Exemple #1
0
 public Race()
     : base()
 {
     competitors = new CompetitorCollection();
     competitorGroups = new CompetitorGroupCollection();
     flights = new FlightCollection();
     date = new DateTime();
     map = new Map();
     takeOffGate = new Gate();
     defaultRunway = true;
     defaultTargetFlightDuration = new TimeSpan(0);
     timeToStartGateDefault = new TimeSpan(0);
     timeToStartGateAlternative = new TimeSpan(0);
 }
Exemple #2
0
 public void SetTakeOffGate(GpsPoint leftPoint, GpsPoint rightPoint)
 {
     takeOffGate = new Gate(leftPoint, rightPoint);
 }
Exemple #3
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 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;
        }
Exemple #4
0
        /// <summary>
        /// Returns true if the specified Gate was passed between the GPSPoints p1, p2
        /// </summary>
        /// <param name="gate"></param>
        /// <param name="p1"></param>
        /// <param name="p2"></param>
        /// <returns></returns>
        public static bool gatePassed(Gate gate, GpsPoint p1, GpsPoint p2)
        {
            double Ax = gate.LeftPoint.Longitude;
            double Ay = gate.LeftPoint.Latitude;
            double Bx = gate.RightPoint.Longitude;
            double By = gate.RightPoint.Latitude;
            double Cx = p1.Longitude;
            double Cy = p1.Latitude;
            double Dx = p2.Longitude;
            double Dy = p2.Latitude;
            //double* X, double* Y

            double distAB, theCos, theSin, newX, ABpos;

            //  Fail if either line segment is zero-length.
            if (Ax == Bx && Ay == By || Cx == Dx && Cy == Dy) return false;

            //  Fail if the segments share an end-point.
            if (Ax == Cx && Ay == Cy || Bx == Cx && By == Cy
                || Ax == Dx && Ay == Dy || Bx == Dx && By == Dy)
            {
                return false;
            }

            //  (1) Translate the system so that point A is on the origin.
            Bx -= Ax;
            By -= Ay;
            Cx -= Ax;
            Cy -= Ay;
            Dx -= Ax;
            Dy -= Ay;

            //  Discover the length of segment A-B.
            distAB = Math.Sqrt(Bx * Bx + By * By);

            //  (2) Rotate the system so that point B is on the positive X axis.
            theCos = Bx / distAB;
            theSin = By / distAB;
            newX = Cx * theCos + Cy * theSin;
            Cy = Cy * theCos - Cx * theSin;
            Cx = newX;
            newX = Dx * theCos + Dy * theSin;
            Dy = Dy * theCos - Dx * theSin;
            Dx = newX;

            //  Fail if segment C-D doesn't cross line A-B.
            if (Cy < 0.0 && Dy < 0.0 || Cy >= 0.0 && Dy >= 0.0)
                return false;

            //  (3) Discover the position of the intersection point along line A-B.
            ABpos = Dx + (Cx - Dx) * Dy / (Dy - Cy);

            //  Fail if segment C-D crosses line A-B outside of segment A-B.
            if (ABpos < 0.0 || ABpos > distAB)
                return false;
            else
            {
                return true;
            }
        }
Exemple #5
0
 public bool Contains(Gate item)
 {
     return items.Contains(item);
 }
Exemple #6
0
 public void Add(Gate item)
 {
     items.Add(item);
 }
Exemple #7
0
 public void Remove(Gate item)
 {
     items.Remove(item);
 }