mirror of
https://github.com/azaion/satellite-provider.git
synced 2026-06-21 19:41:15 +00:00
f7ad7aa5ab
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>
51 lines
1.7 KiB
C#
51 lines
1.7 KiB
C#
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);
|
|
}
|
|
}
|