Exemple #1
0
        private GpxTrackSegment ReadGpxTrackSegment(XmlReader reader)
        {
            GpxTrackSegment segment = new GpxTrackSegment();

            if (reader.IsEmptyElement)
            {
                return(segment);
            }

            string elementName = reader.Name;

            while (reader.Read())
            {
                switch (reader.NodeType)
                {
                case XmlNodeType.Element:

                    switch (reader.Name)
                    {
                    case "trkpt":
                        segment.TrackPoints.Add(ReadGpxTrackPoint(reader));
                        break;

                    case "extensions":
                        ReadTrackSegmentExtensions(reader);
                        break;

                    default:
                        throw new FormatException(reader.Name);
                    }

                    break;

                case XmlNodeType.EndElement:
                    if (reader.Name != elementName)
                    {
                        throw new FormatException(reader.Name);
                    }
                    return(segment);
                }
            }

            throw new FormatException(elementName);
        }