[AZ-371] Refactor C18: magic numbers to ProcessingConfig/MapConfig

Promotes 8 operational levers into config keys with defaults that match
the prior source literals byte-for-byte:
  ProcessingConfig: RegionProcessingTimeoutSeconds (300),
  RouteProcessingPollIntervalSeconds (5),
  MaxRoutePointSpacingMeters (200), LatLonTolerance (0.0001).
  MapConfig: TileSizePixels (256), AllowedZoomLevels ([15..19]),
  RetryBaseDelaySeconds (1), RetryMaxDelaySeconds (30).

Sites updated: RegionService, RouteProcessingService,
RoutePointGraphBuilder, RouteValidator, RouteService 4-arg ctor,
RouteImageRenderer, GoogleMapsDownloaderV2, TileService. Closes LF-2 by
forwarding HttpContext.RequestAborted from GetTileByLatLon into the
downloader. appsettings.json gains the 8 new keys at default values.

Tests: 141 / 141 unit + 5 / 5 smoke green. New ConfigDefaultsTests pins
defaults to original literals; new TileService unit test asserts CT
identity from caller to downloader (AZ-371 AC-3).

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Oleksandr Bezdieniezhnykh
2026-05-11 03:30:07 +03:00
parent ee42b1716b
commit 1dcd089d39
21 changed files with 404 additions and 68 deletions
@@ -1,9 +1,19 @@
using Microsoft.Extensions.Options;
using SatelliteProvider.Common.Configs;
using SatelliteProvider.Common.DTO;
namespace SatelliteProvider.Services.RouteManagement;
public class RouteValidator
{
private readonly double _latLonTolerance;
public RouteValidator(IOptions<ProcessingConfig> processingConfig)
{
ArgumentNullException.ThrowIfNull(processingConfig);
_latLonTolerance = processingConfig.Value.LatLonTolerance;
}
public void Validate(CreateRouteRequest request)
{
ArgumentNullException.ThrowIfNull(request);
@@ -39,7 +49,7 @@ public class RouteValidator
}
}
private static void ValidatePolygon(GeofencePolygon polygon, List<string> errors)
private void ValidatePolygon(GeofencePolygon polygon, List<string> errors)
{
if (polygon.NorthWest is null || polygon.SouthEast is null)
{
@@ -50,8 +60,8 @@ public class RouteValidator
var nw = polygon.NorthWest;
var se = polygon.SouthEast;
if ((Math.Abs(nw.Lat) < 0.0001 && Math.Abs(nw.Lon) < 0.0001) ||
(Math.Abs(se.Lat) < 0.0001 && Math.Abs(se.Lon) < 0.0001))
if ((Math.Abs(nw.Lat) < _latLonTolerance && Math.Abs(nw.Lon) < _latLonTolerance) ||
(Math.Abs(se.Lat) < _latLonTolerance && Math.Abs(se.Lon) < _latLonTolerance))
{
errors.Add("Geofence polygon coordinates cannot be (0,0)");
}