public override void OnInspectorGUI() { base.OnInspectorGUI(); Track track = (Track)target; if (GUILayout.Button("Add Segment")) { track.AddSegment(); } }
private void OpenGpxRibbonButton_Click(object sender, RoutedEventArgs e) { Gpx gpxFile = new Gpx(); string gpxFilename = OpenGpxDialog(); if (gpxFilename == null) { return; } XElement gpxXe = XElement.Load(gpxFilename); var trkList = gpxXe.Elements().Where(el => el.Name.LocalName == "trk").ToList(); foreach (var trkXe in trkList) { Track track = new Track(); foreach (var trksegXe in trkXe.Elements().Where(el => el.Name.LocalName == "trkseg").ToList()) { TrackSegment segment = new TrackSegment(); foreach (var trkptXe in trksegXe.Elements().Where(el => el.Name.LocalName == "trkpt").ToList()) { double latValue = double.Parse(trkptXe.Attribute("lat").Value, System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture); double longValue = double.Parse(trkptXe.Attribute("lon").Value, System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture); DateTime time = DateTime.Parse(trkptXe.Elements().First(el => el.Name.LocalName == "time").Value); segment.AddPoint(new TrackPoint { Latitude = latValue, Longtitude = longValue, Time = time }); } track.AddSegment(segment); LocationCollection locations = new LocationCollection(); foreach (var point in segment.GetPoints()) { locations.Add(new Location { Latitude = point.Latitude, Longitude = point.Longtitude }); } MapPolyline line = CreateMapLine(locations); TracksMap.Children.Add(line); } gpxFile.AddTrack(track); } }
public GpxFile ApplyFilter(GpxFile input) { GpxFile output = CreateGpxFileCopy(input); foreach (Track track in input.Tracks) { Track outputTrack = CreateTrackCopy(track); foreach (TrackSegment segment in track.Segments) { IList <TrackPoint> filteredPoints = ApplyFilter(segment); TrackSegment outputSegment = new TrackSegment(filteredPoints); outputTrack.AddSegment(outputSegment); } output.AddTrack(outputTrack); } foreach (Track track in input.Routes) { Track outputTrack = CreateTrackCopy(track); foreach (TrackSegment segment in track.Segments) { IList <TrackPoint> filteredPoints = ApplyFilter(segment); TrackSegment outputSegment = new TrackSegment(filteredPoints); outputTrack.AddSegment(outputSegment); } output.AddRoute(outputTrack); } IList <TrackPoint> filteredWaypoints = ApplyFilter(input.Waypoints); output.AddWaypoints(filteredWaypoints); return(output); }
private void Waypoints2TrackRibbonButton_Click(object sender, RoutedEventArgs e) { Gpx gpxFile = new Gpx(); string gpxFilename = OpenGpxDialog(); if (gpxFilename == null) { return; } XElement gpxXe = XElement.Load(gpxFilename); Track track = new Track(); TrackSegment segment = new TrackSegment(); var rteList = gpxXe.Elements().Where(el => el.Name.LocalName == "rte").ToList(); if (rteList.Count != 0) { foreach (var rteXe in rteList) { var rteptList = rteXe.Elements().Where(el => el.Name.LocalName == "rtept").ToList(); foreach (var rteptXe in rteptList) { double latValue = double.Parse(rteptXe.Attribute("lat").Value, System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture); double longValue = double.Parse(rteptXe.Attribute("lon").Value, System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture); segment.AddPoint(new TrackPoint { Latitude = latValue, Longtitude = longValue }); } } track.AddSegment(segment); gpxFile.AddTrack(track); } var trkList = gpxXe.Elements().Where(el => el.Name.LocalName == "trk").ToList(); foreach (var trkXe in trkList) { var trksegList = trkXe.Elements().Where(el => el.Name.LocalName == "trkseg").ToList(); foreach (var trksegXe in trksegList) { var trkptList = trksegXe.Elements().Where(el => el.Name.LocalName == "trkpt").ToList(); foreach (var trkptXe in trkptList) { double latValue = double.Parse(trkptXe.Attribute("lat").Value, System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture); double longValue = double.Parse(trkptXe.Attribute("lon").Value, System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture); segment.AddPoint(new TrackPoint { Latitude = latValue, Longtitude = longValue }); } } track.AddSegment(segment); gpxFile.AddTrack(track); } LocationCollection locations = new LocationCollection(); foreach (var point in segment.GetPoints()) { locations.Add(new Location { Latitude = point.Latitude, Longitude = point.Longtitude }); } MapPolyline line = CreateMapLine(locations); TracksMap.Children.Add(line); StartEndDateWindow window = new StartEndDateWindow(track); window.ShowDialog(); }
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); } }