better geo fences and points on the map

This commit is contained in:
Anton Martynenko
2025-11-19 17:59:52 +01:00
parent a148df1697
commit eff7ca4dba
5 changed files with 135 additions and 53 deletions
+8 -6
View File
@@ -166,8 +166,10 @@ public class RouteService : IRouteService
_logger.LogInformation("Route {RouteId}: Processing {GeofenceCount} geofence polygons",
request.Id, request.Geofences.Polygons.Count);
foreach (var polygon in request.Geofences.Polygons)
for (int polygonIndex = 0; polygonIndex < request.Geofences.Polygons.Count; polygonIndex++)
{
var polygon = request.Geofences.Polygons[polygonIndex];
if (polygon.NorthWest is null || polygon.SouthEast is null)
{
throw new ArgumentException("Geofence polygon coordinates are required");
@@ -194,15 +196,15 @@ public class RouteService : IRouteService
var geofenceRegions = CreateGeofenceRegionGrid(polygon.NorthWest, polygon.SouthEast, request.RegionSizeMeters);
_logger.LogInformation("Route {RouteId}: Created grid of {Count} regions to cover geofence area",
request.Id, geofenceRegions.Count);
_logger.LogInformation("Route {RouteId}: Polygon {PolygonIndex} - Created grid of {Count} regions to cover geofence area",
request.Id, polygonIndex, geofenceRegions.Count);
foreach (var geofencePoint in geofenceRegions)
{
var geofenceRegionId = Guid.NewGuid();
_logger.LogInformation("Route {RouteId}: Requesting geofence region {RegionId} at ({Lat}, {Lon}) with size {Size}m",
request.Id, geofenceRegionId, geofencePoint.Lat, geofencePoint.Lon, request.RegionSizeMeters);
_logger.LogInformation("Route {RouteId}: Polygon {PolygonIndex} - Requesting geofence region {RegionId} at ({Lat}, {Lon}) with size {Size}m",
request.Id, polygonIndex, geofenceRegionId, geofencePoint.Lat, geofencePoint.Lon, request.RegionSizeMeters);
await _regionService.RequestRegionAsync(
geofenceRegionId,
@@ -212,7 +214,7 @@ public class RouteService : IRouteService
request.ZoomLevel,
stitchTiles: false);
await _routeRepository.LinkRouteToRegionAsync(request.Id, geofenceRegionId, isGeofence: true);
await _routeRepository.LinkRouteToRegionAsync(request.Id, geofenceRegionId, isGeofence: true, geofencePolygonIndex: polygonIndex);
}
}
}