public void ReadGpxData(GpxFile gpxFile, Stream stream) { XmlSerializer serializer = new XmlSerializer(typeof(gpx)); gpx gpx = (gpx)serializer.Deserialize(stream); if (gpx.trk != null) { foreach (gpxTrk trkType in gpx.trk) { Track track = new Track(); foreach (gpxTrkTrkseg trkseg in trkType.trkseg) { if (trkseg.trkpt.Length > 0) { TrackSegment segment = new TrackSegment(); foreach (gpxTrkTrksegTrkpt trkpt in trkseg.trkpt) { TrackPoint waypoint = ReadTrackPoint(trkpt); segment.AddPoint(waypoint); } track.AddSegment(segment); } } gpxFile.AddTrack(track); } } if (gpx.wpt != null) { foreach (gpxWpt wptType in gpx.wpt) { TrackPoint waypoint = ReadWayoint(wptType); gpxFile.AddWaypoint(waypoint); } } if (gpx.rte != null) { foreach (gpxRte rteType in gpx.rte) { Track route = new Track(); if (rteType.rtept != null) { TrackSegment segment = new TrackSegment(); foreach (gpxRteRtept wptType in rteType.rtept) { TrackPoint waypoint = ReadRoutePoint(wptType); segment.AddPoint(waypoint); } } gpxFile.AddRoute(route); } } }
public void ReadGpxData(GpxFile gpxFile, Stream stream) { XmlSerializer serializer = new XmlSerializer(typeof(gpxType)); gpxType gpx = (gpxType)serializer.Deserialize(stream); if (gpx.trk != null) { foreach (trkType trkType in gpx.trk) { Track track = new Track(); if (trkType.trkseg != null) { foreach (trksegType trksegType in trkType.trkseg) { if (trksegType.trkpt != null) { TrackSegment segment = new TrackSegment(); foreach (wptType wptType in trksegType.trkpt) { TrackPoint waypoint = ReadTrackPoint(wptType); segment.AddPoint(waypoint); } track.AddSegment(segment); } } } gpxFile.AddTrack(track); } } if (gpx.wpt != null) { foreach (wptType wptType in gpx.wpt) { TrackPoint waypoint = ReadTrackPoint(wptType); gpxFile.AddWaypoint(waypoint); } } if (gpx.rte != null) { foreach (rteType rteType in gpx.rte) { Track route = new Track(); if (rteType.rtept != null) { TrackSegment segment = new TrackSegment(); foreach (wptType wptType in rteType.rtept) { TrackPoint waypoint = ReadTrackPoint(wptType); segment.AddPoint(waypoint); } route.AddSegment(segment); } gpxFile.AddRoute(route); } } }
public void AddSegment(TrackSegment segment) { segments.Add(segment); }