diff --git a/SatelliteProvider.Api/Program.cs b/SatelliteProvider.Api/Program.cs index 205336b..0232c89 100644 --- a/SatelliteProvider.Api/Program.cs +++ b/SatelliteProvider.Api/Program.cs @@ -179,7 +179,6 @@ async Task GetTileByLatLon([FromQuery] double Latitude, [FromQuery] dou TileSizeMeters = tile.TileSizeMeters, TileSizePixels = tile.TileSizePixels, ImageType = tile.ImageType, - MapsVersion = tile.MapsVersion, Version = tile.Version, FilePath = tile.FilePath, CreatedAt = tile.CreatedAt, diff --git a/SatelliteProvider.Common/DTO/DownloadTileResponse.cs b/SatelliteProvider.Common/DTO/DownloadTileResponse.cs index 8290862..448c284 100644 --- a/SatelliteProvider.Common/DTO/DownloadTileResponse.cs +++ b/SatelliteProvider.Common/DTO/DownloadTileResponse.cs @@ -9,7 +9,6 @@ public record DownloadTileResponse public double TileSizeMeters { get; set; } public int TileSizePixels { get; set; } public string ImageType { get; set; } = string.Empty; - public string? MapsVersion { get; set; } public int? Version { get; set; } public string FilePath { get; set; } = string.Empty; public DateTime CreatedAt { get; set; } diff --git a/SatelliteProvider.Common/DTO/TileMetadata.cs b/SatelliteProvider.Common/DTO/TileMetadata.cs index 7b1717a..d178ab7 100644 --- a/SatelliteProvider.Common/DTO/TileMetadata.cs +++ b/SatelliteProvider.Common/DTO/TileMetadata.cs @@ -11,7 +11,6 @@ public class TileMetadata public double TileSizeMeters { get; set; } public int TileSizePixels { get; set; } public string ImageType { get; set; } = string.Empty; - public string? MapsVersion { get; set; } public int? Version { get; set; } public string FilePath { get; set; } = string.Empty; public DateTime CreatedAt { get; set; } diff --git a/SatelliteProvider.IntegrationTests/Models.cs b/SatelliteProvider.IntegrationTests/Models.cs index 76eb726..19b3a55 100644 --- a/SatelliteProvider.IntegrationTests/Models.cs +++ b/SatelliteProvider.IntegrationTests/Models.cs @@ -9,7 +9,6 @@ public record DownloadTileResponse public double TileSizeMeters { get; set; } public int TileSizePixels { get; set; } public string ImageType { get; set; } = string.Empty; - public string? MapsVersion { get; set; } public string FilePath { get; set; } = string.Empty; public DateTime CreatedAt { get; set; } public DateTime UpdatedAt { get; set; } diff --git a/SatelliteProvider.IntegrationTests/TileTests.cs b/SatelliteProvider.IntegrationTests/TileTests.cs index 9f777cc..2fa1b43 100644 --- a/SatelliteProvider.IntegrationTests/TileTests.cs +++ b/SatelliteProvider.IntegrationTests/TileTests.cs @@ -45,7 +45,6 @@ public static class TileTests Console.WriteLine($" Tile Size (meters): {tile.TileSizeMeters:F2}"); Console.WriteLine($" Tile Size (pixels): {tile.TileSizePixels}"); Console.WriteLine($" Image Type: {tile.ImageType}"); - Console.WriteLine($" Maps Version: {tile.MapsVersion}"); Console.WriteLine($" File Path: {tile.FilePath}"); Console.WriteLine($" Created At: {tile.CreatedAt:yyyy-MM-dd HH:mm:ss}"); diff --git a/SatelliteProvider.Services.TileDownloader/TileService.cs b/SatelliteProvider.Services.TileDownloader/TileService.cs index 0d9934b..59d8525 100644 --- a/SatelliteProvider.Services.TileDownloader/TileService.cs +++ b/SatelliteProvider.Services.TileDownloader/TileService.cs @@ -154,7 +154,7 @@ public class TileService : ITileService TileSizeMeters = downloaded.TileSizeMeters, TileSizePixels = _mapConfig.TileSizePixels, ImageType = "jpg", - MapsVersion = $"downloaded_{now:yyyy-MM-dd}", + MapsVersion = null, Version = null, FilePath = downloaded.FilePath, CreatedAt = now, @@ -175,7 +175,6 @@ public class TileService : ITileService TileSizeMeters = entity.TileSizeMeters, TileSizePixels = entity.TileSizePixels, ImageType = entity.ImageType, - MapsVersion = entity.MapsVersion, Version = entity.Version, FilePath = entity.FilePath, CreatedAt = entity.CreatedAt, diff --git a/SatelliteProvider.Tests/TileServiceTests.cs b/SatelliteProvider.Tests/TileServiceTests.cs index 31c6f22..795ba15 100644 --- a/SatelliteProvider.Tests/TileServiceTests.cs +++ b/SatelliteProvider.Tests/TileServiceTests.cs @@ -207,6 +207,54 @@ public class TileServiceTests captured!.Version.Should().BeNull("AZ-357: new code never writes the deprecated year-based version"); } + [Fact] + public void BuildTileEntity_DoesNotPopulateMapsVersion_AZ373_AC1() + { + // Arrange + var downloader = new Mock(); + var tileRepo = new Mock(); + TileEntity? captured = null; + tileRepo + .Setup(r => r.InsertAsync(It.IsAny())) + .Callback(e => captured = e) + .ReturnsAsync(Guid.NewGuid()); + downloader + .Setup(d => d.DownloadSingleTileAsync(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) + .ReturnsAsync(new DownloadedTileInfoV2(1, 2, 18, 47.46, 37.65, "tiles/18/1/2.jpg", 100.0)); + + var service = BuildService(downloader, tileRepo); + + // Act + _ = service.DownloadAndStoreSingleTileAsync(47.46, 37.65, 18).GetAwaiter().GetResult(); + + // Assert + captured.Should().NotBeNull(); + captured!.MapsVersion.Should().BeNull( + "AZ-373 option (a): new code never writes a MapsVersion value; the column is retained for forensics on pre-existing rows only"); + } + + [Fact] + public void DownloadTileResponse_DoesNotExposeMapsVersion_AZ373_AC2() + { + // Act + var property = typeof(DownloadTileResponse).GetProperty("MapsVersion"); + + // Assert + property.Should().BeNull( + "AZ-373 AC-2 option (a): MapsVersion is removed from the HTTP response shape"); + } + + [Fact] + public void TileMetadata_DoesNotExposeMapsVersion_AZ373_AC1() + { + // Act + var property = typeof(TileMetadata).GetProperty("MapsVersion"); + + // Assert + property.Should().BeNull( + "AZ-373 AC-1: TileMetadata DTO no longer carries MapsVersion (consistent with the HTTP response removal)"); + } + [Fact] public async Task GetTileAsync_KnownId_ReturnsMappedMetadata() { diff --git a/_docs/02_document/data_model.md b/_docs/02_document/data_model.md index 71e51f5..b33dd85 100644 --- a/_docs/02_document/data_model.md +++ b/_docs/02_document/data_model.md @@ -96,7 +96,7 @@ Stores metadata for downloaded satellite imagery tiles. Each tile is a single im | tile_size_meters | DOUBLE PRECISION | NOT NULL | Ground coverage in meters | | tile_size_pixels | INT | NOT NULL | Image dimension in pixels | | image_type | VARCHAR(10) | NOT NULL | Image format (e.g., "jpg") | -| maps_version | VARCHAR(50) | | Google Maps version string | +| maps_version | VARCHAR(50) | | Legacy free-form provider tag; post-AZ-373 new rows write NULL (column retained for forensics on pre-existing rows) | | version | INT | NOT NULL, DEFAULT 2025 | Year-based versioning for cache invalidation | | file_path | VARCHAR(500) | NOT NULL | Relative path to stored image | | tile_x | INT | NOT NULL | Tile X coordinate (Slippy Map) | diff --git a/_docs/02_document/modules/common_dtos.md b/_docs/02_document/modules/common_dtos.md index dadb449..f61d0f7 100644 --- a/_docs/02_document/modules/common_dtos.md +++ b/_docs/02_document/modules/common_dtos.md @@ -30,7 +30,7 @@ Represents a single map tile with its spatial bounds. Metadata about a stored tile (mirrors `TileEntity` but without DB-specific concerns). - `Id` (Guid), `TileZoom`, `TileX`, `TileY` (int), `Latitude`, `Longitude` (double) - `TileSizeMeters` (double), `TileSizePixels` (int), `ImageType` (string) -- `MapsVersion` (string?), `Version` (int), `FilePath` (string) +- `Version` (int?), `FilePath` (string) - `CreatedAt`, `UpdatedAt` (DateTime) ### RegionRequest diff --git a/_docs/02_document/modules/services_tile_service.md b/_docs/02_document/modules/services_tile_service.md index 1134d2c..388e48b 100644 --- a/_docs/02_document/modules/services_tile_service.md +++ b/_docs/02_document/modules/services_tile_service.md @@ -9,7 +9,7 @@ Orchestrates tile downloading and persistence. Bridges the downloader (Google Ma ### TileService (implements ITileService) - `DownloadAndStoreTilesAsync(double lat, double lon, double sizeMeters, int zoomLevel, CancellationToken) → Task>`: - 1. Queries existing tiles in the region from the repository (filtered to current year's version) + 1. Queries existing tiles in the region from the repository (latest per `(latitude, longitude, zoom_level, tile_size_meters)` post-AZ-357) 2. Calls `ISatelliteDownloader.GetTilesWithMetadataAsync` with existing tiles to skip 3. Creates `TileEntity` for each newly downloaded tile and inserts via repository (upsert) 4. Returns combined list of existing + new tile metadata @@ -19,10 +19,9 @@ Orchestrates tile downloading and persistence. Bridges the downloader (Google Ma - `DownloadAndStoreSingleTileAsync(double latitude, double longitude, int zoomLevel, CancellationToken) → Task` (AZ-311): download one tile by lat/lon, persist, return metadata ## Internal Logic -- Version is `DateTime.UtcNow.Year` — tiles are considered fresh for the current calendar year -- `MapToMetadata(TileEntity) → TileMetadata`: entity-to-DTO mapping (static helper) -- Tile size hardcoded to 256 pixels, image type "jpg" -- `MapsVersion` formatted as `"downloaded_{date}"` +- New rows write `Version = null` and `MapsVersion = null` (post-AZ-357 / AZ-373); the `version` and `maps_version` columns are retained for backward compatibility with pre-existing rows +- `MapToMetadata(TileEntity) → TileMetadata`: entity-to-DTO mapping (static helper); `MapsVersion` is no longer projected onto `TileMetadata` / `DownloadTileResponse` +- `TileSizePixels` sourced from `MapConfig.TileSizePixels` (default 256, post-AZ-371); image type fixed at `"jpg"` - `IMemoryCache` keyed by `(z, x, y)` with 1h absolute / 30min sliding expiration; populated on first hit and on downloader fallback ## Dependencies diff --git a/_docs/02_tasks/todo/AZ-373_refactor_clarify_mapsversion.md b/_docs/02_tasks/done/AZ-373_refactor_clarify_mapsversion.md similarity index 100% rename from _docs/02_tasks/todo/AZ-373_refactor_clarify_mapsversion.md rename to _docs/02_tasks/done/AZ-373_refactor_clarify_mapsversion.md