Exemple #1
0
 public void Write()
 {
     using (var folder = new FolderWriter(_streamWriter, $"Legend: Speed ({_options.GPSSpeedLabel})", true, true))
     {
         folder.Open();
         foreach (var legend in _speedData.SpeedLegend)
         {
             _streamWriter.WriteLine($"<Placemark>");
             _streamWriter.WriteLine($"<name><![CDATA[<span style=\"color:{legend.FromColor.WebColor};\"><b>{legend.FromSpeed:0.00}</b></span> - <span style=\"color:{legend.ToColor.WebColor};\"><b>{legend.ToSpeed:0.00}</b></span>]]></name>");
             _streamWriter.WriteLine($"<visibility>1</visibility><styleUrl>#speed_legend</styleUrl></Placemark>");
         }
     }
 }
 public void Write()
 {
     using (var folder = new FolderWriter(_streamWriter, "Flight", false))
     {
         _streamWriter.WriteLine($"<Placemark><name>{_options.Name}</name><styleUrl>#multiTrack</styleUrl><gx:Track><altitudeMode>{_options.AltitudeMode}</altitudeMode>");
         foreach (var data in _logData)
         {
             _streamWriter.WriteLine($"<when>{data.TimeStamp:yyyy-MM-ddTHH:mm:ss.FFFZ}</when>");
             _streamWriter.WriteLine($"<gx:coord>{data.Longitude:0.00000000},{data.Latitude:0.00000000},{data.Alt:0.00}</gx:coord>");
         }
         _streamWriter.WriteLine(@"</gx:Track></Placemark>");
     }
 }
        public void Convert()
        {
            // Invariant culture for parsing / converting operations
            var currentCulture = CultureInfo.CurrentCulture;

            CultureInfo.CurrentCulture = CultureInfo.InvariantCulture;

            string snippet = @"<![CDATA[Created using <a href=""https://github.com/naice/OpenTXLog2GoogleEarth"">OpenTXLog2GoogleEarth</a>]]>";

            using (StreamWriter sw = new StreamWriter(_options.OutputStream))
            {
                sw.WriteLine(Constants.KML_HEADER);

                using (DocumentWriter dw = new DocumentWriter(sw, _options.FullName, snippet))
                {
                    dw.Open();
                    bool open = true, visible = true;
                    int  flightCount = 1;

                    foreach (var logData in ParseMultiFlightLog(_logData.Value))
                    {
                        var speedData = ParseSpeedData(logData);
                        using (var folder = new FolderWriter(sw, $"Flight {flightCount}", visible, open))
                        {
                            folder.Open();
                            ColorTrackStyleWriter colorTrackStyleWriter = new ColorTrackStyleWriter(sw, _options, speedData);
                            colorTrackStyleWriter.Write();

                            // Write legend
                            ColorTrackLegendWriter colorTrackLegendWriter = new ColorTrackLegendWriter(sw, _options, speedData);
                            colorTrackLegendWriter.Write();

                            // write speedlayer
                            ColorTrackWriter colorTrackWriter = new ColorTrackWriter(sw, _options, speedData.SpeedColors, logData);
                            colorTrackWriter.Write();

                            // write playback track (google earth extension)
                            FlightWriter flightWriter = new FlightWriter(sw, _options, logData);
                            flightWriter.Write();
                        }

                        flightCount++;
                    }
                }
                // write footer
                sw.WriteLine(Constants.KML_FOOTER);
            }

            CultureInfo.CurrentCulture = currentCulture;
        }