Beispiel #1
0
        static public GpxFile Load (Stream stream)
        {
            XmlDocument xmlDoc = new XmlDocument ();
            xmlDoc.Load(stream);

            IGpxDataTranslator gpxDataTranslator = null;
            switch (xmlDoc.DocumentElement.NamespaceURI)
            {
                case "http://www.topografix.com/GPX/1/1":
                    gpxDataTranslator = new Gpx11DataTranslator();
                    break;
                case "http://www.topografix.com/GPX/1/0":
                    gpxDataTranslator = new Gpx10DataTranslator ();
                    break;
                    //throw new NotSupportedException ("GPX version 1.0 is currently not supported. Please use a 3rd party tool (like gpsbabel) to convert it to 1.1 format.");
                default:
                    throw new ArgumentException("This is not a GPX file.");
            }

            // move back to the start of the stream
            stream.Seek(0, SeekOrigin.Begin);
            GpxFile gpxFile = new GpxFile ();
            gpxDataTranslator.ReadGpxData(gpxFile, stream);
            return gpxFile;
        }
Beispiel #2
0
 public void Save (string fileName)
 {
     Gpx11DataTranslator translator = new Gpx11DataTranslator();
     translator.WriteGpxData(this, fileName);
 }