/// <summary>
        /// Convert this GPX Type to the common GeoFile format
        /// </summary>
        /// <returns>The GPX converted to GeoFile format</returns>
        public GeoFile ToGeoFile()
        {
            // Create a blank new file with the basic information
            GeoFile result = new GeoFile()
            {
                Name   = this.MetaData.Name,
                Author = this.Creator,
                Routes = new List <GeoFileRoute>()
            };

            // Loop the routes and add them to the GeoFile version
            result.Routes = this.Routes.Select(route =>
                                               new GeoFileRoute()
            {
                Name   = route.Name,
                Points = route.ToCoords()
            }).ToList();

            // Loop the tracks and add them to the GeoFile version
            result.Routes.AddRange(this.Tracks.Select(track =>
                                                      new GeoFileRoute()
            {
                Name   = track.Name,
                Points = track.ToCoords()
            }).ToList());

            return(result);
        }
        public GeoFile ToGeoFile()
        {
            GeoFile result = new GeoFile();

            // Transform the activity to the route information
            result.Routes = this.Activities.Activity.Select(activity => new GeoFileRoute()
            {
                Name = activity.Id, Points = activity.ToCoords()
            }).ToList();

            return(result);
        }
        /// <summary>
        /// Convert a GeoFile to the native format
        /// </summary>
        /// <param name="file">The GeoFile format to convert from</param>
        /// <returns>Success Or Failure flag</returns>
        public Boolean FromGeoFile(GeoFile file)
        {
            this.Routes = file.Routes
                          .Select(rt =>
                                  new GPXRoute()
            {
                RoutePoints = rt.Points
                              .Where(pt => !pt.BadCoordinate && !pt.IsUnknown)
                              .Select(pt =>
                                      GPXWaypoint.FromCoord(pt)
                                      ).ToList()
            })
                          .ToList();

            return(true);
        }
        /// <summary>
        /// Convert a GeoFile to the native format
        /// </summary>
        /// <param name="file">The GeoFile format to convert from</param>
        /// <returns>Success Or Failure flag</returns>
        public Boolean FromGeoFile(GeoFile file)
        {
            this.Activities =
                new TCXActivities()
            {
                Activity = file.Routes.Select(rt =>
                                              new TCXActivity()
                {
                    Creator = new TCXAbstractSource()
                    {
                    },
                    Laps = new List <TCXActivityLap>()
                    {
                        new TCXActivityLap()
                        {
                            AverageHeartRateBpm = new TCXHeartRateInBeatsPerMinute()
                            {
                                Value = 0
                            },
                            Cadence        = 0,
                            Calories       = 0,
                            DistanceMeters = rt.Points.CalculateTotalDistance(),
                            Extensions     = new TCXExtensions()
                            {
                            },
                            Intensity           = String.Empty,
                            MaximumHeartRateBpm = new TCXHeartRateInBeatsPerMinute()
                            {
                                Value = 0
                            },
                            MaximumSpeed     = 0,
                            Notes            = String.Empty,
                            StartTime        = String.Empty,
                            TotalTimeSeconds = 0,
                            TriggerMethod    = String.Empty,
                            Track            = new TCXTrack()
                            {
                                TrackPoints = rt.Points.Select(pt =>
                                                               new TCXTrackPoint()
                                {
                                    AltitudeMeters  = pt.Altitude,
                                    Cadence         = 0, // SPM for running, revolutions for cycling (apparantly)
                                    CreatedDateTime = pt.Time,
                                    DistanceMeters  = 0,
                                    Extensions      = new TCXExtensions()
                                    {
                                    },
                                    HeartRateBpm = new TCXHeartRateInBeatsPerMinute()
                                    {
                                    },
                                    Position = new TCXPosition()
                                    {
                                        LatitudeDegrees  = pt.Latitude,
                                        LongitudeDegrees = pt.Longitude
                                    },
                                    SensorState = String.Empty,
                                    Time        = ((pt.Time == null) ? DateTime.MinValue : pt.Time).ToString(TCXFile.DateTimeFormat)
                                }
                                                               ).ToList()
                            }
                        }
                    }
                }).ToList()
            };

            /*
             * file.Routes
             * .Select(rt =>
             *  new TCXActivities()
             *  {
             *
             *      RoutePoints = rt.Points
             *          .Where(pt => !pt.BadCoordinate && !pt.IsUnknown)
             *          .Select(pt =>
             *              GPXWaypoint.FromCoord(pt)
             *          ).ToList()
             *  })
             * .ToList();
             */
            return(true);
        }