mirror of
https://github.com/azaion/satellite-provider.git
synced 2026-04-22 03:56:38 +00:00
change how tiles are stored
This commit is contained in:
@@ -4,5 +4,19 @@ public class StorageConfig
|
||||
{
|
||||
public string TilesDirectory { get; set; } = "/tiles";
|
||||
public string ReadyDirectory { get; set; } = "/ready";
|
||||
|
||||
public string GetTileSubdirectoryPath(int zoomLevel, int tileX, int tileY)
|
||||
{
|
||||
var xBucket = tileX / 1000;
|
||||
var yBucket = tileY / 1000;
|
||||
return Path.Combine(TilesDirectory, zoomLevel.ToString(), xBucket.ToString(), yBucket.ToString());
|
||||
}
|
||||
|
||||
public string GetTileFilePath(int zoomLevel, int tileX, int tileY, string timestamp)
|
||||
{
|
||||
var subdirectory = GetTileSubdirectoryPath(zoomLevel, tileX, tileY);
|
||||
var fileName = $"tile_{zoomLevel}_{tileX}_{tileY}_{timestamp}.jpg";
|
||||
return Path.Combine(subdirectory, fileName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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 () =>
|
||||
{
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
# TODO
|
||||
- add geo fences (2 regions)
|
||||
- add parameter to zip resulting tiles, 50 mb max
|
||||
- implement api to download tile - lat, lon and zoom level
|
||||
- implement parallel tiles fetching from google maps
|
||||
|
||||
|
||||
|
||||
# High level description
|
||||
|
||||
We need to implement a service which will have the following high level functionality:
|
||||
|
||||
Reference in New Issue
Block a user