示例#1
0
文件: Parcours.cs 项目: helios57/anrl
        public bool IsPointOffTrack(TrackPoint pointToTest)
        {
            double y = pointToTest.Latitude;
            double x = pointToTest.Longitude;
            bool isOffTrack = false;

            foreach (ForbiddenZone forbiddenZone in this.forbiddenZones)
            {
                int polySides = forbiddenZone.GpsPoints.Count - 1;
                double[] polyY = new double[forbiddenZone.GpsPoints.Count];
                double[] polyX = new double[forbiddenZone.GpsPoints.Count];

                int k = 0;
                foreach (GpsPoint gpsPoint in forbiddenZone.GpsPoints)
                {
                    polyY[k] = gpsPoint.Latitude;
                    polyX[k] = gpsPoint.Longitude;
                    k++;
                }

                int i, j = polySides - 1;
                bool oddNodes = false;

                for (i = 0; i < polySides; i++)
                {
                    if (polyY[i] < y && polyY[j] >= y || polyY[j] < y && polyY[i] >= y)
                    {
                        if (polyX[i] + (y - polyY[i]) / (polyY[j] - polyY[i]) * (polyX[j] - polyX[i]) < x)
                        {
                            oddNodes = !oddNodes;
                        }
                    }
                    j = i;
                }
                isOffTrack = oddNodes;
                if (isOffTrack)
                    return isOffTrack;

            }
            return isOffTrack;
        }
示例#2
0
 public bool IsPointInZone(TrackPoint currentTrackPoint)
 {
     // ToDo: move strange things from Common class here
     throw new NotImplementedException();
 }
示例#3
0
 public void Remove(TrackPoint item)
 {
     base.Remove(item);
 }
示例#4
0
 public bool Contains(TrackPoint item)
 {
     return base.Contains(item);
 }
示例#5
0
 public void Add(TrackPoint item)
 {
     base.Add(item);
 }
示例#6
0
文件: Flight.cs 项目: helios57/anrl
        /// <summary>
        /// Imports a GAC File of a Flight.
        /// </summary>
        /// <param name="filepath"></param>
        /// <returns>The created Flight object</returns>
        public void dataFromGAC(string filename)
        {
            TrackPointCollection trackpoints = new TrackPointCollection();
            StreamReader gacFileStreamReader = new StreamReader(filename);
            string line = string.Empty;
            DateTime newPointTimeStamp = DateTime.Now;
            double newPointLatitude = 0;
            double newPointLongitude = 0;
            line = gacFileStreamReader.ReadLine();
            while (!line.Substring(0, 1).Equals("I") && !gacFileStreamReader.EndOfStream)
            {
                line = gacFileStreamReader.ReadLine();
            }
            {
                while (!gacFileStreamReader.EndOfStream)
                {
                    line = gacFileStreamReader.ReadLine();
                    if (line.Substring(0, 1).Equals("B"))
                    {
                        // timestamp
                        newPointTimeStamp = new DateTime(1, 1, 1, Convert.ToInt32(line.Substring(1, 2)), Convert.ToInt32(line.Substring(3, 2)), Convert.ToInt32(line.Substring(5, 2)));
                        // latitude
                        newPointLatitude = Convert.ToDouble(line.Substring(7, 2)) * 3600 + Convert.ToDouble(line.Substring(9, 2)) * 60 + Convert.ToDouble(line.Substring(11, 3)) * 60 / 1000;
                        switch (line.Substring(14, 1))
                        {
                            case "N":
                                break;
                            case "S":
                                newPointLatitude *= (-1);
                                break;
                            default:
                                // TODO: Error
                                break;
                        }
                        // longitude
                        newPointLongitude = Convert.ToDouble(line.Substring(15, 3)) * 3600 + Convert.ToDouble(line.Substring(18, 2)) * 60 + Convert.ToDouble(line.Substring(20, 3)) * 60 / 1000;
                        switch (line.Substring(23, 1))
                        {
                            case "E":
                                break;
                            case "W":
                                newPointLongitude *= (-1);
                                break;
                            default:
                                // ToDo: Error
                                break;
                        }
                        TrackPoint newTrackPoint = new TrackPoint(newPointLatitude, newPointLongitude, newPointTimeStamp, GpsPointFormatImport.WGS84);

                        trackpoints.Add(newTrackPoint);
                    }
                }
            }
            this.track = trackpoints;
        }