Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public List<string> LoadGPXTracks(string sFile)
- {
- XDocument gpxDoc = GetGpxDoc(sFile);
- XNamespace gpx = GetGpxNameSpace();
- var tracks = from track in gpxDoc.Descendants(gpx + "trk")
- select new
- {
- Name = track.Element(gpx + "name") != null ?
- track.Element(gpx + "name").Value : null,
- Segs = (
- from trackpoint in track.Descendants(gpx + "trkpt")
- select new
- {
- Latitude = trackpoint.Attribute("lat").Value,
- Longitude = trackpoint.Attribute("lon").Value,
- Elevation = trackpoint.Element(gpx + "ele") != null ?
- trackpoint.Element(gpx + "ele").Value : null,
- Time = trackpoint.Element(gpx + "time") != null ?
- trackpoint.Element(gpx + "time").Value : null
- }
- )
- };
- // StringBuilder sb = new StringBuilder();
- List<string> stringList = new List<string>();
- foreach (var trk in tracks)
- {
- stringList.Add(trk);
- // Populate track data objects.
- foreach (var trkSeg in trk.Segs)
- {
- // Populate detailed track segments
- // in the object model here.
- /*sb.Append(
- string.Format("Track:{0} - Latitude:{1} Longitude:{2} " +
- "Elevation:{3} Date:{4}\n",
- trk.Name, trkSeg.Latitude,
- trkSeg.Longitude, trkSeg.Elevation,
- trkSeg.Time));
- */
- /* stringList.Add(trkSeg.Latitude);
- stringList.Add(trkSeg.Longitude);
- stringList.Add(trkSeg.Elevation);
- */
- }
- }
- return stringList;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement