change how tiles are stored

This commit is contained in:
Anton Martynenko
2025-11-19 12:17:27 +01:00
parent 7a32ed5110
commit 7f33567632
3 changed files with 32 additions and 10 deletions
@@ -27,7 +27,7 @@ public class GoogleMapsDownloaderV2
private readonly ILogger<GoogleMapsDownloaderV2> _logger;
private readonly string _apiKey;
private readonly string _tilesDirectory;
private readonly StorageConfig _storageConfig;
private readonly IHttpClientFactory _httpClientFactory;
public GoogleMapsDownloaderV2(
@@ -38,7 +38,7 @@ public class GoogleMapsDownloaderV2
{
_logger = logger;
_apiKey = mapConfig.Value.ApiKey;
_tilesDirectory = storageConfig.Value.TilesDirectory;
_storageConfig = storageConfig.Value;
_httpClientFactory = httpClientFactory;
}
@@ -98,11 +98,11 @@ public class GoogleMapsDownloaderV2
var server = 0;
var url = string.Format(TILE_URL_TEMPLATE, server, tileX, tileY, zoomLevel, sessionToken);
Directory.CreateDirectory(_tilesDirectory);
var timestamp = DateTime.UtcNow.ToString("yyyyMMddHHmmss");
var fileName = $"tile_{zoomLevel}_{tileX}_{tileY}_{timestamp}.jpg";
var filePath = Path.Combine(_tilesDirectory, fileName);
var subdirectory = _storageConfig.GetTileSubdirectoryPath(zoomLevel, tileX, tileY);
Directory.CreateDirectory(subdirectory);
var filePath = _storageConfig.GetTileFilePath(zoomLevel, tileX, tileY, timestamp);
var imageBytes = await ExecuteWithRetryAsync(async () =>
{
@@ -278,11 +278,11 @@ public class GoogleMapsDownloaderV2
var server = (x + y) % 4;
var url = string.Format(TILE_URL_TEMPLATE, server, x, y, zoomLevel, sessionToken);
Directory.CreateDirectory(_tilesDirectory);
var timestamp = DateTime.UtcNow.ToString("yyyyMMddHHmmss");
var fileName = $"tile_{zoomLevel}_{x}_{y}_{timestamp}.jpg";
var filePath = Path.Combine(_tilesDirectory, fileName);
var subdirectory = _storageConfig.GetTileSubdirectoryPath(zoomLevel, x, y);
Directory.CreateDirectory(subdirectory);
var filePath = _storageConfig.GetTileFilePath(zoomLevel, x, y, timestamp);
var imageBytes = await ExecuteWithRetryAsync(async () =>
{