mirror of
https://github.com/azaion/satellite-provider.git
synced 2026-04-22 09:16:39 +00:00
geo fences - wip
This commit is contained in:
@@ -23,9 +23,9 @@ builder.Services.Configure<MapConfig>(builder.Configuration.GetSection("MapConfi
|
||||
builder.Services.Configure<StorageConfig>(builder.Configuration.GetSection("StorageConfig"));
|
||||
builder.Services.Configure<ProcessingConfig>(builder.Configuration.GetSection("ProcessingConfig"));
|
||||
|
||||
builder.Services.AddSingleton<ITileRepository>(sp => new TileRepository(connectionString));
|
||||
builder.Services.AddSingleton<IRegionRepository>(sp => new RegionRepository(connectionString));
|
||||
builder.Services.AddSingleton<IRouteRepository>(sp => new RouteRepository(connectionString));
|
||||
builder.Services.AddSingleton<ITileRepository>(sp => new TileRepository(connectionString, sp.GetRequiredService<ILogger<TileRepository>>()));
|
||||
builder.Services.AddSingleton<IRegionRepository>(sp => new RegionRepository(connectionString, sp.GetRequiredService<ILogger<RegionRepository>>()));
|
||||
builder.Services.AddSingleton<IRouteRepository>(sp => new RouteRepository(connectionString, sp.GetRequiredService<ILogger<RouteRepository>>()));
|
||||
|
||||
builder.Services.AddHttpClient();
|
||||
builder.Services.AddSingleton<GoogleMapsDownloaderV2>();
|
||||
@@ -42,6 +42,12 @@ builder.Services.AddHostedService<RegionProcessingService>();
|
||||
builder.Services.AddSingleton<IRouteService, RouteService>();
|
||||
builder.Services.AddHostedService<RouteProcessingService>();
|
||||
|
||||
builder.Services.ConfigureHttpJsonOptions(options =>
|
||||
{
|
||||
options.SerializerOptions.PropertyNamingPolicy = System.Text.Json.JsonNamingPolicy.CamelCase;
|
||||
options.SerializerOptions.PropertyNameCaseInsensitive = true;
|
||||
});
|
||||
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Services.AddSwaggerGen(c =>
|
||||
{
|
||||
@@ -236,8 +242,35 @@ async Task<IResult> CreateRoute([FromBody] CreateRouteRequest request, IRouteSer
|
||||
{
|
||||
try
|
||||
{
|
||||
logger.LogInformation("Route creation request: ID={Id}, Name={Name}, Points={PointCount}, RegionSize={RegionSize}m, Zoom={Zoom}",
|
||||
request.Id, request.Name, request.Points.Count, request.RegionSizeMeters, request.ZoomLevel);
|
||||
logger.LogInformation("Route creation request: ID={Id}, Name={Name}, Points={PointCount}, RegionSize={RegionSize}m, Zoom={Zoom}, RequestMaps={RequestMaps}",
|
||||
request.Id, request.Name, request.Points.Count, request.RegionSizeMeters, request.ZoomLevel, request.RequestMaps);
|
||||
|
||||
if (request.Points.Count > 0)
|
||||
{
|
||||
var firstPoint = request.Points[0];
|
||||
logger.LogInformation("First point: Lat={Lat}, Lon={Lon}", firstPoint.Latitude, firstPoint.Longitude);
|
||||
}
|
||||
|
||||
if (request.Geofences != null)
|
||||
{
|
||||
logger.LogInformation("Geofences object received: Polygons count = {Count}", request.Geofences.Polygons?.Count ?? 0);
|
||||
|
||||
if (request.Geofences.Polygons != null)
|
||||
{
|
||||
for (int i = 0; i < request.Geofences.Polygons.Count; i++)
|
||||
{
|
||||
var polygon = request.Geofences.Polygons[i];
|
||||
logger.LogInformation("Geofence {Index}: NorthWest = {NW}, SouthEast = {SE}",
|
||||
i,
|
||||
polygon.NorthWest is not null ? $"({polygon.NorthWest.Lat}, {polygon.NorthWest.Lon})" : "null",
|
||||
polygon.SouthEast is not null ? $"({polygon.SouthEast.Lat}, {polygon.SouthEast.Lon})" : "null");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.LogInformation("No geofences provided (Geofences is null)");
|
||||
}
|
||||
|
||||
var route = await routeService.CreateRouteAsync(request);
|
||||
return Results.Ok(route);
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
### Create Route with Geofences
|
||||
POST http://localhost:5000/api/satellite/route
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"id": "{{$guid}}",
|
||||
"name": "Route with Geofences",
|
||||
"description": "Test route with two geofence regions",
|
||||
"regionSizeMeters": 500,
|
||||
"zoomLevel": 18,
|
||||
"requestMaps": true,
|
||||
"geofences": {
|
||||
"polygons": [
|
||||
{
|
||||
"northWest": {
|
||||
"lat": 48.28022277841604,
|
||||
"lon": 37.37548828125001
|
||||
},
|
||||
"southEast": {
|
||||
"lat": 48.2720540660028,
|
||||
"lon": 37.3901653289795
|
||||
}
|
||||
},
|
||||
{
|
||||
"northWest": {
|
||||
"lat": 48.2614270732573,
|
||||
"lon": 37.35239982604981
|
||||
},
|
||||
"southEast": {
|
||||
"lat": 48.24988342757033,
|
||||
"lon": 37.37943649291993
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"points": [
|
||||
{
|
||||
"lat": 48.276067180586544,
|
||||
"lon": 37.38445758819581
|
||||
},
|
||||
{
|
||||
"lat": 48.27074009522731,
|
||||
"lon": 37.374029159545906
|
||||
},
|
||||
{
|
||||
"lat": 48.263312668696855,
|
||||
"lon": 37.37707614898682
|
||||
},
|
||||
{
|
||||
"lat": 48.26539817051818,
|
||||
"lon": 37.36587524414063
|
||||
},
|
||||
{
|
||||
"lat": 48.25851283439989,
|
||||
"lon": 37.35952377319337
|
||||
},
|
||||
{
|
||||
"lat": 48.254426906081555,
|
||||
"lon": 37.374801635742195
|
||||
},
|
||||
{
|
||||
"lat": 48.25914140977405,
|
||||
"lon": 37.39068031311036
|
||||
},
|
||||
{
|
||||
"lat": 48.25354110233028,
|
||||
"lon": 37.401752471923835
|
||||
},
|
||||
{
|
||||
"lat": 48.25902712391726,
|
||||
"lon": 37.416257858276374
|
||||
},
|
||||
{
|
||||
"lat": 48.26828345053738,
|
||||
"lon": 37.402009963989265
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
### Create Route without Geofences (backward compatible)
|
||||
POST http://localhost:5000/api/satellite/route
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"id": "{{$guid}}",
|
||||
"name": "Simple Route",
|
||||
"description": "Route without geofences",
|
||||
"regionSizeMeters": 500,
|
||||
"zoomLevel": 18,
|
||||
"requestMaps": true,
|
||||
"points": [
|
||||
{
|
||||
"lat": 48.276067180586544,
|
||||
"lon": 37.38445758819581
|
||||
},
|
||||
{
|
||||
"lat": 48.27074009522731,
|
||||
"lon": 37.374029159545906
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user