コード例 #1
0
ファイル: GpxDocument.cs プロジェクト: hungdluit/OsmSharp
        private void FindVersionFromSource()
        {
            XmlReader reader = this._source.GetReader();

            while (!reader.EOF)
            {
                if (reader.NodeType == XmlNodeType.Element && reader.Name == "gpx")
                {
                    string attribute = reader.GetAttribute("xmlns");
                    if (!(attribute == "http://www.topografix.com/GPX/1/0"))
                    {
                        if (attribute == "http://www.topografix.com/GPX/1/1")
                        {
                            this._version = GpxVersion.Gpxv1_1;
                        }
                    }
                    else
                    {
                        this._version = GpxVersion.Gpxv1_0;
                    }
                }
                else if (reader.NodeType == XmlNodeType.Element)
                {
                    throw new XmlException("First element expected: gpx!");
                }
                if (this._version != GpxVersion.Unknown)
                {
                    break;
                }
                reader.Read();
            }
        }
コード例 #2
0
        /// <summary>
        /// Save the GPX file to a string, using the given version
        /// </summary>
        /// <param name="version"></param>
        /// <returns></returns>
        public string ToXml(GpxVersion version)
        {
            string xmlString = Serializer.Serialize <GPX1_1.gpxType>(this.ToGpx1_1());

            return
                ((version == GpxVersion.GPX_1_0) ?
                 XsltHelper.Transform(xmlString, Resources.gpx11to10) :
                 xmlString);
        }
コード例 #3
0
 private void FindVersionFromObject()
 {
     _version = GpxVersion.Unknown;
     if (_gpx_object is OsmSharp.Xml.Gpx.v1_0.gpx)
     {
         _version = GpxVersion.Gpxv1_0;
     }
     else if (_gpx_object is OsmSharp.Xml.Gpx.v1_1.gpxType)
     {
         _version = GpxVersion.Gpxv1_1;
     }
 }
コード例 #4
0
 /// <summary>
 /// Save the GPX file to a stream in the given version
 /// </summary>
 /// <param name="stream"></param>
 /// <param name="version"></param>
 private void ToStream(Stream stream, GpxVersion version)
 {
     if (version == GpxVersion.GPX_1_1)
     {
         Serializer.Serialize <GPX1_1.gpxType>(stream, this.ToGpx1_1());
     }
     else
     {
         XsltHelper.Transform(
             Serializer.Serialize <GPX1_1.gpxType>(this.ToGpx1_1()),
             Resources.gpx11to10,
             stream);
     }
 }
コード例 #5
0
ファイル: GpxDocument.cs プロジェクト: hungdluit/OsmSharp
 private void FindVersionFromObject()
 {
     this._version = GpxVersion.Unknown;
     if (this._gpx_object is gpx)
     {
         this._version = GpxVersion.Gpxv1_0;
     }
     else
     {
         if (!(this._gpx_object is gpxType))
         {
             return;
         }
         this._version = GpxVersion.Gpxv1_1;
     }
 }
コード例 #6
0
        private void FindVersionFromSource()
        {
            // try to find the xmlns and the correct version to use.
            XmlReader reader = _source.GetReader();

            while (!reader.EOF)
            {
                if (reader.NodeType == XmlNodeType.Element &&
                    reader.Name == "gpx")
                {
                    string ns = reader.GetAttribute("xmlns");
                    switch (ns)
                    {
                    case "http://www.topografix.com/GPX/1/0":
                        _version = GpxVersion.Gpxv1_0;
                        break;

                    case "http://www.topografix.com/GPX/1/1":
                        _version = GpxVersion.Gpxv1_1;
                        break;
                    }
                }
                else if (reader.NodeType == XmlNodeType.Element)
                {
                    throw new XmlException("First element expected: gpx!");
                }

                // check end conditions.
                if (_version != GpxVersion.Unknown)
                {
                    reader.Close();
                    reader = null;
                    break;
                }

                reader.Read();
            }
        }
コード例 #7
0
ファイル: GpxDocument.cs プロジェクト: UnifyKit/OsmSharp
 /// <summary>
 /// Creates a new kml document based on an xml source.
 /// </summary>
 /// <param name="source"></param>
 public GpxDocument(IXmlSource source)
 {
     _source = source;
     _version = GpxVersion.Unknown;
 }
コード例 #8
0
ファイル: GpxDocument.cs プロジェクト: UnifyKit/OsmSharp
        private void FindVersionFromSource()
        {
            // try to find the xmlns and the correct version to use.
            XmlReader reader = _source.GetReader();
            while (!reader.EOF)
            {
                if (reader.NodeType == XmlNodeType.Element
                    && reader.Name == "gpx")
                {
                    string ns = reader.GetAttribute("xmlns");
                    switch (ns)
                    {
                        case "http://www.topografix.com/GPX/1/0":
                            _version = GpxVersion.Gpxv1_0;
                            break;
                        case "http://www.topografix.com/GPX/1/1":
                            _version = GpxVersion.Gpxv1_1;
                            break;
                    }
                }
                else if (reader.NodeType == XmlNodeType.Element)
                {
                    throw new XmlException("First element expected: gpx!");
                }

                // check end conditions.
                if (_version != GpxVersion.Unknown)
                {
                    reader = null;
                    break;
                }

                reader.Read();
            }
        }
コード例 #9
0
ファイル: GpxDocument.cs プロジェクト: UnifyKit/OsmSharp
 private void FindVersionFromObject()
 {
     _version = GpxVersion.Unknown;
     if (_gpx_object is OsmSharp.IO.Xml.Gpx.v1_0.gpx)
     {
         _version = GpxVersion.Gpxv1_0;
     }
     else if (_gpx_object is OsmSharp.IO.Xml.Gpx.v1_1.gpxType)
     {
         _version = GpxVersion.Gpxv1_1;
     }
 }
コード例 #10
0
ファイル: GpxDocument.cs プロジェクト: hungdluit/OsmSharp
 public GpxDocument(IXmlSource source)
 {
     this._source  = source;
     this._version = GpxVersion.Unknown;
 }