Version 3.0.260

This commit is contained in:
Oliver Hauff 2021-11-07 21:28:13 +01:00
parent 5a26bf273b
commit 4df8aa98aa
134 changed files with 8098 additions and 567 deletions

View file

@ -13,8 +13,8 @@ namespace TINK.Model.Connector.Filter
/// <summary> Applies filtering. </summary>
/// <param name="filter">Enumeration of filter values to filter with or null if no filtering has to be applied.</param>
/// <returns></returns>
public IEnumerable<string> DoFilter(IEnumerable<string> filter) => filter != null
? Group.Intersect(filter)
: Group;
public IEnumerable<string> DoFilter(IEnumerable<string> filter) => filter != null
? Group.IntersectByGoupId(filter)
: Group;
}
}

View file

@ -0,0 +1,43 @@
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
namespace TINK.Model.Connector.Filter
{
public static class IntersectGroupFilterHelper
{
/// <summary>
/// Transforms a group (each element consists of an operator prefix and a numeric bike category) to bike category enumeration (numeric elements).
/// </summary>
/// <param name="group">Group to transform.</param>
/// <returns>Enumeration of numeric bike categories.</returns>
public static IEnumerable<string> ToBikeCategory(this IEnumerable<string> group)
=> group?.Select(x => x.GetBikeCategory())?.Where(x => !string.IsNullOrEmpty(x))
?? new List<string>();
/// <summary>
/// Extracts bike group category umber from a group string.
/// </summary>
/// <param name="group">Group to transform. Example KN_300101 (Stadtrad located in Konstanz), FR_300102 (Lastenrad located in Freiburg).</param>
/// <returns>Enumeration of numeric bike categories.</returns>
public static string GetBikeCategory(this string group)
=> Regex.Match(group, "[0-9]+")?.Value ?? string.Empty;
/// <summary>
/// Intersects two goups only taking into accout the numeric bike group category part.
/// </summary>
/// <param name="group">Group to filter.</param>
/// <param name="filter">Filter to apply</param>
public static IEnumerable<string> IntersectByGoupId(this IEnumerable<string> group, IEnumerable<string> filter)
=> group.Where(x => filter.ContainsGroupId(x));
/// <summary>
/// Gets if group contains a filter element.
/// </summary>
/// <param name="group"></param>
/// <param name="filterElement"></param>
/// <returns></returns>
public static bool ContainsGroupId(this IEnumerable<string> group, string filterElement)
=> group.ToBikeCategory().Contains(filterElement.GetBikeCategory());
}
}

View file

@ -3,9 +3,17 @@
public static class FilterHelper
{
/// <summary> Holds the Konrad group (city bikes).</summary>
public const string FILTERKONRAD = "Konrad";
/// <remarks>
/// Was "Konrad" up to version 3.0.258.
/// Specified first: "KN300001" (RG).
/// </remarks>
public const string FILTERKONRAD = "300101";
/// <summary> Holds the tink group (Lastenräder).</summary>
public const string FILTERTINKGENERAL = "TINK";
/// <remarks>
/// Was "TINK" up to version 3.0.258.
/// Specified first: "KN300029" (RG).
/// </remarks>
public const string FILTERTINKGENERAL = "300102";
}
}

View file

@ -86,16 +86,6 @@ namespace TINK.Model.Connector
}
}
/// <summary>
/// Gets the position from StationInfo object.
/// </summary>
/// <param name="p_oBikeInfo">Object to get information from.</param>
/// <returns>Position information.</returns>
public static Station.Position GetPosition(this BikeInfoAvailable p_oBikeInfo)
{
return GetPosition(p_oBikeInfo.gps);
}
/// <summary>
/// Gets the position from StationInfo object.
/// </summary>

View file

@ -507,6 +507,8 @@ namespace TINK.Model.Connector
FeeEuroPerHour = double.TryParse(tariffDesciption?.eur_per_hour, NumberStyles.Any, CultureInfo.InvariantCulture, out double euroPerHour) ? euroPerHour : double.NaN,
AboEuroPerMonth = double.TryParse(tariffDesciption?.abo_eur_per_month, NumberStyles.Any, CultureInfo.InvariantCulture, out double aboEuroPerMonth) ? aboEuroPerMonth : double.NaN,
MaxFeeEuroPerDay = double.TryParse(tariffDesciption?.max_eur_per_day, NumberStyles.Any, CultureInfo.InvariantCulture, out double maxEuroPerDay) ? maxEuroPerDay : double.NaN,
OperatorAgb = tariffDesciption?.operator_agb,
TrackingInfo = tariffDesciption?.track_info
};
}