Exemple #1
0
        private GpxRoutePoint ReadGpxRoutePoint()
        {
            string elementName    = Reader_.Name;
            bool   isEmptyElement = Reader_.IsEmptyElement;

            GpxRoutePoint routePoint = new GpxRoutePoint();

            GetPointLocation(routePoint);
            if (isEmptyElement)
            {
                return(routePoint);
            }

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

                    switch (Reader_.Name)
                    {
                    case "extensions":
                        ReadRoutePointExtensions(routePoint);
                        break;

                    default:
                        if (!ProcessPointField(routePoint))
                        {
                            SkipElement();
                        }
                        break;
                    }

                    break;

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

            throw new FormatException(elementName);
        }
Exemple #2
0
        private void ReadRoutePointExtensions(GpxRoutePoint routePoint)
        {
            if (Reader_.IsEmptyElement)
            {
                return;
            }

            string elementName = Reader_.Name;

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

                    if (Reader_.NamespaceURI == GpxNamespaces.GARMIN_EXTENSIONS_NAMESPACE)
                    {
                        switch (Reader_.LocalName)
                        {
                        case "RoutePointExtension":
                            ReadGarminRoutePointExtensions(routePoint);
                            break;

                        default:
                            SkipElement();
                            break;
                        }

                        break;
                    }

                    SkipElement();
                    break;

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

            throw new FormatException(elementName);
        }
Exemple #3
0
        private void WriteRoutePoint(string elementName, GpxRoutePoint routePoint)
        {
            Writer_.WriteStartElement(elementName);
            WritePoint(routePoint);

            if (routePoint.HasExtensions)
            {
                Writer_.WriteStartElement("extensions");
                Writer_.WriteStartElement("RoutePointExtension", GpxNamespaces.GARMIN_EXTENSIONS_NAMESPACE);

                foreach (GpxPoint point in routePoint.RoutePoints)
                {
                    WriteSubPoint(point);
                }

                Writer_.WriteEndElement();
                Writer_.WriteEndElement();
            }

            Writer_.WriteEndElement();
        }
Exemple #4
0
        private void ReadGarminRoutePointExtensions(GpxRoutePoint routePoint)
        {
            if (Reader_.IsEmptyElement)
            {
                return;
            }

            string elementName = Reader_.Name;

            while (Reader_.Read())
            {
                switch (Reader_.NodeType)
                {
                case XmlNodeType.Element:
                    switch (Reader_.LocalName)
                    {
                    case "rpt":
                        routePoint.RoutePoints.Add(ReadGarminAutoRoutePoint());
                        break;

                    default:
                        SkipElement();
                        break;
                    }

                    break;

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

            throw new FormatException(elementName);
        }