예제 #1
0
        private string GetActivityName(GpxType gpxObj)
        {
            string activityName = "Route";
            try
            {

            
                string temp = gpxObj.trk[0].name;

                // find split in string and separate into name and date of activity
                if (temp == null)
                {
                    PIFitnessLog.Write(TraceEventType.Warning, 0, "Activity name is null");
                    return activityName;
                }
                
                int i;
                for (i = 0; i < temp.Length; i++)
                {
                    if (char.IsDigit(temp[i]))
                    {
                        break;
                    }
                }

                string creator = gpxObj.creator;
                if (creator == null)
                {
                    PIFitnessLog.Write(TraceEventType.Warning, 0, "Gpx creator element is null");
                    return activityName;
                }
                
                if (creator.Contains("RunKeeper"))
                {
                    activityName = temp.Substring(0, --i);
                }
                else if(creator.Contains("Garmin Connect"))
                {
                    activityName = temp;
                }
                
                return activityName;
            }
            catch (Exception ex)
            {
                PIFitnessLog.Write(TraceEventType.Error, 0, ex);
                return "Route";
            }

        }
예제 #2
0
        private List<TrackPoint> GetWayPoints(GpxType gpxObj)
        {
            try
            {
                //pull all geopositional data into the structure
                List<TrackPoint> wayPoints = new List<TrackPoint>();
                foreach (trksegType trackSeg in gpxObj.trk[0].trkseg)
                {
                    foreach (wptType waypoint in trackSeg.trkpt)
                    {
                        wayPoints.Add(new TrackPoint(waypoint.time, (double)waypoint.lon, (double)waypoint.lat, (double)waypoint.ele));
                    }
                }
                return wayPoints;
            }
            catch (Exception ex)
            {
                PIFitnessLog.Write(TraceEventType.Error, 0, ex);
                return null;
            }

        }