glax
b87d8a0300
Pathfinder now finds the result and returns itself. Pathfinder includes PathResult for later usage.
56 lines
1.7 KiB
C#
56 lines
1.7 KiB
C#
using System.Text.Json.Serialization;
|
|
using OSMDatastructure;
|
|
using OSMDatastructure.Graph;
|
|
using Pathfinding;
|
|
|
|
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();
|
|
|
|
app.MapGet("/getRoute", (float latStart, float lonStart, float latEnd, float lonEnd, Tag.SpeedType vehicle, double stayOnSameRoadPriority, double useHigherLevelRoadsPriority, double useRoadsWithLessJunctionsPriority) =>
|
|
{
|
|
Pathfinder result = new Pathfinder("D:/stuttgart-regbez-latest").AStar(new Coordinates(latStart, lonStart),
|
|
new Coordinates(latEnd, lonEnd), vehicle, useHigherLevelRoadsPriority, stayOnSameRoadPriority,
|
|
useRoadsWithLessJunctionsPriority);
|
|
return result.pathResult;
|
|
}
|
|
);
|
|
|
|
app.MapGet("/getShortestRoute", (float latStart, float lonStart, float latEnd, float lonEnd) =>
|
|
{
|
|
Pathfinder result = new Pathfinder("D:/stuttgart-regbez-latest").AStar(new Coordinates(latStart, lonStart),
|
|
new Coordinates(latEnd, lonEnd), Tag.SpeedType.any, 0, 0,
|
|
0);
|
|
return result.pathResult;
|
|
}
|
|
);
|
|
|
|
app.MapGet("/getClosestNode", (float lat, float lon) =>
|
|
{
|
|
RegionManager regionManager = new RegionManager("D:/stuttgart-regbez-latest");
|
|
return regionManager.ClosestNodeToCoordinates(new Coordinates(lat, lon), Tag.SpeedType.any);
|
|
});
|
|
|
|
// Configure the HTTP request pipeline.
|
|
if (app.Environment.IsDevelopment())
|
|
{
|
|
app.UseSwagger();
|
|
app.UseSwaggerUI();
|
|
}
|
|
|
|
app.UseHttpsRedirection();
|
|
|
|
app.UseAuthorization();
|
|
|
|
app.MapControllers();
|
|
|
|
app.Run();
|
|
|