| | 1 | | using System; |
| | 2 | | using System.IO; |
| | 3 | |
|
| | 4 | | namespace Itinero.Profiles.Lua.Osm; |
| | 5 | |
|
| | 6 | | /// <summary> |
| | 7 | | /// Contains a few default embedded OSM profiles. |
| | 8 | | /// </summary> |
| | 9 | | public static class OsmProfiles |
| | 10 | | { |
| 2 | 11 | | private static readonly Lazy<Profile> LazyBicycle = new(() => LuaProfile.Load(LoadEmbeddedResource("Itinero.Profiles |
| 2 | 12 | | "Itinero.Profiles.Lua.Osm.bicycle.lua")); |
| | 13 | |
|
| | 14 | | /// <summary> |
| | 15 | | /// Gets the default bicycle profile. |
| | 16 | | /// </summary> |
| 6 | 17 | | public static Profile Bicycle { get; } = LazyBicycle.Value; |
| | 18 | |
|
| 2 | 19 | | private static readonly Lazy<Profile> LazyPedestrian = new(() => LuaProfile.Load(LoadEmbeddedResource("Itinero.Profi |
| 2 | 20 | | "Itinero.Profiles.Lua.Osm.pedestrian.lua")); |
| | 21 | |
|
| | 22 | | /// <summary> |
| | 23 | | /// Gets the default pedestrian profile. |
| | 24 | | /// </summary> |
| 1 | 25 | | public static Profile Pedestrian { get; } = LazyPedestrian.Value; |
| | 26 | |
|
| 2 | 27 | | private static readonly Lazy<Profile> LazyCar = new(() => LuaProfile.Load(LoadEmbeddedResource("Itinero.Profiles.Lua |
| 2 | 28 | | "Itinero.Profiles.Lua.Osm.car.lua")); |
| | 29 | |
|
| | 30 | | /// <summary> |
| | 31 | | /// Gets the default car profile. |
| | 32 | | /// </summary> |
| 1 | 33 | | public static Profile Car { get; } = LazyCar.Value; |
| | 34 | |
|
| 2 | 35 | | private static readonly Lazy<Profile> LazyCarShort = new(() => LuaProfile.Load(LoadEmbeddedResource("Itinero.Profile |
| 2 | 36 | | "Itinero.Profiles.Lua.Osm.car.short.lua")); |
| | 37 | |
|
| | 38 | | /// <summary> |
| | 39 | | /// Gets the car short profile. |
| | 40 | | /// </summary> |
| 1 | 41 | | public static Profile CarShort { get; } = LazyCarShort.Value; |
| | 42 | |
|
| | 43 | | /// <summary> |
| | 44 | | /// Loads a string from an embedded resource stream. |
| | 45 | | /// </summary> |
| | 46 | | private static string LoadEmbeddedResource(string name) |
| 4 | 47 | | { |
| 4 | 48 | | using var stream = typeof(LuaProfile).Assembly.GetManifestResourceStream(name); |
| 4 | 49 | | if (stream == null) throw new Exception($"Profile {name} not found."); |
| 4 | 50 | | using var streamReader = new StreamReader(stream); |
| 4 | 51 | | return streamReader.ReadToEnd(); |
| 4 | 52 | | } |
| | 53 | | } |