mirror of
https://github.com/azaion/satellite-provider.git
synced 2026-04-22 09:16:39 +00:00
fix warnings
This commit is contained in:
@@ -289,6 +289,7 @@ public static class RouteTests
|
||||
Console.WriteLine("✓ Route with Region Processing and Stitching Test: PASSED");
|
||||
}
|
||||
|
||||
|
||||
public static async Task RunComplexRouteWithStitching(HttpClient httpClient)
|
||||
{
|
||||
Console.WriteLine();
|
||||
@@ -296,6 +297,227 @@ public static class RouteTests
|
||||
Console.WriteLine("======================================================================================");
|
||||
Console.WriteLine();
|
||||
|
||||
var routeId = Guid.NewGuid();
|
||||
var request = new CreateRouteRequest
|
||||
{
|
||||
Id = routeId,
|
||||
Name = "Complex Route with 10 Points + 2 Geofences",
|
||||
Description = "Test route with 10 action points and 2 geofence regions for complex map stitching",
|
||||
RegionSizeMeters = 300.0,
|
||||
ZoomLevel = 18,
|
||||
RequestMaps = true,
|
||||
Points = new List<RoutePointInput>
|
||||
{
|
||||
new() { Lat = 48.276067180586544, Lon = 37.38445758819581 },
|
||||
new() { Lat = 48.27074009522731, Lon = 37.374029159545906 },
|
||||
new() { Lat = 48.263312668696855, Lon = 37.37707614898682 },
|
||||
new() { Lat = 48.26539817051818, Lon = 37.36587524414063 },
|
||||
new() { Lat = 48.25851283439989, Lon = 37.35952377319337 },
|
||||
new() { Lat = 48.254426906081555, Lon = 37.374801635742195 },
|
||||
new() { Lat = 48.25914140977405, Lon = 37.39068031311036 },
|
||||
new() { Lat = 48.25354110233028, Lon = 37.401752471923835 },
|
||||
new() { Lat = 48.25902712391726, Lon = 37.416257858276374 },
|
||||
new() { Lat = 48.26828345053738, Lon = 37.402009963989265 }
|
||||
},
|
||||
};
|
||||
|
||||
Console.WriteLine("Step 1: Creating complex route with RequestMaps=true and 2 geofences");
|
||||
Console.WriteLine($" Action Points: {request.Points.Count}");
|
||||
Console.WriteLine($" NO Geofences Regions");
|
||||
Console.WriteLine($" Region Size: {request.RegionSizeMeters}m");
|
||||
Console.WriteLine($" Zoom Level: {request.ZoomLevel}");
|
||||
Console.WriteLine($" Request Maps: {request.RequestMaps}");
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("Route Path:");
|
||||
for (int i = 0; i < request.Points.Count; i++)
|
||||
{
|
||||
Console.WriteLine($" {i + 1}. ({request.Points[i].Lat}, {request.Points[i].Lon})");
|
||||
}
|
||||
Console.WriteLine();
|
||||
|
||||
var routeResponse = await httpClient.PostAsJsonAsync("/api/satellite/route", request, JsonWriteOptions);
|
||||
|
||||
if (!routeResponse.IsSuccessStatusCode)
|
||||
{
|
||||
var errorContent = await routeResponse.Content.ReadAsStringAsync();
|
||||
throw new Exception($"Route creation failed: {routeResponse.StatusCode} - {errorContent}");
|
||||
}
|
||||
|
||||
var route = await routeResponse.Content.ReadFromJsonAsync<RouteResponseModel>(JsonOptions);
|
||||
|
||||
if (route == null)
|
||||
{
|
||||
throw new Exception("No route data returned");
|
||||
}
|
||||
|
||||
Console.WriteLine($"✓ Route created with {route.TotalPoints} total points");
|
||||
Console.WriteLine($" Distance: {route.TotalDistanceMeters:F2}m");
|
||||
Console.WriteLine($" Request Maps: {route.RequestMaps}");
|
||||
Console.WriteLine($" Maps Ready: {route.MapsReady}");
|
||||
Console.WriteLine();
|
||||
|
||||
var startPoints = route.Points.Count(p => p.PointType == "start");
|
||||
var endPoints = route.Points.Count(p => p.PointType == "end");
|
||||
var actionPoints = route.Points.Count(p => p.PointType == "action");
|
||||
var intermediatePoints = route.Points.Count(p => p.PointType == "intermediate");
|
||||
|
||||
Console.WriteLine("Point Type Distribution:");
|
||||
Console.WriteLine($" Start: {startPoints}");
|
||||
Console.WriteLine($" Action: {actionPoints}");
|
||||
Console.WriteLine($" Intermediate: {intermediatePoints}");
|
||||
Console.WriteLine($" End: {endPoints}");
|
||||
Console.WriteLine();
|
||||
|
||||
if (startPoints != 1)
|
||||
{
|
||||
throw new Exception($"Expected 1 start point, got {startPoints}");
|
||||
}
|
||||
|
||||
if (endPoints != 1)
|
||||
{
|
||||
throw new Exception($"Expected 1 end point, got {endPoints}");
|
||||
}
|
||||
|
||||
if (actionPoints != 8)
|
||||
{
|
||||
throw new Exception($"Expected 8 action points (excluding start/end), got {actionPoints}");
|
||||
}
|
||||
|
||||
if (!route.RequestMaps)
|
||||
{
|
||||
throw new Exception("Expected RequestMaps to be true");
|
||||
}
|
||||
|
||||
if (route.MapsReady)
|
||||
{
|
||||
throw new Exception("Expected MapsReady to be false initially");
|
||||
}
|
||||
|
||||
Console.WriteLine("Step 2: Waiting for complex route maps to be ready");
|
||||
Console.WriteLine(" (Processing route point regions + 2 geofence regions SEQUENTIALLY to avoid API throttling)");
|
||||
Console.WriteLine(" (This will take several minutes as each region is processed one at a time)");
|
||||
Console.WriteLine();
|
||||
|
||||
RouteResponseModel? finalRoute = null;
|
||||
int maxAttempts = 240;
|
||||
int pollInterval = 3000;
|
||||
|
||||
for (int attempt = 0; attempt < maxAttempts; attempt++)
|
||||
{
|
||||
await Task.Delay(pollInterval);
|
||||
|
||||
var getResponse = await httpClient.GetAsync($"/api/satellite/route/{routeId}");
|
||||
|
||||
if (!getResponse.IsSuccessStatusCode)
|
||||
{
|
||||
throw new Exception($"Failed to get route status: {getResponse.StatusCode}");
|
||||
}
|
||||
|
||||
var currentRoute = await getResponse.Content.ReadFromJsonAsync<RouteResponseModel>(JsonOptions);
|
||||
|
||||
if (currentRoute == null)
|
||||
{
|
||||
throw new Exception("No route returned");
|
||||
}
|
||||
|
||||
if (currentRoute.MapsReady)
|
||||
{
|
||||
finalRoute = currentRoute;
|
||||
Console.WriteLine($"✓ Complex route maps ready in approximately {attempt * pollInterval / 1000}s");
|
||||
break;
|
||||
}
|
||||
|
||||
if (attempt % 10 == 0)
|
||||
{
|
||||
Console.WriteLine($" Waiting... (attempt {attempt + 1}/{maxAttempts})");
|
||||
}
|
||||
|
||||
if (attempt == maxAttempts - 1)
|
||||
{
|
||||
throw new Exception($"Timeout: Complex route maps did not become ready in {maxAttempts * pollInterval / 1000}s");
|
||||
}
|
||||
}
|
||||
|
||||
if (finalRoute == null)
|
||||
{
|
||||
throw new Exception("Final route is null");
|
||||
}
|
||||
|
||||
Console.WriteLine();
|
||||
|
||||
Console.WriteLine("Step 3: Verifying generated files");
|
||||
|
||||
if (string.IsNullOrEmpty(finalRoute.CsvFilePath))
|
||||
{
|
||||
throw new Exception("CSV file path is null or empty");
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(finalRoute.SummaryFilePath))
|
||||
{
|
||||
throw new Exception("Summary file path is null or empty");
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(finalRoute.StitchedImagePath))
|
||||
{
|
||||
throw new Exception("Stitched image path is null or empty");
|
||||
}
|
||||
|
||||
if (!File.Exists(finalRoute.CsvFilePath))
|
||||
{
|
||||
throw new Exception($"CSV file not found: {finalRoute.CsvFilePath}");
|
||||
}
|
||||
|
||||
if (!File.Exists(finalRoute.SummaryFilePath))
|
||||
{
|
||||
throw new Exception($"Summary file not found: {finalRoute.SummaryFilePath}");
|
||||
}
|
||||
|
||||
if (!File.Exists(finalRoute.StitchedImagePath))
|
||||
{
|
||||
throw new Exception($"Stitched image not found: {finalRoute.StitchedImagePath}");
|
||||
}
|
||||
|
||||
var csvLines = await File.ReadAllLinesAsync(finalRoute.CsvFilePath);
|
||||
var uniqueTileCount = csvLines.Length - 1;
|
||||
|
||||
var stitchedInfo = new FileInfo(finalRoute.StitchedImagePath);
|
||||
|
||||
Console.WriteLine("Files Generated:");
|
||||
Console.WriteLine($" ✓ CSV: {Path.GetFileName(finalRoute.CsvFilePath)} ({uniqueTileCount} tiles)");
|
||||
Console.WriteLine($" ✓ Summary: {Path.GetFileName(finalRoute.SummaryFilePath)}");
|
||||
Console.WriteLine($" ✓ Stitched Map: {Path.GetFileName(finalRoute.StitchedImagePath)} ({stitchedInfo.Length / 1024:F2} KB)");
|
||||
Console.WriteLine();
|
||||
|
||||
Console.WriteLine("Route Summary:");
|
||||
Console.WriteLine($" Route ID: {finalRoute.Id}");
|
||||
Console.WriteLine($" Total Points: {finalRoute.TotalPoints}");
|
||||
Console.WriteLine($" Action Points: {actionPoints}");
|
||||
Console.WriteLine($" Distance: {finalRoute.TotalDistanceMeters:F2}m");
|
||||
Console.WriteLine($" Geofence Regions: 2");
|
||||
Console.WriteLine($" Unique Tiles: {uniqueTileCount}");
|
||||
Console.WriteLine($" Maps Ready: {finalRoute.MapsReady}");
|
||||
Console.WriteLine();
|
||||
|
||||
if (uniqueTileCount < 10)
|
||||
{
|
||||
throw new Exception($"Expected at least 10 unique tiles for complex route with geofences, got {uniqueTileCount}");
|
||||
}
|
||||
|
||||
if (stitchedInfo.Length < 1024)
|
||||
{
|
||||
throw new Exception($"Stitched image seems too small: {stitchedInfo.Length} bytes");
|
||||
}
|
||||
|
||||
Console.WriteLine("✓ Complex Route with 10 Points + 2 Geofences Test: PASSED");
|
||||
}
|
||||
|
||||
public static async Task RunComplexRouteWithStitchingAndGeofences(HttpClient httpClient)
|
||||
{
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("Test: Complex Route with 10 Points + 2 Geofences - Region Processing and Stitching");
|
||||
Console.WriteLine("======================================================================================");
|
||||
Console.WriteLine();
|
||||
|
||||
var routeId = Guid.NewGuid();
|
||||
var request = new CreateRouteRequest
|
||||
{
|
||||
@@ -347,7 +569,7 @@ public static class RouteTests
|
||||
for (int i = 0; i < request.Geofences.Polygons.Count; i++)
|
||||
{
|
||||
var polygon = request.Geofences.Polygons[i];
|
||||
Console.WriteLine($" {i + 1}. NW: ({polygon.NorthWest.Lat}, {polygon.NorthWest.Lon}) -> SE: ({polygon.SouthEast.Lat}, {polygon.SouthEast.Lon})");
|
||||
Console.WriteLine($" {i + 1}. NW: ({polygon.NorthWest?.Lat}, {polygon.NorthWest?.Lon}) -> SE: ({polygon.SouthEast?.Lat}, {polygon.SouthEast?.Lon})");
|
||||
}
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("Route Path:");
|
||||
|
||||
Reference in New Issue
Block a user