Esempio n. 1
0
        static void Sort(string folder, string targetFile)
        {
            var points = Directory.GetFiles(Path.GetFullPath(folder), "*.gpx")
                         .SelectMany(file => GpxFile.Load(file).Tracks)
                         .SelectMany(trk => trk.Segments)
                         .SelectMany(seg => seg.Points)
                         .Distinct();

            var gpx = new GpxFile();

            foreach (var trkpt in points)
            {
                gpx.AddTrackPoint(trkpt);
            }

            gpx.Metadata = new Metadata()
            {
                Name   = "Food & wine cruise, 2018",
                Author = new Person()
                {
                    Name  = "Keith Fletcher",
                    Email = new Email("*****@*****.**"),
                },
                Copyright = new Copyright("Keith Fletcher")
                {
                    Year = 2018
                },
                Time = DateTime.Now
            };

            gpx.Save(targetFile, true);
            Console.WriteLine();
        }
Esempio n. 2
0
        static void ChangeToRoute()
        {
            var points = GpxFile.Load("Track.gpx")
                         .Tracks
                         .SelectMany(t => t.Segments)
                         .SelectMany(s => s.Points);

            var gpx = new GpxFile();

            foreach (var pt in points)
            {
                gpx.AddRoutePoint(pt);
            }
            gpx.Save("Route.gpx", true);
        }
Esempio n. 3
0
        static void ChangeToWaypoints()
        {
            var points = GpxFile.Load("Track.gpx")
                         .Tracks
                         .SelectMany(t => t.Segments)
                         .SelectMany(s => s.Points);

            var gpx = new GpxFile();
            var i   = 1;

            foreach (var pt in points)
            {
                pt.Name        = $"My waypoint - {i++}";
                pt.Description = $"Desc My waypoint - {i++}";
                gpx.AddWaypoint(pt);
            }
            gpx.Save("Waypoints.gpx", true);
        }
Esempio n. 4
0
        static void Create()
        {
            var gpx = new GpxFile()
            {
                Metadata = new Metadata()
                {
                    Name        = "meta name",
                    Description = "meta desc",
                    Author      = new Person()
                    {
                        Name  = "person name",
                        Email = new Email("*****@*****.**"),
                        Link  = new Link(new Uri("http://personlink.com"))
                        {
                            Text = "person link text",
                            Type = "person link type"
                        }
                    },
                    Copyright = new Copyright("copyright author")
                    {
                        License = new Uri("http://copyrightlicense.com"),
                        Year    = 2018
                    },
                    Time     = DateTime.Now,
                    Keywords = "meta keywords",
                    Bounds   = new Bounds(1.0, 2.0, 3.0, 4.0)
                }
                .Tap(meta => meta.Add(new Link(new Uri("http://metadatalink1.com"))
                {
                    Text = "meta link text 1",
                    Type = "meta link type 1"
                }))
                .Tap(meta => meta.Add(new Link(new Uri("http://metadatalink2.com"))
                {
                    Text = "meta link text 2",
                    Type = "meta link type 2"
                }))
            };

            var fileName = "test.xml";

            gpx.Save(fileName, true);
            Validate(fileName);
        }