コード例 #1
0
ファイル: GpsTrackResolver.cs プロジェクト: meghuizen/fotofly
        public void Add(GpsFile gpsFile)
        {
            if (gpsFile != null && gpsFile.Tracks != null && gpsFile.Tracks.Count > 0)
            {
                // Loop through each Track
                foreach (GpsTrack gpsTrack in gpsFile.Tracks)
                {
                    // Loop through each Segment
                    foreach (GpsTrackSegment gpsTrackSegment in gpsTrack.Segments)
                    {
                        // Loop through each Point
                        foreach (GpsTrackPoint gpsTrackPoint in gpsTrackSegment.Points)
                        {
                            GpsPosition newCoordinate = new GpsPosition();
                            newCoordinate.Time              = gpsTrackPoint.Time;
                            newCoordinate.Latitude.Numeric  = gpsTrackPoint.LatitudeAsDouble;
                            newCoordinate.Longitude.Numeric = gpsTrackPoint.LongitudeAsDouble;
                            newCoordinate.Altitude          = gpsTrackPoint.Altitude;

                            // Use the tracks data or the parameter override
                            newCoordinate.Source = string.IsNullOrEmpty(this.GpsTrackSource) ? gpsTrackPoint.Source : this.GpsTrackSource;

                            // Add the point to the cache
                            this.TrackPoints.Add(newCoordinate);
                        }
                    }
                }

                // ReOptimise the Track
                this.OptimiseTrack();
            }
        }
コード例 #2
0
ファイル: NmeaFileManager.cs プロジェクト: meghuizen/fotofly
        public static GpsFile Read(string fileName)
        {
            GpsFile gpsFile = new GpsFile();

            gpsFile.Tracks.Add(new GpsTrack());
            gpsFile.Tracks.First().Segments.Add(new GpsTrackSegment());

            List <List <string> > nmeaFile = NmeaFileManager.ReadFile(fileName);

            // Save the current date
            DateTime currentDate;

            // Look for first GPGGA record, which contains the current date
            List <string> gprmcRecord = nmeaFile.Where(x => x[0].StartsWith("$GPRMC")).FirstOrDefault();

            if (gprmcRecord == null)
            {
                throw new Exception("Unable to find a valid GPRMC in the Nmea file");
            }
            else
            {
                currentDate = NmeaFileManager.ParseGPRMC(gprmcRecord);
            }

            foreach (List <string> nmeaLine in nmeaFile)
            {
                // See what type of data it is
                switch (nmeaLine[0])
                {
                case "$GPRMC":
                    // Date
                    currentDate = NmeaFileManager.ParseGPRMC(nmeaLine);
                    break;

                case "$GPGGA":
                    // Gps Coordinate
                    GpsTrackPoint trackPoint = NmeaFileManager.ParseGPGGA(nmeaLine, currentDate);

                    if (trackPoint.IsValidCoordinate)
                    {
                        gpsFile.Tracks.Last().Segments.Last().Points.Add(trackPoint);
                    }
                    break;

                default:
                    break;
                }
            }

            return(gpsFile);
        }
コード例 #3
0
ファイル: TraceFile.cs プロジェクト: BJFX/UWSensorControl
 public void SaveGPS(GPSInfo gpsInfo)
 {
     if (Path == null)
     {
         return;
     }
     if (GpsFile == null)
     {
         GpsFile = new ADFile("GPS", "dat");
         GpsFile.SetFileSizeLimit(GPSFileSize);
         GpsFile.SetPath(new DirectoryInfo(Path));
         GpsFile.Create();
     }
     if (GpsFile.Write(gpsInfo.SavePackage()) == 0)
     {
         throw new Exception("创建GPS文件失败!");
     }
 }
コード例 #4
0
ファイル: TraceFile.cs プロジェクト: BJFX/UWSensorControl
 public void Close()
 {
     Path = null;
     if (GpsFile != null)
     {
         GpsFile.Close();
     }
     if (PoseFile != null)
     {
         PoseFile.Close();
     }
     if (ADFile != null)
     {
         ADFile.Close();
     }
     if (PosFile != null)
     {
         PosFile.Close();
     }
     if (SonarSetting != null)
     {
         SonarSetting.Close();
     }
 }