Compare commits
No commits in common. "2cf7bf47014940fdf56e6f44701eccbb6424d431" and "ffa2e5abe9c2c7803c9b97ff8729c7f4f4ae3f1a" have entirely different histories.
2cf7bf4701
...
ffa2e5abe9
@ -30,7 +30,7 @@ namespace astar
|
||||
endNode.Value.Metric = 0f;
|
||||
|
||||
double totalDistance = NodeUtils.DistanceBetween(startNode.Value, endNode.Value);
|
||||
PriorityHelper priorityHelper = new(totalDistance, SpeedHelper.GetTheoreticalMaxSpeed(car));
|
||||
PriorityHelper priorityHelper = new(totalDistance, SpeedHelper.GetMaxSpeed(car));
|
||||
|
||||
logger?.Log(LogLevel.Information,
|
||||
"From {0:00.00000}#{1:000.00000} to {2:00.00000}#{3:000.00000} Great-Circle {4:00000.00}km",
|
||||
@ -44,27 +44,21 @@ namespace astar
|
||||
ValueTuple<Node, Node>? meetingEnds = null;
|
||||
while (toVisitStart.Count > 0 && toVisitEnd.Count > 0)
|
||||
{
|
||||
ulong closestEndNodeId = toVisitEnd.UnorderedItems
|
||||
.MinBy(n => graph.Nodes[n.Element].DistanceTo(startNode.Value)).Element;
|
||||
Node closestEndNode = graph.Nodes[closestEndNodeId];
|
||||
if (toVisitStart.Count >= toVisitEnd.Count && meetingEnds is null)
|
||||
{
|
||||
for(int i = 0; i < Math.Min(toVisitStart.Count * 0.5, 50) && meetingEnds is null; i++)
|
||||
meetingEnds = ExploreSide(true, graph, toVisitStart, rl, priorityHelper, closestEndNode, car, DefaultPriorityWeights, pathing, logger);
|
||||
for(int i = 0; i < toVisitStart.Count / 10 && meetingEnds is null; i++)
|
||||
meetingEnds = ExploreSide(true, graph, toVisitStart, rl, priorityHelper, endNode.Value, car, DefaultPriorityWeights, pathing, logger);
|
||||
}
|
||||
if(meetingEnds is null)
|
||||
meetingEnds = ExploreSide(true, graph, toVisitStart, rl, priorityHelper, closestEndNode, car, DefaultPriorityWeights, pathing, logger);
|
||||
meetingEnds = ExploreSide(true, graph, toVisitStart, rl, priorityHelper, endNode.Value, car, DefaultPriorityWeights, pathing, logger);
|
||||
|
||||
ulong closestStartNodeId = toVisitStart.UnorderedItems
|
||||
.MinBy(n => graph.Nodes[n.Element].DistanceTo(endNode.Value)).Element;
|
||||
Node closestStartNode = graph.Nodes[closestStartNodeId];
|
||||
if (toVisitEnd.Count >= toVisitStart.Count && meetingEnds is null)
|
||||
{
|
||||
for(int i = 0; i < Math.Min(toVisitEnd.Count * 0.5, 50) && meetingEnds is null; i++)
|
||||
meetingEnds = ExploreSide(false, graph, toVisitEnd, rl, priorityHelper, closestStartNode, car, DefaultPriorityWeights, pathing, logger);
|
||||
for(int i = 0; i < toVisitEnd.Count / 10 && meetingEnds is null; i++)
|
||||
meetingEnds = ExploreSide(false, graph, toVisitEnd, rl, priorityHelper, startNode.Value, car, DefaultPriorityWeights, pathing, logger);
|
||||
}
|
||||
if(meetingEnds is null)
|
||||
meetingEnds = ExploreSide(false, graph, toVisitEnd, rl, priorityHelper, closestStartNode, car, DefaultPriorityWeights, pathing, logger);
|
||||
meetingEnds = ExploreSide(false, graph, toVisitEnd, rl, priorityHelper, startNode.Value, car, DefaultPriorityWeights, pathing, logger);
|
||||
|
||||
if (meetingEnds is not null)
|
||||
break;
|
||||
|
@ -8,12 +8,12 @@ internal static class SpeedHelper
|
||||
{
|
||||
byte maxspeed = way.GetMaxSpeed();
|
||||
if (maxspeed != 0)
|
||||
return (byte)(maxspeed * 0.85);
|
||||
return maxspeed;
|
||||
HighwayType highwayType = way.GetHighwayType();
|
||||
return car ? SpeedCar[highwayType] : SpeedPedestrian[highwayType];
|
||||
}
|
||||
|
||||
public static byte GetTheoreticalMaxSpeed(bool car = true)
|
||||
public static byte GetMaxSpeed(bool car = true)
|
||||
{
|
||||
return car ? SpeedCar.MaxBy(s => s.Value).Value : SpeedPedestrian.MaxBy(s => s.Value).Value;
|
||||
}
|
||||
@ -52,18 +52,18 @@ internal static class SpeedHelper
|
||||
|
||||
private static Dictionary<HighwayType, byte> SpeedCar = new() {
|
||||
{ HighwayType.NONE, 0 },
|
||||
{ HighwayType.motorway, 120 },
|
||||
{ HighwayType.motorway, 110 },
|
||||
{ HighwayType.trunk, 80 },
|
||||
{ HighwayType.primary, 70 },
|
||||
{ HighwayType.secondary, 70 },
|
||||
{ HighwayType.primary, 80 },
|
||||
{ HighwayType.secondary, 80 },
|
||||
{ HighwayType.tertiary, 70 },
|
||||
{ HighwayType.unclassified, 30 },
|
||||
{ HighwayType.residential, 10 },
|
||||
{ HighwayType.motorway_link, 70 },
|
||||
{ HighwayType.motorway_link, 50 },
|
||||
{ HighwayType.trunk_link, 50 },
|
||||
{ HighwayType.primary_link, 50 },
|
||||
{ HighwayType.secondary_link, 50 },
|
||||
{ HighwayType.tertiary_link, 40 },
|
||||
{ HighwayType.secondary_link, 30 },
|
||||
{ HighwayType.tertiary_link, 25 },
|
||||
{ HighwayType.living_street, 5 },
|
||||
{ HighwayType.service, 0 },
|
||||
{ HighwayType.pedestrian, 0 },
|
||||
|
Loading…
Reference in New Issue
Block a user