mirror of
https://github.com/azaion/satellite-provider.git
synced 2026-04-22 07:06:39 +00:00
route in progress, region stitching is disabled by default
This commit is contained in:
@@ -29,6 +29,7 @@ public record RequestRegionRequest
|
||||
public double Longitude { get; set; }
|
||||
public double SizeMeters { get; set; }
|
||||
public int ZoomLevel { get; set; }
|
||||
public bool StitchTiles { get; set; } = false;
|
||||
}
|
||||
|
||||
public record RegionStatusResponse
|
||||
@@ -43,3 +44,42 @@ public record RegionStatusResponse
|
||||
public DateTime UpdatedAt { get; set; }
|
||||
}
|
||||
|
||||
public class RoutePointInput
|
||||
{
|
||||
public double Latitude { get; set; }
|
||||
public double Longitude { get; set; }
|
||||
}
|
||||
|
||||
public class CreateRouteRequest
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public string? Description { get; set; }
|
||||
public double RegionSizeMeters { get; set; }
|
||||
public int ZoomLevel { get; set; }
|
||||
public List<RoutePointInput> Points { get; set; } = new();
|
||||
}
|
||||
|
||||
public class RoutePointModel
|
||||
{
|
||||
public double Latitude { get; set; }
|
||||
public double Longitude { get; set; }
|
||||
public string PointType { get; set; } = string.Empty;
|
||||
public int SequenceNumber { get; set; }
|
||||
public int SegmentIndex { get; set; }
|
||||
public double? DistanceFromPrevious { get; set; }
|
||||
}
|
||||
|
||||
public class RouteResponseModel
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public string? Description { get; set; }
|
||||
public double RegionSizeMeters { get; set; }
|
||||
public int ZoomLevel { get; set; }
|
||||
public double TotalDistanceMeters { get; set; }
|
||||
public int TotalPoints { get; set; }
|
||||
public List<RoutePointModel> Points { get; set; } = new();
|
||||
public DateTime CreatedAt { get; set; }
|
||||
public DateTime UpdatedAt { get; set; }
|
||||
}
|
||||
|
||||
@@ -32,6 +32,8 @@ class Program
|
||||
|
||||
await RegionTests.RunRegionProcessingTest_500m_Zoom18(httpClient);
|
||||
|
||||
await RouteTests.RunSimpleRouteTest(httpClient);
|
||||
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("=========================");
|
||||
Console.WriteLine("All tests completed successfully!");
|
||||
|
||||
@@ -20,8 +20,9 @@ public static class RegionTests
|
||||
const double longitude = 37.647063;
|
||||
const double sizeMeters = 200;
|
||||
const int zoomLevel = 18;
|
||||
const bool stitchTiles = false;
|
||||
|
||||
await RunRegionProcessingTest(httpClient, latitude, longitude, sizeMeters, zoomLevel);
|
||||
await RunRegionProcessingTest(httpClient, latitude, longitude, sizeMeters, zoomLevel, stitchTiles);
|
||||
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("Region Processing Test (200m, Zoom 18): PASSED");
|
||||
@@ -37,8 +38,9 @@ public static class RegionTests
|
||||
const double longitude = 37.647063;
|
||||
const double sizeMeters = 400;
|
||||
const int zoomLevel = 17;
|
||||
const bool stitchTiles = false;
|
||||
|
||||
await RunRegionProcessingTest(httpClient, latitude, longitude, sizeMeters, zoomLevel);
|
||||
await RunRegionProcessingTest(httpClient, latitude, longitude, sizeMeters, zoomLevel, stitchTiles);
|
||||
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("Region Processing Test (400m, Zoom 17): PASSED");
|
||||
@@ -47,18 +49,19 @@ public static class RegionTests
|
||||
public static async Task RunRegionProcessingTest_500m_Zoom18(HttpClient httpClient)
|
||||
{
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("Test: Region Processing 500m at Zoom 18");
|
||||
Console.WriteLine("Test: Region Processing 500m at Zoom 18 with Stitching");
|
||||
Console.WriteLine("------------------------------------------------------------------");
|
||||
|
||||
const double latitude = 47.461747;
|
||||
const double longitude = 37.647063;
|
||||
const double sizeMeters = 500;
|
||||
const int zoomLevel = 18;
|
||||
const bool stitchTiles = true;
|
||||
|
||||
await RunRegionProcessingTest(httpClient, latitude, longitude, sizeMeters, zoomLevel);
|
||||
await RunRegionProcessingTest(httpClient, latitude, longitude, sizeMeters, zoomLevel, stitchTiles);
|
||||
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("Region Processing Test (500m, Zoom 18): PASSED");
|
||||
Console.WriteLine("Region Processing Test (500m, Zoom 18 with Stitching): PASSED");
|
||||
}
|
||||
|
||||
private static async Task RunRegionProcessingTest(
|
||||
@@ -66,7 +69,8 @@ public static class RegionTests
|
||||
double latitude,
|
||||
double longitude,
|
||||
double sizeMeters,
|
||||
int zoomLevel)
|
||||
int zoomLevel,
|
||||
bool stitchTiles)
|
||||
{
|
||||
var regionId = Guid.NewGuid();
|
||||
|
||||
@@ -74,6 +78,7 @@ public static class RegionTests
|
||||
Console.WriteLine($" Coordinates: ({latitude}, {longitude})");
|
||||
Console.WriteLine($" Size: {sizeMeters}m");
|
||||
Console.WriteLine($" Zoom Level: {zoomLevel}");
|
||||
Console.WriteLine($" Stitch Tiles: {stitchTiles}");
|
||||
Console.WriteLine();
|
||||
|
||||
var requestRegion = new RequestRegionRequest
|
||||
@@ -82,7 +87,8 @@ public static class RegionTests
|
||||
Latitude = latitude,
|
||||
Longitude = longitude,
|
||||
SizeMeters = sizeMeters,
|
||||
ZoomLevel = zoomLevel
|
||||
ZoomLevel = zoomLevel,
|
||||
StitchTiles = stitchTiles
|
||||
};
|
||||
|
||||
var requestResponse = await httpClient.PostAsJsonAsync("/api/satellite/request", requestRegion);
|
||||
|
||||
@@ -0,0 +1,121 @@
|
||||
using System.Net.Http.Json;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace SatelliteProvider.IntegrationTests;
|
||||
|
||||
public static class RouteTests
|
||||
{
|
||||
private static readonly JsonSerializerOptions JsonOptions = new()
|
||||
{
|
||||
PropertyNameCaseInsensitive = true
|
||||
};
|
||||
|
||||
public static async Task RunSimpleRouteTest(HttpClient httpClient)
|
||||
{
|
||||
Console.WriteLine("Test: Create Simple Route with Two Points");
|
||||
Console.WriteLine("-----------------------------------------");
|
||||
|
||||
var routeId = Guid.NewGuid();
|
||||
var request = new CreateRouteRequest
|
||||
{
|
||||
Id = routeId,
|
||||
Name = "Simple Test Route",
|
||||
Description = "Test route with 2 points",
|
||||
RegionSizeMeters = 500.0,
|
||||
ZoomLevel = 18,
|
||||
Points = new List<RoutePointInput>
|
||||
{
|
||||
new() { Latitude = 48.276067180586544, Longitude = 37.38445758819581 },
|
||||
new() { Latitude = 48.27074009522731, Longitude = 37.374029159545906 }
|
||||
}
|
||||
};
|
||||
|
||||
Console.WriteLine($"Creating route with 2 points:");
|
||||
Console.WriteLine($" Start: ({request.Points[0].Latitude}, {request.Points[0].Longitude})");
|
||||
Console.WriteLine($" End: ({request.Points[1].Latitude}, {request.Points[1].Longitude})");
|
||||
Console.WriteLine($" Region Size: {request.RegionSizeMeters}m");
|
||||
Console.WriteLine($" Zoom Level: {request.ZoomLevel}");
|
||||
Console.WriteLine();
|
||||
|
||||
var response = await httpClient.PostAsJsonAsync("/api/satellite/route", request);
|
||||
|
||||
if (!response.IsSuccessStatusCode)
|
||||
{
|
||||
var errorContent = await response.Content.ReadAsStringAsync();
|
||||
throw new Exception($"API returned error status {response.StatusCode}: {errorContent}");
|
||||
}
|
||||
|
||||
var route = await response.Content.ReadFromJsonAsync<RouteResponseModel>(JsonOptions);
|
||||
|
||||
if (route == null)
|
||||
{
|
||||
throw new Exception("No route data returned from API");
|
||||
}
|
||||
|
||||
Console.WriteLine("Route Details:");
|
||||
Console.WriteLine($" ID: {route.Id}");
|
||||
Console.WriteLine($" Name: {route.Name}");
|
||||
Console.WriteLine($" Total Points: {route.TotalPoints}");
|
||||
Console.WriteLine($" Total Distance: {route.TotalDistanceMeters:F2}m");
|
||||
Console.WriteLine();
|
||||
|
||||
var startPoints = route.Points.Count(p => p.PointType == "start");
|
||||
var endPoints = route.Points.Count(p => p.PointType == "end");
|
||||
var intermediatePoints = route.Points.Count(p => p.PointType == "intermediate");
|
||||
|
||||
Console.WriteLine("Point Types:");
|
||||
Console.WriteLine($" Start points: {startPoints}");
|
||||
Console.WriteLine($" Intermediate points: {intermediatePoints}");
|
||||
Console.WriteLine($" End points: {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}");
|
||||
}
|
||||
|
||||
Console.WriteLine("Point spacing validation:");
|
||||
for (int i = 1; i < route.Points.Count; i++)
|
||||
{
|
||||
var point = route.Points[i];
|
||||
if (point.DistanceFromPrevious.HasValue)
|
||||
{
|
||||
if (point.DistanceFromPrevious.Value > 200.0)
|
||||
{
|
||||
throw new Exception($"Point {i} is {point.DistanceFromPrevious.Value:F2}m from previous, exceeds 200m limit");
|
||||
}
|
||||
Console.WriteLine($" Point {i} ({point.PointType}): {point.DistanceFromPrevious.Value:F2}m from previous");
|
||||
}
|
||||
}
|
||||
Console.WriteLine();
|
||||
|
||||
Console.WriteLine("Retrieving route by ID...");
|
||||
var getResponse = await httpClient.GetAsync($"/api/satellite/route/{routeId}");
|
||||
|
||||
if (!getResponse.IsSuccessStatusCode)
|
||||
{
|
||||
throw new Exception($"Failed to retrieve route: {getResponse.StatusCode}");
|
||||
}
|
||||
|
||||
var retrievedRoute = await getResponse.Content.ReadFromJsonAsync<RouteResponseModel>(JsonOptions);
|
||||
|
||||
if (retrievedRoute == null || retrievedRoute.Id != routeId)
|
||||
{
|
||||
throw new Exception("Retrieved route does not match created route");
|
||||
}
|
||||
|
||||
Console.WriteLine($"✓ Route retrieved successfully");
|
||||
Console.WriteLine($"✓ Retrieved {retrievedRoute.Points.Count} points");
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("✓ Route created successfully");
|
||||
Console.WriteLine("✓ All point spacing validated (≤ 200m)");
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("Simple Route Test: PASSED");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user