removed nodeAngleFactor

This commit is contained in:
glax 2023-04-23 15:00:22 +02:00
parent af1d9baf4f
commit 886ccaa8dc
3 changed files with 14 additions and 16 deletions

View File

@ -16,7 +16,7 @@ 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 stayOnSameRoadPriority, double useHigherLevelRoadsPriority, double useRoadsWithLessJunctionsPriority, double angleFactor) =>
{ {
Pathfinder result = new Pathfinder("D:/stuttgart-regbez-latest", useHigherLevelRoadsPriority, stayOnSameRoadPriority, Pathfinder result = new Pathfinder("D:/stuttgart-regbez-latest", useHigherLevelRoadsPriority, stayOnSameRoadPriority,
useRoadsWithLessJunctionsPriority, angleFactor, 30).AStar(new Coordinates(latStart, lonStart), useRoadsWithLessJunctionsPriority, 30).AStar(new Coordinates(latStart, lonStart),
new Coordinates(latEnd, lonEnd), vehicle); new Coordinates(latEnd, lonEnd), vehicle);
return result.pathResult; return result.pathResult;
} }
@ -25,7 +25,7 @@ app.MapGet("/getRoute", (float latStart, float lonStart, float latEnd, float lon
app.MapGet("/getShortestRoute", (float latStart, float lonStart, float latEnd, float lonEnd) => app.MapGet("/getShortestRoute", (float latStart, float lonStart, float latEnd, float lonEnd) =>
{ {
Pathfinder result = new Pathfinder("D:/stuttgart-regbez-latest", 0, 0, Pathfinder result = new Pathfinder("D:/stuttgart-regbez-latest", 0, 0,
0, 0, 30).AStar(new Coordinates(latStart, lonStart), 0, 30).AStar(new Coordinates(latStart, lonStart),
new Coordinates(latEnd, lonEnd), Tag.SpeedType.any); new Coordinates(latEnd, lonEnd), Tag.SpeedType.any);
return result.pathResult; return result.pathResult;
} }

View File

@ -13,9 +13,9 @@ public class Pathfinder
public Dictionary<OsmNode, double>? gScore; public Dictionary<OsmNode, double>? gScore;
private Dictionary<OsmNode, OsmNode>? _cameFromDict; private Dictionary<OsmNode, OsmNode>? _cameFromDict;
private SpeedType _speedType; private SpeedType _speedType;
private double roadPriorityFactor, junctionFactor, sameRoadFactor, nodeAngleFactor, turnAngle; private double roadPriorityFactor, junctionFactor, sameRoadFactor, turnAngle;
public Pathfinder(string workingDirectory, double roadPriorityFactor, double junctionFactor, double sameRoadFactor, double nodeAngleFactor, double turnAngle) public Pathfinder(string workingDirectory, double roadPriorityFactor, double junctionFactor, double sameRoadFactor, double turnAngle)
{ {
if (!Path.Exists(workingDirectory)) if (!Path.Exists(workingDirectory))
throw new DirectoryNotFoundException(workingDirectory); throw new DirectoryNotFoundException(workingDirectory);
@ -23,17 +23,15 @@ public class Pathfinder
this.roadPriorityFactor = roadPriorityFactor; this.roadPriorityFactor = roadPriorityFactor;
this.junctionFactor = junctionFactor; this.junctionFactor = junctionFactor;
this.sameRoadFactor = sameRoadFactor; this.sameRoadFactor = sameRoadFactor;
this.nodeAngleFactor = nodeAngleFactor;
this.turnAngle = turnAngle; this.turnAngle = turnAngle;
} }
public Pathfinder(RegionManager regionManager, double roadPriorityFactor, double junctionFactor, double sameRoadFactor, double nodeAngleFactor, double turnAngle) public Pathfinder(RegionManager regionManager, double roadPriorityFactor, double junctionFactor, double sameRoadFactor, double turnAngle)
{ {
this.regionManager = regionManager; this.regionManager = regionManager;
this.roadPriorityFactor = roadPriorityFactor; this.roadPriorityFactor = roadPriorityFactor;
this.junctionFactor = junctionFactor; this.junctionFactor = junctionFactor;
this.sameRoadFactor = sameRoadFactor; this.sameRoadFactor = sameRoadFactor;
this.nodeAngleFactor = nodeAngleFactor;
this.turnAngle = turnAngle; this.turnAngle = turnAngle;
} }

View File

@ -26,8 +26,8 @@ public class Server
Coordinates start = new (48.7933798f, 9.8275859f); Coordinates start = new (48.7933798f, 9.8275859f);
Coordinates finish = new (48.795918f, 9.021618f); Coordinates finish = new (48.795918f, 9.021618f);
//TestVariables(workingDir, start, finish, 16); TestVariables(workingDir, start, finish, 16);
//GetShortestRoute("D:"); GetShortestRoute("D:");
/* /*
ValueTuple<Image, Renderer.Bounds> area = RenderAreaBaseImage(workingDir, start, finish); ValueTuple<Image, Renderer.Bounds> area = RenderAreaBaseImage(workingDir, start, finish);
@ -41,7 +41,7 @@ public class Server
PathResult.PathresultFromFile(@"D:\angle0,160_level0,020_same0,020.result"), Image.FromFile(@"D:\Base.png"), area.Item2); PathResult.PathresultFromFile(@"D:\angle0,160_level0,020_same0,020.result"), Image.FromFile(@"D:\Base.png"), area.Item2);
areaWeight.Item1.Save(@"D:\Weight.png", ImageFormat.Png); areaWeight.Item1.Save(@"D:\Weight.png", ImageFormat.Png);
*/ */
/*
string parentFolder = new DirectoryInfo(workingDir).Parent!.FullName; string parentFolder = new DirectoryInfo(workingDir).Parent!.FullName;
Pathfinder result = new Pathfinder(workingDir, 0.002, 0, Pathfinder result = new Pathfinder(workingDir, 0.002, 0,
@ -118,22 +118,22 @@ public class Server
Queue<Thread> calcThreads = new(); Queue<Thread> calcThreads = new();
for (double sameRoadPriority = 0.02; sameRoadPriority < 0.1; sameRoadPriority += 0.02) for (double sameRoadPriority = 0; sameRoadPriority < 0.02; sameRoadPriority += 0.001)
{ {
for (double roadLevelPriority = 0.05; roadLevelPriority > 0; roadLevelPriority -= 0.002) for (double roadLevelPriority = 0.02; roadLevelPriority > 0; roadLevelPriority -= 0.001)
{ {
for (double angleWeightFactor = 0.12; angleWeightFactor < 0.17; angleWeightFactor += 0.002) for (double maxAngle = 5; maxAngle < 45; maxAngle += 5)
{ {
double priority = roadLevelPriority; double priority = roadLevelPriority;
double roadPriority = sameRoadPriority; double roadPriority = sameRoadPriority;
double factor = angleWeightFactor; double angle = maxAngle;
calcThreads.Enqueue(new Thread(() => calcThreads.Enqueue(new Thread(() =>
{ {
Pathfinder testresult = new Pathfinder(rm, priority, roadPriority, Pathfinder testresult = new Pathfinder(rm, priority, roadPriority,
0, factor, 30).AStar(start, 0, angle).AStar(start,
finish, Tag.SpeedType.car); finish, Tag.SpeedType.car);
string fileName = string fileName =
$"angle{factor:0.000}_level{priority:0.000}_same{roadPriority:0.000}.result"; $"angle{angle:0.000}_level{priority:0.000}_same{roadPriority:0.000}.result";
testresult.SaveResult(Path.Join(parentFolder, fileName)); testresult.SaveResult(Path.Join(parentFolder, fileName));
})); }));
} }