2024-07-23 19:10:29 +02:00
|
|
|
|
using OSM_Graph.Enums;
|
2024-07-23 02:56:18 +02:00
|
|
|
|
|
|
|
|
|
namespace astar.PathingHelper;
|
|
|
|
|
|
|
|
|
|
internal static class SpeedHelper
|
|
|
|
|
{
|
2024-07-23 16:42:03 +02:00
|
|
|
|
public static byte GetSpeed(OSM_Graph.Way way, bool car = true)
|
2024-07-23 02:56:18 +02:00
|
|
|
|
{
|
2024-07-23 16:42:03 +02:00
|
|
|
|
byte maxspeed = way.GetMaxSpeed();
|
|
|
|
|
if (maxspeed != 0)
|
2024-07-25 02:23:03 +02:00
|
|
|
|
return (byte)(maxspeed * 0.85);
|
2024-07-23 16:42:03 +02:00
|
|
|
|
HighwayType highwayType = way.GetHighwayType();
|
|
|
|
|
return car ? SpeedCar[highwayType] : SpeedPedestrian[highwayType];
|
2024-07-23 04:24:35 +02:00
|
|
|
|
}
|
|
|
|
|
|
2024-07-25 02:22:41 +02:00
|
|
|
|
public static byte GetTheoreticalMaxSpeed(bool car = true)
|
2024-07-23 04:24:35 +02:00
|
|
|
|
{
|
|
|
|
|
return car ? SpeedCar.MaxBy(s => s.Value).Value : SpeedPedestrian.MaxBy(s => s.Value).Value;
|
2024-07-23 02:56:18 +02:00
|
|
|
|
}
|
|
|
|
|
|
2024-07-29 01:30:27 +02:00
|
|
|
|
private static readonly Dictionary<HighwayType, byte> SpeedPedestrian = new() {
|
2024-07-23 02:56:18 +02:00
|
|
|
|
{ HighwayType.NONE, 0 },
|
|
|
|
|
{ HighwayType.motorway, 0 },
|
|
|
|
|
{ HighwayType.trunk, 0 },
|
|
|
|
|
{ HighwayType.primary, 0 },
|
|
|
|
|
{ HighwayType.secondary, 0 },
|
|
|
|
|
{ HighwayType.tertiary, 0 },
|
|
|
|
|
{ HighwayType.unclassified, 1 },
|
|
|
|
|
{ HighwayType.residential, 3 },
|
|
|
|
|
{ HighwayType.motorway_link, 0 },
|
|
|
|
|
{ HighwayType.trunk_link, 0 },
|
|
|
|
|
{ HighwayType.primary_link, 0 },
|
|
|
|
|
{ HighwayType.secondary_link, 0 },
|
|
|
|
|
{ HighwayType.tertiary_link, 0 },
|
|
|
|
|
{ HighwayType.living_street, 5 },
|
|
|
|
|
{ HighwayType.service, 2 },
|
|
|
|
|
{ HighwayType.pedestrian, 5 },
|
|
|
|
|
{ HighwayType.track, 0 },
|
|
|
|
|
{ HighwayType.bus_guideway, 0 },
|
|
|
|
|
{ HighwayType.escape, 0 },
|
|
|
|
|
{ HighwayType.raceway, 0 },
|
|
|
|
|
{ HighwayType.road, 3 },
|
|
|
|
|
{ HighwayType.busway, 0 },
|
|
|
|
|
{ HighwayType.footway, 4 },
|
|
|
|
|
{ HighwayType.bridleway, 1 },
|
|
|
|
|
{ HighwayType.steps, 2 },
|
|
|
|
|
{ HighwayType.corridor, 3 },
|
|
|
|
|
{ HighwayType.path, 4 },
|
|
|
|
|
{ HighwayType.cycleway, 2 },
|
|
|
|
|
{ HighwayType.construction, 0 }
|
|
|
|
|
};
|
|
|
|
|
|
2024-07-29 01:30:27 +02:00
|
|
|
|
private static readonly Dictionary<HighwayType, byte> SpeedCar = new() {
|
2024-07-23 02:56:18 +02:00
|
|
|
|
{ HighwayType.NONE, 0 },
|
2024-07-25 02:24:33 +02:00
|
|
|
|
{ HighwayType.motorway, 120 },
|
2024-07-23 04:24:35 +02:00
|
|
|
|
{ HighwayType.trunk, 80 },
|
2024-07-25 02:24:33 +02:00
|
|
|
|
{ HighwayType.primary, 70 },
|
|
|
|
|
{ HighwayType.secondary, 70 },
|
2024-07-23 02:56:18 +02:00
|
|
|
|
{ HighwayType.tertiary, 70 },
|
2024-07-23 04:24:35 +02:00
|
|
|
|
{ HighwayType.unclassified, 30 },
|
2024-07-23 02:56:18 +02:00
|
|
|
|
{ HighwayType.residential, 10 },
|
2024-07-25 02:24:33 +02:00
|
|
|
|
{ HighwayType.motorway_link, 70 },
|
2024-07-23 02:56:18 +02:00
|
|
|
|
{ HighwayType.trunk_link, 50 },
|
2024-07-23 04:24:35 +02:00
|
|
|
|
{ HighwayType.primary_link, 50 },
|
2024-07-25 02:24:33 +02:00
|
|
|
|
{ HighwayType.secondary_link, 50 },
|
|
|
|
|
{ HighwayType.tertiary_link, 40 },
|
2024-07-23 04:24:35 +02:00
|
|
|
|
{ HighwayType.living_street, 5 },
|
2024-07-23 02:56:18 +02:00
|
|
|
|
{ HighwayType.service, 0 },
|
|
|
|
|
{ HighwayType.pedestrian, 0 },
|
|
|
|
|
{ HighwayType.track, 0 },
|
|
|
|
|
{ HighwayType.bus_guideway, 0 },
|
|
|
|
|
{ HighwayType.escape, 0 },
|
|
|
|
|
{ HighwayType.raceway, 0 },
|
2024-07-23 04:24:35 +02:00
|
|
|
|
{ HighwayType.road, 30 },
|
2024-07-23 02:56:18 +02:00
|
|
|
|
{ HighwayType.busway, 0 },
|
|
|
|
|
{ HighwayType.footway, 0 },
|
|
|
|
|
{ HighwayType.bridleway, 0 },
|
|
|
|
|
{ HighwayType.steps, 0 },
|
|
|
|
|
{ HighwayType.corridor, 0 },
|
|
|
|
|
{ HighwayType.path, 0 },
|
|
|
|
|
{ HighwayType.cycleway, 0 },
|
|
|
|
|
{ HighwayType.construction, 0 }
|
|
|
|
|
};
|
|
|
|
|
}
|