Removed unnecessary factors
This commit is contained in:
parent
886ccaa8dc
commit
ec6725a5c5
@ -13,10 +13,9 @@ builder.Services.AddSwaggerGen();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
app.MapGet("/getRoute", (float latStart, float lonStart, float latEnd, float lonEnd, Tag.SpeedType vehicle, double stayOnSameRoadPriority, double useHigherLevelRoadsPriority, double useRoadsWithLessJunctionsPriority, double angleFactor) =>
|
||||
app.MapGet("/getRoute", (float latStart, float lonStart, float latEnd, float lonEnd, Tag.SpeedType vehicle, double useHigherLevelRoadsPriority, double maxTurnAngle) =>
|
||||
{
|
||||
Pathfinder result = new Pathfinder("D:/stuttgart-regbez-latest", useHigherLevelRoadsPriority, stayOnSameRoadPriority,
|
||||
useRoadsWithLessJunctionsPriority, 30).AStar(new Coordinates(latStart, lonStart),
|
||||
Pathfinder result = new Pathfinder("D:/stuttgart-regbez-latest", useHigherLevelRoadsPriority, maxTurnAngle).AStar(new Coordinates(latStart, lonStart),
|
||||
new Coordinates(latEnd, lonEnd), vehicle);
|
||||
return result.pathResult;
|
||||
}
|
||||
@ -24,8 +23,7 @@ app.MapGet("/getRoute", (float latStart, float lonStart, float latEnd, float lon
|
||||
|
||||
app.MapGet("/getShortestRoute", (float latStart, float lonStart, float latEnd, float lonEnd) =>
|
||||
{
|
||||
Pathfinder result = new Pathfinder("D:/stuttgart-regbez-latest", 0, 0,
|
||||
0, 30).AStar(new Coordinates(latStart, lonStart),
|
||||
Pathfinder result = new Pathfinder("D:/stuttgart-regbez-latest", 0, 30).AStar(new Coordinates(latStart, lonStart),
|
||||
new Coordinates(latEnd, lonEnd), Tag.SpeedType.any);
|
||||
return result.pathResult;
|
||||
}
|
||||
|
@ -13,25 +13,21 @@ public class Pathfinder
|
||||
public Dictionary<OsmNode, double>? gScore;
|
||||
private Dictionary<OsmNode, OsmNode>? _cameFromDict;
|
||||
private SpeedType _speedType;
|
||||
private double roadPriorityFactor, junctionFactor, sameRoadFactor, turnAngle;
|
||||
private double roadPriorityFactor, turnAngle;
|
||||
|
||||
public Pathfinder(string workingDirectory, double roadPriorityFactor, double junctionFactor, double sameRoadFactor, double turnAngle)
|
||||
public Pathfinder(string workingDirectory, double roadPriorityFactor, double turnAngle)
|
||||
{
|
||||
if (!Path.Exists(workingDirectory))
|
||||
throw new DirectoryNotFoundException(workingDirectory);
|
||||
regionManager = new(workingDirectory);
|
||||
this.roadPriorityFactor = roadPriorityFactor;
|
||||
this.junctionFactor = junctionFactor;
|
||||
this.sameRoadFactor = sameRoadFactor;
|
||||
this.turnAngle = turnAngle;
|
||||
}
|
||||
|
||||
public Pathfinder(RegionManager regionManager, double roadPriorityFactor, double junctionFactor, double sameRoadFactor, double turnAngle)
|
||||
public Pathfinder(RegionManager regionManager, double roadPriorityFactor, double turnAngle)
|
||||
{
|
||||
this.regionManager = regionManager;
|
||||
this.roadPriorityFactor = roadPriorityFactor;
|
||||
this.junctionFactor = junctionFactor;
|
||||
this.sameRoadFactor = sameRoadFactor;
|
||||
this.turnAngle = turnAngle;
|
||||
}
|
||||
|
||||
@ -154,27 +150,9 @@ public class Pathfinder
|
||||
else
|
||||
angle = nodeAngle / 180;
|
||||
}
|
||||
|
||||
TagManager curTags = regionManager.GetRegion(currentNode.coordinates)!.tagManager;
|
||||
TagManager nextTags = regionManager.GetRegion(neighborNode.coordinates)!.tagManager;
|
||||
|
||||
bool sameName = false;
|
||||
string? curName = (string?)curTags.GetTag(edge.wayId, TagType.name);
|
||||
bool sameRef = false;
|
||||
string? curRef = (string?)curTags.GetTag(edge.wayId, TagType.tagref);
|
||||
if(curName is not null)
|
||||
foreach (OsmEdge pEdge in neighborNode.edges)
|
||||
{
|
||||
if ((string?)nextTags.GetTag(pEdge.wayId, TagType.name) == curName)
|
||||
sameName = true;
|
||||
if ((string?)nextTags.GetTag(pEdge.wayId, TagType.tagref) == curRef)
|
||||
sameRef = true;
|
||||
}
|
||||
|
||||
double junctionCount = (neighborNode.edges.Count > 2 ? 0 : 1) * junctionFactor;
|
||||
double roadPriority = priority * roadPriorityFactor;
|
||||
double sameRoadName = (sameRef || sameName ? 1 : 0) * sameRoadFactor;
|
||||
return Utils.DistanceBetween(neighborNode, goalNode) / (speed * angle + 1);
|
||||
return Utils.DistanceBetween(neighborNode, goalNode) / (speed * angle + roadPriority + 1);
|
||||
}
|
||||
|
||||
public void SaveResult(string path)
|
||||
|
@ -118,25 +118,19 @@ public class Server
|
||||
|
||||
Queue<Thread> calcThreads = new();
|
||||
|
||||
for (double sameRoadPriority = 0; sameRoadPriority < 0.02; sameRoadPriority += 0.001)
|
||||
for (double roadLevelPriority = 0.02; roadLevelPriority > 0; roadLevelPriority -= 0.001)
|
||||
{
|
||||
for (double roadLevelPriority = 0.02; roadLevelPriority > 0; roadLevelPriority -= 0.001)
|
||||
for (double maxAngle = 5; maxAngle < 45; maxAngle += 5)
|
||||
{
|
||||
for (double maxAngle = 5; maxAngle < 45; maxAngle += 5)
|
||||
double priority = roadLevelPriority;
|
||||
double angle = maxAngle;
|
||||
calcThreads.Enqueue(new Thread(() =>
|
||||
{
|
||||
double priority = roadLevelPriority;
|
||||
double roadPriority = sameRoadPriority;
|
||||
double angle = maxAngle;
|
||||
calcThreads.Enqueue(new Thread(() =>
|
||||
{
|
||||
Pathfinder testresult = new Pathfinder(rm, priority, roadPriority,
|
||||
0, angle).AStar(start,
|
||||
finish, Tag.SpeedType.car);
|
||||
string fileName =
|
||||
$"angle{angle:0.000}_level{priority:0.000}_same{roadPriority:0.000}.result";
|
||||
testresult.SaveResult(Path.Join(parentFolder, fileName));
|
||||
}));
|
||||
}
|
||||
Pathfinder testresult = new Pathfinder(rm, priority, angle).AStar(start,
|
||||
finish, Tag.SpeedType.car);
|
||||
string fileName = $"angle{angle:0.000}_level{priority:0.000}.result";
|
||||
testresult.SaveResult(Path.Join(parentFolder, fileName));
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user