mirror of
https://github.com/azaion/satellite-provider.git
synced 2026-06-21 09:41:15 +00:00
7c37636fdf
- Stop writing "downloaded_YYYY-MM-DD" into tiles.maps_version: new rows bind @MapsVersion to NULL via TileService.BuildTileEntity. - Retain the tiles.maps_version column (coderule.mdc forbids unprompted column drops); pre-existing rows keep their values for forensics. - Remove MapsVersion property from DownloadTileResponse (API wire shape) and TileMetadata (internal DTO); OpenAPI schema regenerates from the DTO via Swashbuckle. - Add 3 AC tests in TileServiceTests covering the captured-entity write (AC-1) and the DTO/wire-shape removal (AC-2). - Update integration-test local DTO + console output; refresh docs in common_dtos.md, services_tile_service.md, data_model.md. - Archive AZ-373 task file: todo/ -> done/. 174 unit + 5 smoke pass. Co-authored-by: Cursor <cursoragent@cursor.com>
2.9 KiB
2.9 KiB
Module: Services/TileService
Purpose
Orchestrates tile downloading and persistence. Bridges the downloader (Google Maps) with the tile repository (PostgreSQL), handling in-memory caching, entity creation, and metadata mapping. Single ownership point for all tile read/write business logic — both region-batch and single-tile API endpoints route through this service.
csproj: SatelliteProvider.Services.TileDownloader/TileService.cs
Public Interface
TileService (implements ITileService)
DownloadAndStoreTilesAsync(double lat, double lon, double sizeMeters, int zoomLevel, CancellationToken) → Task<List<TileMetadata>>:- Queries existing tiles in the region from the repository (latest per
(latitude, longitude, zoom_level, tile_size_meters)post-AZ-357) - Calls
ISatelliteDownloader.GetTilesWithMetadataAsyncwith existing tiles to skip - Creates
TileEntityfor each newly downloaded tile and inserts via repository (upsert) - Returns combined list of existing + new tile metadata
- Queries existing tiles in the region from the repository (latest per
GetTileAsync(Guid id) → Task<TileMetadata?>: single tile lookupGetTilesByRegionAsync(double lat, double lon, double sizeMeters, int zoomLevel) → Task<IEnumerable<TileMetadata>>: query tiles in a regionGetOrDownloadTileAsync(int z, int x, int y, CancellationToken) → Task<TileBytes>(AZ-310): cache → repository → downloader fallback for single Z/X/Y servingDownloadAndStoreSingleTileAsync(double latitude, double longitude, int zoomLevel, CancellationToken) → Task<TileMetadata>(AZ-311): download one tile by lat/lon, persist, return metadata
Internal Logic
- New rows write
Version = nullandMapsVersion = null(post-AZ-357 / AZ-373); theversionandmaps_versioncolumns are retained for backward compatibility with pre-existing rows MapToMetadata(TileEntity) → TileMetadata: entity-to-DTO mapping (static helper);MapsVersionis no longer projected ontoTileMetadata/DownloadTileResponseTileSizePixelssourced fromMapConfig.TileSizePixels(default 256, post-AZ-371); image type fixed at"jpg"IMemoryCachekeyed by(z, x, y)with 1h absolute / 30min sliding expiration; populated on first hit and on downloader fallback
Dependencies
ISatelliteDownloader(resolved via DI; concrete isGoogleMapsDownloaderV2)ITileRepositoryIMemoryCache(registered byAddTileDownloader())SatelliteProvider.Common.DTO— GeoPoint, TileMetadata, TileBytesSatelliteProvider.DataAccess.Models— TileEntity
Consumers
RegionService.ProcessRegionAsync— downloads and retrieves tiles for a region
Data Models
Transforms between TileEntity (persistence) and TileMetadata (DTO).
Configuration
None directly; relies on GoogleMapsDownloaderV2's configuration.
External Integrations
Indirect: Google Maps (via downloader), PostgreSQL (via repository).
Security
None.
Tests
No dedicated tests.