public static string ToString(double value, Length.Units units) { return(Length.ToString(Length.Convert( value, Length.Units.Meter, units), units, "N" + Length.DefaultDecimalPrecision(units))); }
private Length.Units MinorLengthUnit(Length.Units unit) { if (IsMetric(unit)) { return(Length.Units.Meter); } else { return(Length.Units.Yard); } }
public static Length.Units MajorLengthUnit(Length.Units unit) { if (IsMetric(unit)) { return(Length.Units.Kilometer); } else { return(Length.Units.Mile); } }
public static string GetPaceUnitLabelForActivity(IActivity activity) { Length.Units du = PluginMain.GetApplication().SystemPreferences.DistanceUnits; if (activity != null) { du = activity.Category.DistanceUnits; } // TODO: Migration to ST3 - Localize speed String //string paceUnitLabel = CommonResources.Text.LabelMinPerKm; string paceUnitLabel = "km/hr"; if (!IsMetric(du)) { //paceUnitLabel = CommonResources.Text.LabelMinPerMile; paceUnitLabel = "min/mile"; } return(paceUnitLabel); }
public static bool IsStatute(Length.Units unit) { return(!IsMetric(unit)); }
public static bool IsMetric(Length.Units unit) { return((int)unit <= (int)Length.Units.Kilometer); }
public UnitDecorator(string value, Length.Units unitsToConvertTo) { this.value = value; this.unitsToConvertTo = unitsToConvertTo; }
public static double SetLength(double value, Length.Units du) { return((float)Length.Convert(value, du, Length.Units.Meter)); }
public RecordCategory(string name, RecordType type, List <string> refIds, float distance, Length.Units units) { this.name = name; this.type = type; this.categories = refIds; this.Distance = distance; this.LengthMeasure = units; this.id = Guid.NewGuid(); }
public LengthVector2(Vector2 v, Length.Units unit) : this(new Length((decimal)v.X, unit), new Length((decimal)v.Y, unit)) { }
public LengthVector2(float x, float y, Length.Units unit) : this(new Length((decimal)x, unit), new Length((decimal)y, unit)) { }
public Vector2 ToVector2(Length.Units unit) => new Vector2((float)X[unit], (float)Y[unit]);
public static string DistanceToString(double value, string fmt) { Length.Units units = PluginMain.GetApplication().SystemPreferences.DistanceUnits; return(LengthToString(value, units, fmt)); }
public static float ParseElevation(string p) { Length.Units unit = PluginMain.GetApplication().SystemPreferences.ElevationUnits; return((float)Length.ParseDistanceMeters(p, ref unit)); }
/// <summary> /// Sets up the chart axes. Does things such as setting up the proper labels and formats based on the currently selected data. /// </summary> private void SetupAxes() { // X axis switch (XAxisReferential) { case XAxisValue.Distance: { if (PluginMain.GetApplication() != null) { Length.Units distanceUnit = PluginMain.GetApplication().SystemPreferences.DistanceUnits; if (Activity != null && Activity.Category != null) { distanceUnit = Activity.Category.DistanceUnits; } MainChart.XAxis.Formatter = new Formatter.General(); MainChart.XAxis.Label = CommonResources.Text.LabelDistance + " (" + Length.Label(distanceUnit) + ")"; } break; } case XAxisValue.Time: { MainChart.XAxis.Formatter = new Formatter.SecondsToTime(); MainChart.XAxis.Label = CommonResources.Text.LabelTime; break; } case XAxisValue.Grade: { MainChart.XAxis.Formatter = new Formatter.Percent(); MainChart.XAxis.Label = CommonResources.Text.LabelGrade + " (%)"; break; } default: { Debug.Assert(false); break; } } // Y axis MainChart.YAxis.Formatter = new Formatter.General(); switch (YAxisReferential) { case LineChartTypes.Cadence: { MainChart.YAxis.Label = CommonResources.Text.LabelCadence + " (" + CommonResources.Text.LabelRPM + ")"; break; } case LineChartTypes.Grade: { MainChart.YAxis.Formatter = new Formatter.Percent(); MainChart.YAxis.Label = CommonResources.Text.LabelGrade + " (%)"; break; } case LineChartTypes.Elevation: { if (PluginMain.GetApplication() != null) { Length.Units elevationUnit = PluginMain.GetApplication().SystemPreferences.ElevationUnits; if (Activity != null) { elevationUnit = Activity.Category.ElevationUnits; } MainChart.YAxis.Label = CommonResources.Text.LabelElevation + " (" + Length.Label(elevationUnit) + ")"; } break; } case LineChartTypes.HeartRateBPM: { MainChart.YAxis.Label = CommonResources.Text.LabelHeartRate + " (" + CommonResources.Text.LabelBPM + ")"; break; } case LineChartTypes.HeartRatePercentMax: { MainChart.YAxis.Label = CommonResources.Text.LabelHeartRate + " (" + CommonResources.Text.LabelPercentOfMax + ")"; break; } case LineChartTypes.Power: { MainChart.YAxis.Label = CommonResources.Text.LabelPower + " (" + CommonResources.Text.LabelWatts + ")"; break; } case LineChartTypes.Speed: { MainChart.YAxis.Label = CommonResources.Text.LabelSpeed + " (" + Utils.Units.GetSpeedUnitLabelForActivity(Activity) + ")"; break; } //case LineChartTypes.Pace: // { // MainChart.YAxis.Formatter = new Formatter.SecondsToTime(); // MainChart.YAxis.Label = CommonResources.Text.LabelPace + " (" + // Utils.Units.GetPaceUnitLabelForActivity(Activity) + ")"; // break; // } default: { Debug.Assert(false); break; } } }
private bool IsMetric(Length.Units unit) { return((int)unit <= (int)Length.Units.Kilometer); }
private void SetupYAxisFromType(IAxis yAxis, LineChartTypes chartType) { IAxisFormatter yAxisFormatter = new Formatter.General(); yAxis.Label = GetYAxisLabel(chartType, Activity); switch (chartType) { case LineChartTypes.Cadence: { break; } case LineChartTypes.Elevation: { if (PluginMain.GetApplication() != null) { Length.Units elevationUnit = PluginMain.GetApplication().SystemPreferences.ElevationUnits; if (Activity != null) { elevationUnit = Activity.Category.ElevationUnits; } } break; } case LineChartTypes.Grade: { ((Formatter.General)yAxisFormatter).MinPrecision = 1; break; } case LineChartTypes.HeartRateBPM: { break; } case LineChartTypes.HeartRatePercentMax: { yAxisFormatter = new Formatter.Percent(); break; } case LineChartTypes.Power: { break; } case LineChartTypes.Speed: { if (Activity != null && Activity.Category.SpeedUnits == Speed.Units.Pace) { yAxisFormatter = new Formatter.SecondsToTime(); } else { ((Formatter.General)yAxisFormatter).MinPrecision = 2; } break; } default: { Debug.Assert(false); break; } } yAxis.Formatter = yAxisFormatter; }
/// <summary> /// Convert a track data from meters to (toUnits) /// </summary> /// <param name="track">Input track</param> /// <param name="toUnits">Desired units</param> /// <returns>Converted track</returns> public static INumericTimeDataSeries ConvertDistanceUnits(INumericTimeDataSeries track, Length.Units toUnits) { INumericTimeDataSeries result = new NumericTimeDataSeries(track); foreach (TimeValueEntry <float> item in result) { // Convert to proper distance units from m/s item.Value = (float)Length.Convert(item.Value, Length.Units.Meter, toUnits) * Common.SecondsPerHour; } return(result); }