mirror of
https://github.com/azaion/satellite-provider.git
synced 2026-06-22 20:11:15 +00:00
[AZ-365] Refactor C12: decompose RouteService.CreateRouteAsync
Extract RouteValidator (aggregating validator), RoutePointGraphBuilder (point interpolation + sequence numbering), GeofenceGridCalculator (NW/SE region centers), and RouteResponseMapper (entity -> DTO; also used by GetRouteAsync, eliminating duplicate DTO assembly). CreateRouteAsync shrinks 184 -> 52 LOC of orchestration. RouteService.cs shrinks 295 -> 138 LOC overall. Validation aggregates all failures into a single ArgumentException (AC-2); single-violation messages preserved verbatim so existing RouteServiceTests pass unchanged. 28 new unit tests for the four helpers (112/112 unit tests, smoke green). Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
using SatelliteProvider.Common.DTO;
|
||||
using SatelliteProvider.DataAccess.Models;
|
||||
|
||||
namespace SatelliteProvider.Services.RouteManagement;
|
||||
|
||||
public class RouteResponseMapper
|
||||
{
|
||||
public RouteResponse Map(RouteEntity route, IEnumerable<RoutePointDto> points)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(route);
|
||||
ArgumentNullException.ThrowIfNull(points);
|
||||
|
||||
var pointList = points as List<RoutePointDto> ?? points.ToList();
|
||||
|
||||
return new RouteResponse
|
||||
{
|
||||
Id = route.Id,
|
||||
Name = route.Name,
|
||||
Description = route.Description,
|
||||
RegionSizeMeters = route.RegionSizeMeters,
|
||||
ZoomLevel = route.ZoomLevel,
|
||||
TotalDistanceMeters = route.TotalDistanceMeters,
|
||||
TotalPoints = route.TotalPoints,
|
||||
Points = pointList,
|
||||
RequestMaps = route.RequestMaps,
|
||||
MapsReady = route.MapsReady,
|
||||
CsvFilePath = route.CsvFilePath,
|
||||
SummaryFilePath = route.SummaryFilePath,
|
||||
StitchedImagePath = route.StitchedImagePath,
|
||||
TilesZipPath = route.TilesZipPath,
|
||||
CreatedAt = route.CreatedAt,
|
||||
UpdatedAt = route.UpdatedAt,
|
||||
};
|
||||
}
|
||||
|
||||
public RouteResponse Map(RouteEntity route, IEnumerable<RoutePointEntity> entities)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(entities);
|
||||
var pointDtos = entities.Select(p => new RoutePointDto
|
||||
{
|
||||
Latitude = p.Latitude,
|
||||
Longitude = p.Longitude,
|
||||
PointType = p.PointType,
|
||||
SequenceNumber = p.SequenceNumber,
|
||||
SegmentIndex = p.SegmentIndex,
|
||||
DistanceFromPrevious = p.DistanceFromPrevious,
|
||||
}).ToList();
|
||||
return Map(route, pointDtos);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user