api /api/satellite/tiles/latlon

This commit is contained in:
Anton Martynenko
2025-11-19 13:12:26 +01:00
parent b66d3a0277
commit 5974b0c589
4 changed files with 35 additions and 66 deletions
+11 -18
View File
@@ -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");
}
}