/// <summary>Returns the current instance converted to the specified unit type.</summary> public Speed ToUnitType(SpeedUnit value) { switch (value) { case SpeedUnit.FeetPerSecond: return(ToFeetPerSecond()); case SpeedUnit.KilometersPerHour: return(ToKilometersPerHour()); case SpeedUnit.KilometersPerSecond: return(ToKilometersPerSecond()); case SpeedUnit.Knots: return(ToKnots()); case SpeedUnit.MetersPerSecond: return(ToMetersPerSecond()); case SpeedUnit.StatuteMilesPerHour: return(ToStatuteMilesPerHour()); default: return(Speed.Empty); } }
/// <summary> /// Produces list of speed limits to offer user in the palette /// </summary> /// <param name="unit">What kind of speed limit list is required</param> /// <returns>List from smallest to largest speed with the given unit. Zero (no limit) is not added to the list. /// The values are in-game speeds as float.</returns> public static List <SpeedValue> EnumerateSpeedLimits(SpeedUnit unit) { var result = new List <SpeedValue>(); switch (unit) { case SpeedUnit.Kmph: for (var km = LOWER_KMPH; km <= UPPER_KMPH; km += KMPH_STEP) { result.Add(SpeedValue.FromKmph(km)); } break; case SpeedUnit.Mph: for (var mi = LOWER_MPH; mi <= UPPER_MPH; mi += MPH_STEP) { result.Add(SpeedValue.FromMph(mi)); } break; case SpeedUnit.CurrentlyConfigured: // Automatically choose from the config return(GlobalConfig.Instance.Main.DisplaySpeedLimitsMph ? EnumerateSpeedLimits(SpeedUnit.Mph) : EnumerateSpeedLimits(SpeedUnit.Kmph)); } return(result); }
/// <summary> /// Takes a velocity in length unit per second and returns it in speed unit. /// </summary> public static float ConvertVelocity(float v, LengthUnit lengthUnit, SpeedUnit unit) { float result = 0; float perSecond = ConvertLengthForSpeedUnit(v, lengthUnit, unit); switch (unit) { case SpeedUnit.FeetPerSecond: case SpeedUnit.MetersPerSecond: result = perSecond; break; case SpeedUnit.KilometersPerHour: case SpeedUnit.MilesPerHour: case SpeedUnit.Knots: result = perSecond * 3600; break; default: result = 0; break; } return(result); }
/// <summary> /// Convert to the unit representation <paramref name="unit" />. /// </summary> /// <returns>Value in new unit if successful, exception otherwise.</returns> /// <exception cref="NotImplementedException">If conversion was not successful.</exception> public double As(SpeedUnit unit) { switch (unit) { case SpeedUnit.FootPerSecond: return(FeetPerSecond); case SpeedUnit.KilometerPerHour: return(KilometersPerHour); case SpeedUnit.Knot: return(Knots); case SpeedUnit.MeterPerSecond: return(MetersPerSecond); case SpeedUnit.MilePerHour: return(MilesPerHour); case SpeedUnit.MillimeterPerSecond: return(MillimetersPerSecond); default: throw new NotImplementedException("unit: " + unit); } }
/// <summary> /// Dynamically convert from value and unit enum <see cref="SpeedUnit" /> to <see cref="Speed" />. /// </summary> /// <param name="value">Value to convert from.</param> /// <param name="fromUnit">Unit to convert from.</param> /// <returns>Speed unit value.</returns> public static Speed From(double value, SpeedUnit fromUnit) { switch (fromUnit) { case SpeedUnit.FootPerSecond: return(FromFeetPerSecond(value)); case SpeedUnit.KilometerPerHour: return(FromKilometersPerHour(value)); case SpeedUnit.Knot: return(FromKnots(value)); case SpeedUnit.MeterPerSecond: return(FromMetersPerSecond(value)); case SpeedUnit.MilePerHour: return(FromMilesPerHour(value)); case SpeedUnit.MillimeterPerSecond: return(FromMillimetersPerSecond(value)); default: throw new NotImplementedException("fromUnit: " + fromUnit); } }
private static float GetMeters(float speed, SpeedUnit unit) { double meters = 0; switch (unit) { case SpeedUnit.MetersPerSecond: meters = speed; break; case SpeedUnit.KilometersPerHour: meters = speed * kilometerToMeters; break; case SpeedUnit.FeetPerSecond: meters = speed * footToMeters; break; case SpeedUnit.MilesPerHour: meters = speed * mileToMeters; break; case SpeedUnit.Knots: meters = speed * nauticalMileToMeters; break; case SpeedUnit.PixelsPerSecond: meters = speed; break; } return((float)meters); }
public static SpeedUnit GetSpeedUnit(string raw) { SpeedUnit result = 0; switch (raw) { case "KT": result = SpeedUnit.Kt; break; case "MPH": result = SpeedUnit.Mph; break; case "KPH": result = SpeedUnit.Kmh; break; case "KMH": result = SpeedUnit.Kmh; break; case "MPS": result = SpeedUnit.Mps; break; default: result = SpeedUnit.Unspecified; break; } return(result); }
public void DeserializeCustomUnitAsPredefined_ShouldReturnValidResult() { // arrange var someUnit = new SpeedUnit( name: "some unit", abbreviation: "su", valueInMetresPerSecond: (number)123.456m); string json = @"{ 'unit': 'su' }"; var converter = new SpeedUnitJsonConverter( serializationFormat: LinearUnitJsonSerializationFormat.PredefinedAsString, tryReadCustomPredefinedUnit: (string value, out SpeedUnit predefinedUnit) => { if (value == someUnit.Abbreviation) { predefinedUnit = someUnit; return(true); } predefinedUnit = default(SpeedUnit); return(false); }); // act var result = JsonConvert.DeserializeObject <SomeUnitOwner <SpeedUnit> >(json, converter); // assert result.Unit.Should().Be(someUnit); }
public static double ConvertBack(string str) { //double tmp = double.TryParse(str); double.TryParse(str, out double tmp); SpeedUnit speedUnit = SpeedUnit.FromMillimeterPerSecond(tmp); var unitType = UnitObserverFacade.Instance.SpeedUnitObserver.UnitType; switch (unitType) { case UnitSpeedTypes.Millimeter_Second: speedUnit = SpeedUnit.FromMillimeterPerSecond(tmp); break; case UnitSpeedTypes.Meter_Second: speedUnit = SpeedUnit.FromMeterPerSecond(tmp); break; case UnitSpeedTypes.Meter_Minute: speedUnit = SpeedUnit.FromMeterPerMinute(tmp); break; case UnitSpeedTypes.Millimeter_Minute: speedUnit = SpeedUnit.FromMillimeterPerMinute(tmp); break; } return(speedUnit.AsMillimeterPerSecond); }
public override int GetHashCode() { int hash = 1; if (Latitude != 0D) { hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(Latitude); } if (Longitude != 0D) { hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(Longitude); } if (Speed != 0D) { hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(Speed); } if (SpeedUnit.Length != 0) { hash ^= SpeedUnit.GetHashCode(); } if (Temperature != 0D) { hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(Temperature); } if (TemperatureUnit.Length != 0) { hash ^= TemperatureUnit.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public static string SpeedAbbreviation(SpeedUnit unit) { string abbreviation = ""; switch (unit) { case SpeedUnit.FeetPerSecond: abbreviation = "ft/s"; break; case SpeedUnit.MetersPerSecond: abbreviation = "m/s"; break; case SpeedUnit.KilometersPerHour: abbreviation = "km/h"; break; case SpeedUnit.MilesPerHour: abbreviation = "mph"; break; case SpeedUnit.Knots: abbreviation = "kn"; break; case SpeedUnit.PixelsPerSecond: default: abbreviation = "px/s"; break; } return(abbreviation); }
public void doMoveToPositionWithUpdate(SpeedUnit in_speedUnit, Vector3 n_point) { Debug.Log("(" + gameObject.name + ") MoveTo " + n_point + " With update"); if (in_speedUnit != null) { // moveUpdatePos = n_point; myMove = in_speedUnit; myMove.getTimeScaleBySpeed(); Hashtable moveUpdateHash = iTween.Hash("x", n_point.x, "z", n_point.z, "easeType", "easeInCubic", "loopType", "none", "speed", gameObject.GetComponent <UnitProperty>().getMaxMoveSpeed()); moveUpdateHash.Add("onstarttarget", gameObject); moveUpdateHash.Add("onstart", "moveStart"); moveUpdateHash.Add("oncompletetarget", gameObject); moveUpdateHash.Add("oncomplete", "moveEnd"); moveUpdateHash.Add("onupdatetarget", gameObject); moveUpdateHash.Add("onupdate", "onMoveUpdate"); iTween.MoveTo(gameObject, moveUpdateHash); //use moveUpdate ....... // myMoveUpdate = new MoveUpdateHelper(); } else { Debug.Log(" SpeedUnit is required ! "); } }
public static string Convert(double speed) { var speedUnit = SpeedUnit.FromMillimeterPerSecond(speed); var speedUnitObserver = UnitObserverFacade.Instance.SpeedUnitObserver; switch (speedUnitObserver.UnitType) { case UnitSpeedTypes.Millimeter_Second: speed = speedUnit.AsMillimeterPerSecond; break; case UnitSpeedTypes.Meter_Second: speed = speedUnit.AsMeterPerSecond; break; case UnitSpeedTypes.Meter_Minute: speed = speedUnit.AsMeterPerMinute; break; case UnitSpeedTypes.Millimeter_Minute: speed = speedUnit.AsMillimeterPerMinute; break; } return(speed.ToString("0.###")); }
public string ToString(SpeedUnit unit, [CanBeNull] string cultureName, int significantDigitsAfterRadix) { double value = As(unit); string format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); return(ToString(unit, cultureName, format)); }
public UserMeasurementUnitMetric(float rawValue, SpeedUnit rawSpeedUnit, SpeedUnit userSelectedSpeedUnit) : this(rawValue) { _rawSpeedUnit = rawSpeedUnit; _userSelectedSpeedUnit = userSelectedSpeedUnit; CalculateFormattedValue(); }
/// <summary> /// Converts the <see cref="Speed"/> to the specified <paramref name="targetUnit"/>. /// </summary> /// <param name="targetUnit">Target units.</param> /// <returns><see cref="Speed"/> converted to <paramref name="targetUnit"/>.</returns> public double ConvertTo(SpeedUnit targetUnit) { switch (targetUnit) { case SpeedUnit.MetersPerSecond: return(m_value); case SpeedUnit.MilesPerHour: return(ToMilesPerHour()); case SpeedUnit.KilometersPerHour: return(ToKilometersPerHour()); case SpeedUnit.FeetPerMinute: return(ToFeetPerMinute()); case SpeedUnit.InchesPerSecond: return(ToInchesPerSecond()); case SpeedUnit.Knots: return(ToKnots()); case SpeedUnit.Mach: return(ToMach()); default: throw new ArgumentOutOfRangeException(nameof(targetUnit), targetUnit, null); } }
public static string GetAbbreviation(SpeedUnit unit, [CanBeNull] string cultureName) { // Windows Runtime Component does not support CultureInfo and IFormatProvider types, so we use culture name for public methods: https://msdn.microsoft.com/en-us/library/br230301.aspx IFormatProvider provider = cultureName == null ? UnitSystem.DefaultCulture : new CultureInfo(cultureName); return(UnitSystem.GetCached(provider).GetDefaultAbbreviation(unit)); }
/// <summary>Produces list of speed limits to offer user in the palette.</summary> /// <param name="unit">What kind of speed limit list is required.</param> /// <returns> /// List from smallest to largest speed with the given unit. Zero (no limit) is /// not added to the list. The values are in-game speeds as float. /// </returns> public static List <SetSpeedLimitAction> AllSpeedLimits(SpeedUnit unit) { var result = new List <SetSpeedLimitAction>(); // SpeedLimitTextures textures = TMPELifecycle.Instance.Textures.SpeedLimits; switch (unit) { case SpeedUnit.Kmph: for (var km = RoadSignThemes.KMPH_STEP; km <= RoadSignThemes.UPPER_KMPH; km += RoadSignThemes.KMPH_STEP) { result.Add(SetSpeedLimitAction.SetOverride(SpeedValue.FromKmph(km))); } break; case SpeedUnit.Mph: for (var mi = RoadSignThemes.MPH_STEP; mi <= RoadSignThemes.UPPER_MPH; mi += RoadSignThemes.MPH_STEP) { result.Add(SetSpeedLimitAction.SetOverride(SpeedValue.FromMph(mi))); } break; case SpeedUnit.CurrentlyConfigured: // Automatically choose from the config return(AllSpeedLimits(GlobalConfig.Instance.Main.GetDisplaySpeedUnit())); } return(result); }
/// <summary> /// Converts the <paramref name="value"/> in the specified <paramref name="sourceUnit"/> to a new <see cref="Speed"/> in meters per second. /// </summary> /// <param name="value">Source value.</param> /// <param name="sourceUnit">Source value units.</param> /// <returns>New <see cref="Speed"/> from the specified <paramref name="value"/> in <paramref name="sourceUnit"/>.</returns> public static Speed ConvertFrom(double value, SpeedUnit sourceUnit) { switch (sourceUnit) { case SpeedUnit.MetersPerSecond: return(value); case SpeedUnit.MilesPerHour: return(FromMilesPerHour(value)); case SpeedUnit.KilometersPerHour: return(FromKilometersPerHour(value)); case SpeedUnit.FeetPerMinute: return(FromFeetPerMinute(value)); case SpeedUnit.InchesPerSecond: return(FromInchesPerSecond(value)); case SpeedUnit.Knots: return(FromKnots(value)); case SpeedUnit.Mach: return(FromMach(value)); default: throw new ArgumentOutOfRangeException(nameof(sourceUnit), sourceUnit, null); } }
public static int ConvertSpeedLimit(SpeedUnit oldUnit, SpeedUnit newUnit, int limit) { double factor = GetFactor(newUnit) / GetFactor(oldUnit); int newLimit = (int)Math.Round(limit * factor); return(newLimit - (newLimit % 5)); }
public string ToString(SpeedUnit unit, [CanBeNull] IFormatProvider provider, int significantDigitsAfterRadix) { double value = As(unit); string format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); return(ToString(unit, provider, format)); }
/// <summary> /// Constructor /// </summary> /// <param name="tempUnit">Unit for temperature, default = celcius</param> /// <param name="pUnit">Unit for pressure, default = torr</param> /// <param name="speedUnit">Unit for speed (wind), default = knots</param> /// <param name="distanceUnit">Unit for distance (visibility), default = kilometer</param> public Units(TemperatureUnit tempUnit, PressureUnit pUnit, SpeedUnit speedUnit, LengthUnit distanceUnit) { PressureUnit = pUnit; TemperatureUnit = tempUnit; WindSpeedUnit = speedUnit; VisibilityUnit = distanceUnit; }
public void ConvertWindSpeed(SpeedUnit unitOfMeasurement) { if (WindSpeedUnit == unitOfMeasurement) return; WindSpeed = Speed.From(WindSpeed, WindSpeedUnit).As(unitOfMeasurement).Round(); WindSpeedUnit = unitOfMeasurement; }
public void RefreshUnits() { speedUnit = PreferencesManager.PlayerPreferences.SpeedUnit; accelerationUnit = PreferencesManager.PlayerPreferences.AccelerationUnit; angleUnit = PreferencesManager.PlayerPreferences.AngleUnit; angularVelocityUnit = PreferencesManager.PlayerPreferences.AngularVelocityUnit; angularAccelerationUnit = PreferencesManager.PlayerPreferences.AngularAccelerationUnit; }
public SpeedLevel(SpeedUnit speedunit, string speed, LevelUnit levelunit, string level) : base(speedunit + speed + levelunit + level) { this._speedunit = speedunit; this._speed = speed; this._levelunit = levelunit; this._level = level; }
public static string RainDspString(double Value, SpeedUnit Unit) { if (double.IsNaN(Value)) { return(""); } return(Value.ToString(mRainDspFmt[(int)Unit], CultureInfo.CurrentCulture)); }
public static string RainLogString(double Value, SpeedUnit Unit, CultureInfo Culture) { if (double.IsNaN(Value)) { return(""); } return(Value.ToString(mRainLogFmt[(int)Unit], Culture)); }
public SensorStorage(string name, SpeedUnit speedUnit, TemperatureUnit tempUnit, PressureUnit presUnit, IEnumerable <Reading> readings) : base(readings ?? new Reading[0]) { _name = name; _speedUnit = speedUnit; _tempUnit = tempUnit; _presUnit = presUnit; }
/// <summary> /// Parses the word at the given position to Speed based on the given unit. /// </summary> /// <param name="position">Position of the Words array that gets parsed to speed.</param> /// <param name="unit">SpeedUnit that is used for parsing.</param> /// <returns>Invalid if position is outside of Words array or word at the position is empty.</returns> protected Speed ParseSpeed(int position, SpeedUnit unit) { if (Words.Length <= position || Words[position].Length == 0) { return(Speed.Invalid); } return(new Speed(double.Parse(Words[position], NmeaCultureInfo), unit)); }
public Speed(double metres, TimeSpan timeSpan) { _unit = SpeedUnit.Ms; if (Math.Abs(metres - 0d) < double.Epsilon || timeSpan == default(TimeSpan) || Math.Abs(timeSpan.TotalSeconds - 0) < double.Epsilon) _siValue = 0d; else _siValue = metres / timeSpan.TotalSeconds; }
/// <summary> /// Convert the given Metar.Wind to the desired unit. /// </summary> /// <param name="wind">Wind.</param> /// <param name="toUnit">Unit to convert the value to.</param> public static Wind Speed(Wind wind, SpeedUnit toUnit) { wind.Speed = Speed(wind.Speed, toUnit); if (wind.Gust != null) { wind.Gust = Speed(wind.Gust, toUnit); } return(wind); }
public Speed(XmlReader reader) { // Initialize all fields _Value = Double.NaN; _Units = 0; // Deserialize the object from XML ReadXml(reader); }
public void SpeedConversions(double value1, SpeedUnit units1, double value2, SpeedUnit units2) { new Speed(value1, units1) { Units = units2 }.Value.ShouldBeWithinEpsilonOf(value2); new Speed(value2, units2) { Units = units1 }.Value.ShouldBeWithinEpsilonOf(value1); }
public void ConvertsUnitsOfMeasurement(TemperatureUnit tempBefore, TemperatureUnit tempAfter, SpeedUnit windBefore, SpeedUnit windAfter) { var weatherResult = TestData.GetTestWeatherResult(tempBefore, windBefore); weatherResult.ConvertTemperature(tempAfter); weatherResult.ConvertWindSpeed(windAfter); weatherResult.TemperatureUnit.Should().Be(tempAfter); weatherResult.WindSpeedUnit.Should().Be(windAfter); }
public SensorInfo( string name, SpeedUnit speedUnit, TemperatureUnit tempUnit, PressureUnit pressureUnit ) { Name = name; SpeedUnit = speedUnit; TemperatureUnit = tempUnit; PressureUnit = pressureUnit; }
public static WeatherApiResult GetTestWeatherResult(TemperatureUnit tempUnit, SpeedUnit speedUnit) { var random = new Random(); return new WeatherApiResult { Location = "Liverpool", Temperature = random.Next(0, 40), WindSpeed = random.Next(0, 40), TemperatureUnit = tempUnit, WindSpeedUnit = speedUnit }; }
/// <summary> /// Converts the specified from unit to the specified unit. /// </summary> /// <param name="fromUnit">Covert from unit.</param> /// <param name="toUnit">Covert to unit.</param> /// <param name="fromValue">Covert from value.</param> /// <returns>The converted value.</returns> public static double Convert( SpeedUnit fromUnit, SpeedUnit toUnit, double fromValue) { if (fromUnit == toUnit) return fromValue; double fromFactor = factors[(int)fromUnit]; double toFactor = factors[(int)toUnit]; double result = fromFactor * fromValue / toFactor; return result; }
public static float ConvertSpeed(float value, SpeedUnit fromUnit, SpeedUnit toUnit) { float workingValue; if (fromUnit == SpeedUnit.MetresPerSecond) workingValue = value; else workingValue = value / SpeedConversions[(int)fromUnit]; if (toUnit != SpeedUnit.MetresPerSecond) workingValue = workingValue * SpeedConversions[(int)toUnit]; return workingValue; }
protected SensorInfo AddSensor( Data.DbDataStore store = null, string name = "Sensor", SpeedUnit speedUnit = SpeedUnit.MetersPerSec, TemperatureUnit tempUnit = TemperatureUnit.Celsius, PressureUnit pressUnit = PressureUnit.KiloPascals ) { if (null == store) store = Store; Assert.IsNotNull(store, "no store"); var sensor = new SensorInfo(name, speedUnit, tempUnit, pressUnit); var sensorAdded = store.AddSensor(sensor); Assert.IsTrue(sensorAdded, "sensor add failed"); return sensor; }
public int Convert(int value, SpeedUnit sourceUnit, SpeedUnit targetUnit) { if (sourceUnit == targetUnit) return value; double sourceValue = value; double pivotValue; double targetValue; //Pivot : SI switch (sourceUnit) { case SpeedUnit.Imperial: pivotValue = sourceValue / 2.23693629205; break; case SpeedUnit.Metric: pivotValue = sourceValue / 3.6; break; case SpeedUnit.SI: pivotValue = sourceValue; break; default: throw new ArgumentOutOfRangeException(); } switch (targetUnit) { case SpeedUnit.Imperial: targetValue = pivotValue * 2.23693629205; break; case SpeedUnit.Metric: targetValue = pivotValue * 3.6; break; case SpeedUnit.SI: targetValue = pivotValue; break; default: throw new ArgumentOutOfRangeException(); } return System.Convert.ToInt32(targetValue); }
public static WeatherApiResult AverageWeatherResults(this IEnumerable<WeatherApiResult> weatherResults, TemperatureUnit temperatureMeasurement, SpeedUnit windSpeedMeasurement) { if (weatherResults == null) throw new ArgumentNullException("weatherResults"); var weatherApiResults = weatherResults.ToList(); if (weatherApiResults.Count == 0) return null; foreach (var weatherApiResult in weatherApiResults) { weatherApiResult.ConvertTemperature(temperatureMeasurement); weatherApiResult.ConvertWindSpeed(windSpeedMeasurement); } return new WeatherApiResult { Location = weatherApiResults.First().Location, TemperatureUnit = temperatureMeasurement, WindSpeedUnit = windSpeedMeasurement, WindSpeed = weatherApiResults.Average(o => o.WindSpeed), Temperature = weatherApiResults.Average(o => o.Temperature) }; }
public double To(SpeedUnit unit) { return _value.ConvertTo(unit); }
protected override SpeedUnit __DoSubstraction(SpeedUnit right) { return new MeterPerSecond(ConvertToBase().Value - right.ConvertToBase().Value); }
public int Convert(int value, SpeedUnit targetUnit) { return Convert(value, rawUnit, targetUnit); }
public Speed(double metresPerSecond) { _siValue = metresPerSecond; _unit = SpeedUnit.Ms; }
public Speed ConvertTo(SpeedUnit unit) { return new Speed(_siValue.ConvertTo(unit), unit); }
public static string GetFriendlyName(SpeedUnit unit) { switch (unit) { case SpeedUnit.MetersPerSec: return "m/s"; case SpeedUnit.MilesPerHour: return "mph"; default: return unit.ToString(); } }
public static double ConvertUnit(double value, SpeedUnit from, SpeedUnit to) { if (from == to) { return value; } if (from == SpeedUnit.MetersPerSec) { return 2.23693629 * value; } return 0.44704 * value; }
public void ConvertsAllUnitsOfMeasurement(TemperatureUnit tempBefore, TemperatureUnit tempAfter, SpeedUnit speedBefore, SpeedUnit speedAfter) { WeatherApiResult resultA = TestData.GetTestWeatherResult(tempBefore, speedBefore); WeatherApiResult resultB = TestData.GetTestWeatherResult(tempBefore, speedBefore); WeatherApiResult resultc = TestData.GetTestWeatherResult(TemperatureUnit.DegreeCelsius, SpeedUnit.MilePerHour); WeatherApiResult resultd = TestData.GetTestWeatherResult(TemperatureUnit.DegreeFahrenheit, SpeedUnit.KilometerPerHour); var weatherResults = new List<WeatherApiResult>() { resultA, resultB, resultc, resultd }; var averaged = weatherResults.AverageWeatherResults(tempAfter, speedAfter); weatherResults.TrueForAll(o => o.TemperatureUnit == tempAfter && o.WindSpeedUnit == speedAfter); }
public static double ConvertTo(this double metres, SpeedUnit unit) { return metres / unit.GetConversionFactor(); }
public static double GetFactor( SpeedUnit unit ) { return unit == SpeedUnit.Kilometers ? 1 : 0.621371192; }
public static SpeedConversion ConvertFrom(this double value, SpeedUnit unit) { return new SpeedConversion(value * unit.GetConversionFactor()); }
public static int ConvertSpeedLimit( SpeedUnit oldUnit, SpeedUnit newUnit, int limit ) { double factor = GetFactor( newUnit ) / GetFactor( oldUnit ); int newLimit = (int) Math.Round( limit * factor ); return newLimit - ( newLimit % 5 ); }
public string ToString(SpeedUnit unit) { return ConvertTo(unit).ToString(); }
public static SpeedUnit Switch( SpeedUnit unit ) { return unit == SpeedUnit.Kilometers ? SpeedUnit.Miles : SpeedUnit.Kilometers; }
public Speed(double value, SpeedUnit unit) { _siValue = value.ConvertFrom(unit).To(SpeedUnit.Ms); _unit = unit; }
protected static string CreateSuffix(SymbolFormat format, SpeedUnit unit) { return default(Speed).ToString(unit, format).Trim('0'); }