public GPX10Track(GPX.XSD.Ver10.gpxTrk trkType)
        {
            _trkType = trkType;
            _uniqueID = GetUniqueKey();

            _trackSegments = GetTrackSegments();
        }
Beispiel #2
0
            public void SQLiteToGPX(GPX gpxFile)
            {
                //----------------------------------------------------------------------------------------------------------------
                //Umwandlung
                //----------------------------------------------------------------------------------------------------------------

                //Datenbank öffnen
                _sqlitebase = new SQLiteBase(_filename);

                //Waypoint Infos holen
                ArrayList WPInformation = new ArrayList();
                _ReadWaypointInformation(WPInformation);

                //Waypoints holen
                _GetWP(WPInformation, gpxFile);

                //Tracks einlesen
                ArrayList TrackInformation = new ArrayList();
                 _ReadTrackInformation(TrackInformation);

                //Tracks holen
                 _GetTracks(TrackInformation, gpxFile);

                //Datenbank zuletzt schließen
                _sqlitebase.CloseDatabase();

                //----------------------------------------------------------------------------------------------------------------
                //Umwandlung ENDE
                //----------------------------------------------------------------------------------------------------------------
            }
Beispiel #3
0
        /// <summary>
        /// Do Work event Handler
        /// </summary>
        /// <param name="sender">Sender Argument</param>
        /// <param name="e">Event Argument</param>
        private void BuildDatabaseBackgroundWorker_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            Tuple <string, string, bool> settings = (Tuple <string, string, bool>)e.Argument;

            if (Directory.Exists(settings.Item1) && File.Exists(this.gpxFilenameTextBox.Text))
            {
                // Load existing POIs
                buildDatabaseBackgroundWorker.ReportProgress(1, "Loading existing POIs");
                Collection <PointOfInterestCategory> currentPois = PointOfInterestDatabase.LoadPois(settings.Item1);

                buildDatabaseBackgroundWorker.ReportProgress(2, "Loading GPX POIs");
                Collection <PointOfInterestCategory> gpxPois = GPX.ProcessGpxFile(this.gpxFilenameTextBox.Text, settings.Item2, settings.Item3);

                buildDatabaseBackgroundWorker.ReportProgress(3, "Merging new POIs");
                Collection <PointOfInterestCategory> pointsOfInterest = PointOfInterestDatabase.MergePointsOfInterest(currentPois, gpxPois);

                buildDatabaseBackgroundWorker.ReportProgress(4, "Building Database");
                int loadedWaypoints = PointOfInterestDatabase.SavePois(pointsOfInterest, settings.Item1, this.buildDatabaseBackgroundWorker);

                e.Result = loadedWaypoints;
            }
            else
            {
                e.Result = -1;
                MessageBox.Show(
                    Resources.FileNotFoundError,
                    Resources.ErrorTitle,
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error,
                    MessageBoxDefaultButton.Button1,
                    MessageBoxOptions.RightAlign);
            }
        }
        void SaveGpx()
        {
            lock (this)
            {
                var fileName      = gpx.Metadata.Time.ToString("yyyy-MM-dd-HH-mm-ss", CultureInfo.InvariantCulture);
                var sdCardPath    = Android.OS.Environment.ExternalStorageDirectory.Path;
                var folderName    = System.IO.Path.Combine(sdCardPath, "LegendDrive/Tracks");
                var fullFileName  = $"{folderName}/gpx_{fileName}.gpx";
                var fullFileName2 = $"{folderName}/gpx_{fileName}.xml";
                try
                {
                    var directory = new DirectoryInfo(folderName);
                    if (!directory.Exists)
                    {
                        directory.Create();
                    }

                    using (var file = File.Create(fullFileName))
                    {
                        serializer.Serialize(file, gpx);
                    }

                    using (var file = File.Create(fullFileName2))
                    {
                        serializer.Serialize(file, gpx);
                    }
                }
                catch (Exception ex)
                {
                    var s = ex.Message;
                }
                gpx = null;
            }
        }
 protected GPX GetGpx(LocationData loc)
 {
     if (gpx != null)
     {
         return(gpx);
     }
     gpx = new GPX()
     {
         Metadata = new Metadata()
         {
             Time          = DateTime.Now,
             TimeSpecified = true
         }
     };
     gpx.WptList.Add(CreateWpt("Start", loc));
     return(gpx);
 }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="rteType"></param>
 public GPX10Route(GPX.XSD.Ver10.gpxRte rteType)
 {
     _rteType = rteType;
     _waypoints = GetRoutePoints();
 }
Beispiel #7
0
        private void ButtonConvert_Click(object sender, EventArgs e)
        {
            //Lege einen Buffer für später an
            byte[] Buffer = new Byte[4096];

            //Frag den Ort ab, an dem die GPX gespeichert werden sollen
            FolderBrowserDialog TmpFolderBrowser = new FolderBrowserDialog();
            TmpFolderBrowser.ShowDialog();

            foreach (object TmpObject in ListBoxOpened.Items)
            {
                //ZipFile initalisieren zum Entpacken
                ZipFile TmpFile = null;

                try
                {
                    //Öffne die Datei aus dem Kasten
                    TmpFile = new ZipFile(TmpObject.ToString());

                    //Gehe Alle Dateien durch
                    foreach (ZipEntry TmpEntry in TmpFile)
                    {
                        //Bis eine den namen ituser.poi hat
                        if (TmpEntry.IsFile && TmpEntry.Name == "ituser.poi\0")
                        {
                            //Wenn das so ist, dann hole dir einen Stream auf dieses File
                            Stream TmpFileStream = TmpFile.GetInputStream(TmpEntry);

                            //erstelle den neuen Dateinamen, indem du den vorhin ausgewählten Pfad nimmst
                            string TmpFullPath = Path.Combine(TmpFolderBrowser.SelectedPath, "ituser.poi");

                            //und erstelle die Datei
                            using (FileStream TmpOutput = File.Create(TmpFullPath))
                            {
                                //anschließend kopiere sie aus der zip dorthin und schließe sie
                                StreamUtils.Copy(TmpFileStream, TmpOutput, Buffer);
                                TmpOutput.Close();

                                //Jetzt erstelle ein GPX und SQL Objekt
                                SQLiteFile sqlitefile = new SQLiteFile(TmpFullPath);
                                GPX gpxfile = new GPX(Path.Combine(TmpFolderBrowser.SelectedPath,Path.ChangeExtension(Path.GetFileName(TmpObject.ToString()),".gpx")));

                                //Gpx File erstellen
                                sqlitefile.SQLiteToGPX(gpxfile);

                                //und schreiben
                                gpxfile.WriteGPX();

                                //TmpOutput löschen
                                File.Delete(TmpFullPath);
                            }

                        }

                    }
                }
                finally
                {
                    if (TmpFile != null)
                    {
                        TmpFile.IsStreamOwner = true;
                        TmpFile.Close();
                    }
                }
            }
        }
Beispiel #8
0
            private void _GetWP(ArrayList WaypointInformation, GPX gpxfile)
            {
                //Die passende SQLite Tabelle lasen
                System.Data.DataTable datatableWP = _sqlitebase.ExecuteQuery("SELECT * FROM \"WP\"");
                System.Data.DataTable datatableGPS = _sqlitebase.ExecuteQuery("SELECT * FROM \"GPSLog\"");

                //Variablen erstellen
                double latitude, longitude, elevation;
                DateTime gpxdatetime;

                //Für jeden Waypoint ausführen:
                foreach (SQLiteWP sqliteWP in WaypointInformation)
                {
                    //Punktdaten holen
                    latitude = (float)(datatableWP.Rows[sqliteWP.WPID-1][9]);
                    longitude = (float)datatableWP.Rows[sqliteWP.WPID-1][8];
                    elevation = (float)datatableWP.Rows[sqliteWP.WPID-1][10];
                    gpxdatetime = DateTime.FromFileTime((((long)(int)datatableGPS.Rows[sqliteWP.WPID-1][2]) << 32) + (int)datatableGPS.Rows[sqliteWP.WPID-1][3]);

                    //Wenn Sommerzeit war, dann ziehe eine Stunde ab
                    TimeZone localZone = TimeZone.CurrentTimeZone;
                    if(localZone.IsDaylightSavingTime(gpxdatetime))
                    {
                        gpxdatetime = gpxdatetime.AddHours(-1);
                    }

                    //Zu UTC konvertieren
                    gpxdatetime = gpxdatetime.ToUniversalTime();

                    //Punkt erstellen
                    DanielLibrary.GPXWriter.Utils.Point pointtmp = new Point(latitude, longitude, elevation, gpxdatetime);

                    //Punkt zum Segment hinzufügen
                    gpxfile.AddPoint(pointtmp);
                }
            }
Beispiel #9
0
            private void _GetTracks(ArrayList TrackInformation, GPX gpxfile)
            {
                //Die passende SQLite Tabelle lasen
                System.Data.DataTable datatableWP = _sqlitebase.ExecuteQuery("SELECT * FROM \"WP\"");
                System.Data.DataTable datatableGPS= _sqlitebase.ExecuteQuery("SELECT * FROM \"GPSLog\"");

                //Für jeden Track ausführen:
                foreach (SQLiteTracks sqlitetrack in TrackInformation)
                {
                    //Tracksegment erstellen
                    TrackSegment tracksegment = new TrackSegment();

                    //Variablen erstellen
                    double latitude,longitude,elevation;
                    DateTime gpxdatetime;

                    //Alle Punkte in der DB ablaufen
                    for (int i = sqlitetrack.FirstWP; i < sqlitetrack.LastWP; i++)
                    {
                        //Punktdaten holen
                        latitude = (float) (datatableWP.Rows[i][9]);
                        longitude = (float) datatableWP.Rows[i][8];
                        elevation = (float) datatableWP.Rows[i][10];
                        gpxdatetime = DateTime.FromFileTime((((long)(int)datatableGPS.Rows[i][2]) << 32)+(int)datatableGPS.Rows[i][3]);

                        //Wenn Sommerzeit war, dann ziehe eine Stunde ab
                        TimeZone localZone = TimeZone.CurrentTimeZone;
                        if(localZone.IsDaylightSavingTime(gpxdatetime))
                        {
                            gpxdatetime = gpxdatetime.AddHours(-1);
                        }

                        //Zu UTC konvertieren
                        gpxdatetime = gpxdatetime.ToUniversalTime();

                        //Punkt erstellen
                        DanielLibrary.GPXWriter.Utils.Point pointtmp = new Point(latitude,longitude,elevation,gpxdatetime);

                        //Punkt zum Segment hinzufügen
                        tracksegment.AddPoint(pointtmp);
                    }

                    //Track erstellen
                    Track track = new Track();

                    //Track, Segment und GPX verbinden
                    track.AddSegment(tracksegment);
                    gpxfile.AddTrack(track);
                }
            }
Beispiel #10
0
 /// <summary>
 /// Construct the vertex from a GPX point
 /// </summary>
 /// <param name="pt">point</param>
 /// <param name="idx">index of the point</param>
 public Vertex(GPX.WayPoint pt, int idx) : this()
 {
     Point = pt;
     Index = idx;
 }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="wptType"></param>
 public GPX10WayPoint(GPX.XSD.Ver10.gpxWpt wptType)
 {
     _wptType = wptType;
 }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="wptType"></param>
 public GPX11WayPoint(GPX.XSD.Ver11.wptType wptType)
 {
     _wptType = wptType;
 }