mirror of
https://github.com/azaion/satellite-provider.git
synced 2026-04-22 09:26:39 +00:00
api /api/satellite/tiles/latlon
This commit is contained in:
@@ -1,12 +1,5 @@
|
||||
namespace SatelliteProvider.IntegrationTests;
|
||||
|
||||
public record DownloadTileRequest
|
||||
{
|
||||
public double Latitude { get; set; }
|
||||
public double Longitude { get; set; }
|
||||
public int ZoomLevel { get; set; }
|
||||
}
|
||||
|
||||
public record DownloadTileResponse
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
|
||||
@@ -24,7 +24,7 @@ class Program
|
||||
Console.WriteLine("✓ API is ready");
|
||||
Console.WriteLine();
|
||||
|
||||
await TileTests.RunSingleTileDownloadTest(httpClient);
|
||||
await TileTests.RunGetTileByLatLonTest(httpClient);
|
||||
|
||||
await RegionTests.RunRegionProcessingTest_200m_Zoom18(httpClient);
|
||||
|
||||
|
||||
@@ -10,25 +10,18 @@ public static class TileTests
|
||||
PropertyNameCaseInsensitive = true
|
||||
};
|
||||
|
||||
public static async Task RunSingleTileDownloadTest(HttpClient httpClient)
|
||||
public static async Task RunGetTileByLatLonTest(HttpClient httpClient)
|
||||
{
|
||||
Console.WriteLine("Test: Download Single Tile at Coordinates 47.461747, 37.647063");
|
||||
Console.WriteLine("Test: Get Tile by Lat/Lon at Coordinates 47.461747, 37.647063");
|
||||
Console.WriteLine("------------------------------------------------------------------");
|
||||
|
||||
const double latitude = 47.461747;
|
||||
const double longitude = 37.647063;
|
||||
const int zoomLevel = 18;
|
||||
|
||||
Console.WriteLine($"Downloading tile at coordinates ({latitude}, {longitude}) with zoom level {zoomLevel}");
|
||||
Console.WriteLine($"Getting tile at coordinates ({latitude}, {longitude}) with zoom level {zoomLevel}");
|
||||
|
||||
var request = new DownloadTileRequest
|
||||
{
|
||||
Latitude = latitude,
|
||||
Longitude = longitude,
|
||||
ZoomLevel = zoomLevel
|
||||
};
|
||||
|
||||
var response = await httpClient.PostAsJsonAsync("/api/satellite/tiles/download", request);
|
||||
var response = await httpClient.GetAsync($"/api/satellite/tiles/latlon?Latitude={latitude}&Longitude={longitude}&ZoomLevel={zoomLevel}");
|
||||
|
||||
if (!response.IsSuccessStatusCode)
|
||||
{
|
||||
@@ -77,30 +70,30 @@ public static class TileTests
|
||||
}
|
||||
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("✓ Tile downloaded successfully");
|
||||
Console.WriteLine("✓ Tile retrieved successfully");
|
||||
Console.WriteLine("✓ Tile metadata validated");
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("Testing tile reuse (downloading same tile again)...");
|
||||
Console.WriteLine("Testing tile reuse (getting same tile again)...");
|
||||
|
||||
var response2 = await httpClient.PostAsJsonAsync("/api/satellite/tiles/download", request);
|
||||
var response2 = await httpClient.GetAsync($"/api/satellite/tiles/latlon?Latitude={latitude}&Longitude={longitude}&ZoomLevel={zoomLevel}");
|
||||
|
||||
if (!response2.IsSuccessStatusCode)
|
||||
{
|
||||
var errorContent = await response2.Content.ReadAsStringAsync();
|
||||
throw new Exception($"Second download failed with status {response2.StatusCode}: {errorContent}");
|
||||
throw new Exception($"Second request failed with status {response2.StatusCode}: {errorContent}");
|
||||
}
|
||||
|
||||
var tile2 = await response2.Content.ReadFromJsonAsync<DownloadTileResponse>(JsonOptions);
|
||||
|
||||
if (tile2 == null)
|
||||
{
|
||||
throw new Exception("No tile data returned from second download");
|
||||
throw new Exception("No tile data returned from second request");
|
||||
}
|
||||
|
||||
Console.WriteLine($"✓ Second download returned tile ID: {tile2.Id}");
|
||||
Console.WriteLine($"✓ Second request returned tile ID: {tile2.Id}");
|
||||
Console.WriteLine("✓ Tile reuse functionality working");
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("Single Tile Download Test: PASSED");
|
||||
Console.WriteLine("Get Tile by Lat/Lon Test: PASSED");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user