Beispiel #1
0
 public void SetTakeOffGate(GpsPoint leftPoint, GpsPoint rightPoint)
 {
     takeOffGate = new Gate(leftPoint, rightPoint);
 }
Beispiel #2
0
 public void AddGpsPoint(GpsPoint gpsPoint)
 {
     gpsPoints.Add(gpsPoint);
 }
Beispiel #3
0
 public void SetMap(string path)
 {
     Bitmap image = new Bitmap(path);
     GpsPoint topLeftPoint;
     GpsPoint bottomRightPoint;
     double topLeftLatitude;
     double topLeftLongitude;
     double bottomRightLatitude;
     double bottomRightLongitude;
     string[] coordinatesFromPath = path.Remove(path.LastIndexOf(".")).Substring(path.LastIndexOf(@"\") + 1).Split("_".ToCharArray());
     foreach (string coordinate in coordinatesFromPath)
     {
         if (coordinate.Length != 6 || coordinate == null || coordinate == string.Empty)
         {
             throw (new FormatException("Coordinates in image name not in correct format!"));
         }
     }
     topLeftLongitude = Convert.ToDouble(coordinatesFromPath[0]);
     topLeftLatitude = Convert.ToDouble(coordinatesFromPath[1]);
     bottomRightLongitude = Convert.ToDouble(coordinatesFromPath[2]);
     bottomRightLatitude = Convert.ToDouble(coordinatesFromPath[3]);
     topLeftPoint = new GpsPoint(topLeftLatitude, topLeftLongitude, GpsPointFormatImport.Swiss);
     bottomRightPoint = new GpsPoint(bottomRightLatitude, bottomRightLongitude, GpsPointFormatImport.Swiss);
     map = new Map(image, topLeftPoint, bottomRightPoint);
 }
Beispiel #4
0
 public Gate(GpsPoint leftPoint, GpsPoint rightPoint)
 {
     this.LeftPoint = leftPoint;
     this.RightPoint = rightPoint;
 }
Beispiel #5
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;
            }
        }
Beispiel #6
0
 public bool Contains(GpsPoint item)
 {
     return items.Contains(item);
 }
Beispiel #7
0
 public void Add(GpsPoint item)
 {
     items.Add(item);
 }
Beispiel #8
0
 public void Remove(GpsPoint item)
 {
     items.Remove(item);
 }
Beispiel #9
0
 /// <summary>
 /// Creates a Map Object. 
 /// 
 /// </summary>
 /// <param name="image">Bitmap Image of the Location, corresponding to the GPS-Points</param>
 /// <param name="topLeftPoint">GPS Point with the Coordinates of the upper Left Point on the Map Image</param>
 /// <param name="bottomRightPoint">GPS Point with the Coordinates of the lower Right Point on the Map Image</param>
 public Map(Bitmap image, GpsPoint topLeftPoint, GpsPoint bottomRightPoint)
 {
     this.Image = image;
     this.TopLeftPoint = topLeftPoint;
     this.BottomRightPoint = bottomRightPoint;
 }
Beispiel #10
0
        public void AddMapImage(string filename)
        {
            this.image = System.Drawing.Image.FromFile(filename);

            string name = filename.Substring(filename.Length - 31, 31);

            int t1 = int.Parse(name.Substring(0, 6));
            int t2 = int.Parse(name.Substring(7, 6));
            int b1 = int.Parse(name.Substring(14, 6));
            int b2 = int.Parse(name.Substring(21, 6));

            this.topLeftPoint = new GpsPoint(t2, t1, GpsPointFormatImport.Swiss);
            this.bottomRightPoint = new GpsPoint(b2, b1, GpsPointFormatImport.Swiss);
        }