private string BuildGpx(TopoTrailInfo trail) { var writer = new GpxFileWriter(); // write file header writer.SetVersion(GpxSchemaVersion.Version1_1); writer.WriteHeader(trail); // write custom data var data = new GpxExtensionData() { Timezone = trail.Timezone.TZID, Country = (trail.Country?.Name ?? ""), Region = (trail.Region?.RegionName ?? ""), Location = trail.Location }; writer.WriteMetadata(data); // write tracks foreach (var track in trail.TopoTracks) { writer.WriteTrack(track); } return(writer.GetXml()); }
/// <summary> /// Generates a GPX file from the current set of tracks /// </summary> /// <returns></returns> public byte[] GenerateGPX(string name = "") { var writer = new GpxFileWriter(); writer.WriteHeader(name); foreach (var track in ListTracks()) { writer.WriteTrack(track); } return(Encoding.ASCII.GetBytes(writer.GetXml())); }