| | | 1 | | using System.Collections.Generic; |
| | | 2 | | using System.Linq; |
| | | 3 | | using Itinero.Routing.Costs.Caches; |
| | | 4 | | |
| | | 5 | | namespace Itinero.Profiles; |
| | | 6 | | |
| | | 7 | | internal class RouterDbProfileConfiguration |
| | | 8 | | { |
| | | 9 | | private readonly Dictionary<string, (Profile profile, EdgeFactorCache cache, TurnCostFactorCache turnCostFactorCache |
| | | 10 | | |
| | 211 | 11 | | public RouterDbProfileConfiguration() |
| | 211 | 12 | | { |
| | 211 | 13 | | _profiles = new Dictionary<string, (Profile profile, EdgeFactorCache cache, TurnCostFactorCache turnCostFactorCa |
| | 211 | 14 | | } |
| | | 15 | | |
| | | 16 | | internal IEnumerable<string> GetProfileNames() |
| | 0 | 17 | | { |
| | 0 | 18 | | return _profiles.Keys.ToList(); |
| | 0 | 19 | | } |
| | | 20 | | |
| | | 21 | | internal bool HasProfile(string name) |
| | 0 | 22 | | { |
| | 0 | 23 | | return _profiles.ContainsKey(name); |
| | 0 | 24 | | } |
| | | 25 | | |
| | | 26 | | public void AddProfiles(IEnumerable<Profile> profiles) |
| | 37 | 27 | | { |
| | 185 | 28 | | foreach (var profile in profiles) |
| | 37 | 29 | | { |
| | 37 | 30 | | _profiles[profile.Name] = (profile, new EdgeFactorCache(), new TurnCostFactorCache()); |
| | 37 | 31 | | } |
| | 37 | 32 | | } |
| | | 33 | | |
| | | 34 | | internal bool TryGetProfileHandlerEdgeTypesCache(string profileName, out EdgeFactorCache? cache, out TurnCostFactorC |
| | 11487 | 35 | | { |
| | 11487 | 36 | | cache = null; |
| | 11487 | 37 | | turnCostFactorCache = null; |
| | 11487 | 38 | | if (!_profiles.TryGetValue(profileName, out var profileValue)) |
| | 69 | 39 | | { |
| | 69 | 40 | | return false; |
| | | 41 | | } |
| | | 42 | | |
| | 11418 | 43 | | cache = profileValue.cache; |
| | 11418 | 44 | | turnCostFactorCache = profileValue.turnCostFactorCache; |
| | 11418 | 45 | | return true; |
| | 11487 | 46 | | } |
| | | 47 | | |
| | 0 | 48 | | public IEnumerable<Profile> Profiles => _profiles.Values.Select(x => x.profile); |
| | | 49 | | } |