コード例 #1
0
        private SpeedData ParseSpeedData(IEnumerable <LogData> logData)
        {
            SpeedData speedData    = new SpeedData();
            var       makeSpeedHue = new Func <double, double, double>((spd, maxSpd) => {
                double speedPercent = 0.34d;
                if (spd > 0)
                {
                    speedPercent = ((spd / maxSpd) * -0.34d) + 0.34d;
                }
                return(speedPercent);
            });
            var speeds         = logData.Select(d => d.Speed);
            var currentCulture = CultureInfo.CurrentCulture;

            CultureInfo.CurrentCulture = CultureInfo.InvariantCulture;
            CultureInfo.CurrentCulture = currentCulture;
            var minSpeed        = speeds.Min();
            var maxSpeed        = speedData.MaxSpeed = speeds.Max();
            var rangeSpeed      = maxSpeed - minSpeed;
            var legendStepCount = 5;
            var legendSteps     = rangeSpeed / legendStepCount;

            for (int i = 0; i < legendStepCount; i++)
            {
                var fromSpeed = i * legendSteps;
                var toSpeed   = (i + 1) * legendSteps;

                speedData.SpeedLegend.Add(new LegendData()
                {
                    FromSpeed = fromSpeed,
                    ToSpeed   = toSpeed,
                    FromColor = new ColorHLS(180, makeSpeedHue(fromSpeed, maxSpeed), 0.5, 1).HlsToRgb(),
                    ToColor   = new ColorHLS(180, makeSpeedHue(toSpeed, maxSpeed), 0.5, 1).HlsToRgb(),
                });
            }

            foreach (var speed in speeds)
            {
                var    abs          = (int)Math.Abs(speed);
                double speedPercent = 0.34d;
                if (speed > 0)
                {
                    speedPercent = ((speed / maxSpeed) * -0.34d) + 0.34d;
                }
                speedData.SpeedColors[abs] = new ColorHLS(180, makeSpeedHue(speed, maxSpeed), 0.5, 1).HlsToRgb();
            }

            return(speedData);
        }
コード例 #2
0
 public ColorTrackLegendWriter(StreamWriter streamWriter, ConverterOptions options, SpeedData speedData)
 {
     _streamWriter = streamWriter;
     _options      = options;
     _speedData    = speedData;
 }
コード例 #3
0
 public ColorTrackStyleWriter(StreamWriter streamWriter, ConverterOptions options, SpeedData speedData)
 {
     _streamWriter = streamWriter;
     _speedData    = speedData;
 }