2023-04-09 17:06:45 +02:00
|
|
|
using OSMDatastructure;
|
2023-04-06 01:29:45 +02:00
|
|
|
using OSMDatastructure.Graph;
|
2023-04-06 14:27:25 +02:00
|
|
|
using Pathfinding;
|
2023-04-06 01:29:45 +02:00
|
|
|
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
|
|
|
|
// Add services to the container.
|
|
|
|
|
|
|
|
builder.Services.AddControllers();
|
|
|
|
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
|
|
|
builder.Services.AddEndpointsApiExplorer();
|
|
|
|
builder.Services.AddSwaggerGen();
|
|
|
|
|
|
|
|
var app = builder.Build();
|
|
|
|
|
2023-04-23 15:07:26 +02:00
|
|
|
app.MapGet("/getRoute", (float latStart, float lonStart, float latEnd, float lonEnd, Tag.SpeedType vehicle, double useHigherLevelRoadsPriority, double maxTurnAngle) =>
|
2023-04-09 16:47:33 +02:00
|
|
|
{
|
2023-04-23 15:07:26 +02:00
|
|
|
Pathfinder result = new Pathfinder("D:/stuttgart-regbez-latest", useHigherLevelRoadsPriority, maxTurnAngle).AStar(new Coordinates(latStart, lonStart),
|
2023-04-23 14:06:19 +02:00
|
|
|
new Coordinates(latEnd, lonEnd), vehicle);
|
2023-04-20 19:41:40 +02:00
|
|
|
return result.pathResult;
|
2023-04-09 16:47:33 +02:00
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2023-04-11 01:04:19 +02:00
|
|
|
app.MapGet("/getShortestRoute", (float latStart, float lonStart, float latEnd, float lonEnd) =>
|
|
|
|
{
|
2023-04-23 15:07:26 +02:00
|
|
|
Pathfinder result = new Pathfinder("D:/stuttgart-regbez-latest", 0, 30).AStar(new Coordinates(latStart, lonStart),
|
2023-04-23 14:06:19 +02:00
|
|
|
new Coordinates(latEnd, lonEnd), Tag.SpeedType.any);
|
2023-04-20 19:41:40 +02:00
|
|
|
return result.pathResult;
|
2023-04-11 01:04:19 +02:00
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2023-04-06 14:33:00 +02:00
|
|
|
app.MapGet("/getClosestNode", (float lat, float lon) =>
|
|
|
|
{
|
|
|
|
RegionManager regionManager = new RegionManager("D:/stuttgart-regbez-latest");
|
2023-04-09 18:27:53 +02:00
|
|
|
return regionManager.ClosestNodeToCoordinates(new Coordinates(lat, lon), Tag.SpeedType.any);
|
2023-04-06 14:33:00 +02:00
|
|
|
});
|
|
|
|
|
2023-04-06 01:29:45 +02:00
|
|
|
// Configure the HTTP request pipeline.
|
|
|
|
if (app.Environment.IsDevelopment())
|
|
|
|
{
|
|
|
|
app.UseSwagger();
|
|
|
|
app.UseSwaggerUI();
|
|
|
|
}
|
|
|
|
|
|
|
|
app.UseHttpsRedirection();
|
|
|
|
|
|
|
|
app.UseAuthorization();
|
|
|
|
|
|
|
|
app.MapControllers();
|
|
|
|
|
2023-04-06 14:46:08 +02:00
|
|
|
app.Run();
|
|
|
|
|