route in progress, region stitching is disabled by default

This commit is contained in:
Anton Martynenko
2025-11-01 15:55:41 +01:00
parent b532f1335e
commit 8714a4817d
23 changed files with 743 additions and 18 deletions
@@ -0,0 +1,12 @@
namespace SatelliteProvider.Common.DTO;
public class CreateRouteRequest
{
public Guid Id { get; set; }
public string Name { get; set; } = string.Empty;
public string? Description { get; set; }
public double RegionSizeMeters { get; set; }
public int ZoomLevel { get; set; }
public List<RoutePoint> Points { get; set; } = new();
}
@@ -7,5 +7,6 @@ public class RegionRequest
public double Longitude { get; set; }
public double SizeMeters { get; set; }
public int ZoomLevel { get; set; }
public bool StitchTiles { get; set; }
}
@@ -0,0 +1,8 @@
namespace SatelliteProvider.Common.DTO;
public class RoutePoint
{
public double Latitude { get; set; }
public double Longitude { get; set; }
}
@@ -0,0 +1,12 @@
namespace SatelliteProvider.Common.DTO;
public class RoutePointDto
{
public double Latitude { get; set; }
public double Longitude { get; set; }
public string PointType { get; set; } = string.Empty;
public int SequenceNumber { get; set; }
public int SegmentIndex { get; set; }
public double? DistanceFromPrevious { get; set; }
}
@@ -0,0 +1,16 @@
namespace SatelliteProvider.Common.DTO;
public class RouteResponse
{
public Guid Id { get; set; }
public string Name { get; set; } = string.Empty;
public string? Description { get; set; }
public double RegionSizeMeters { get; set; }
public int ZoomLevel { get; set; }
public double TotalDistanceMeters { get; set; }
public int TotalPoints { get; set; }
public List<RoutePointDto> Points { get; set; } = new();
public DateTime CreatedAt { get; set; }
public DateTime UpdatedAt { get; set; }
}
@@ -4,7 +4,7 @@ namespace SatelliteProvider.Common.Interfaces;
public interface IRegionService
{
Task<RegionStatus> RequestRegionAsync(Guid id, double latitude, double longitude, double sizeMeters, int zoomLevel);
Task<RegionStatus> RequestRegionAsync(Guid id, double latitude, double longitude, double sizeMeters, int zoomLevel, bool stitchTiles = false);
Task<RegionStatus?> GetRegionStatusAsync(Guid id);
Task ProcessRegionAsync(Guid id, CancellationToken cancellationToken = default);
}
@@ -0,0 +1,10 @@
using SatelliteProvider.Common.DTO;
namespace SatelliteProvider.Common.Interfaces;
public interface IRouteService
{
Task<RouteResponse> CreateRouteAsync(CreateRouteRequest request);
Task<RouteResponse?> GetRouteAsync(Guid id);
}
@@ -83,4 +83,39 @@ public static class GeoUtils
return (minLat, maxLat, minLon, maxLon);
}
public static List<GeoPoint> CalculateIntermediatePoints(GeoPoint start, GeoPoint end, double maxSpacingMeters)
{
var direction = start.DirectionTo(end);
var distance = direction.Distance;
if (distance <= maxSpacingMeters)
{
return new List<GeoPoint>();
}
var numSegments = (int)Math.Ceiling(distance / maxSpacingMeters);
var actualSpacing = distance / numSegments;
var intermediatePoints = new List<GeoPoint>();
for (int i = 1; i < numSegments; i++)
{
var segmentDistance = actualSpacing * i;
var intermediateDirection = new Direction
{
Distance = segmentDistance,
Azimuth = direction.Azimuth
};
var intermediatePoint = start.GoDirection(intermediateDirection);
intermediatePoints.Add(intermediatePoint);
}
return intermediatePoints;
}
public static double CalculateDistance(GeoPoint p1, GeoPoint p2)
{
return p1.DirectionTo(p2).Distance;
}
}