diff options
| author | Ariel Costas Guerrero <ariel@costas.dev> | 2025-11-30 17:58:55 +0100 |
|---|---|---|
| committer | Ariel Costas Guerrero <ariel@costas.dev> | 2025-11-30 17:58:55 +0100 |
| commit | e7283ba10d45b42e1274cd13c3d6aabec57c85b4 (patch) | |
| tree | 3e753b79c0835a0ecd4674b97039fcd3b53275a7 /src/Costasdev.Busurbano.Backend | |
| parent | 0798325688049a87df02910ab9141c0b1c13ffcb (diff) | |
feat: add Tailwind CSS support and create ConsolidatedCirculationCard styles
- Added Tailwind CSS and its Vite plugin to the project dependencies.
- Updated Vite configuration to include Tailwind CSS plugin.
- Created a new CSS file for the Consolidated Circulation Card component with styles for various states and responsive design.
Diffstat (limited to 'src/Costasdev.Busurbano.Backend')
| -rw-r--r-- | src/Costasdev.Busurbano.Backend/Services/ShapeTraversalService.cs | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/Costasdev.Busurbano.Backend/Services/ShapeTraversalService.cs b/src/Costasdev.Busurbano.Backend/Services/ShapeTraversalService.cs index c8fbbc8..928c173 100644 --- a/src/Costasdev.Busurbano.Backend/Services/ShapeTraversalService.cs +++ b/src/Costasdev.Busurbano.Backend/Services/ShapeTraversalService.cs @@ -112,6 +112,17 @@ public class ShapeTraversalService // Find the closest point on the shape to the stop int closestPointIndex = FindClosestPointIndex(shape.Points, stopLocation); + // Calculate the total distance from the start of the shape to the stop + double totalDistanceToStop = CalculateTotalDistance(shape.Points.ToArray(), closestPointIndex); + + // If the reported distance exceeds the total distance to the stop, the bus is likely + // on a previous trip whose shape we don't have. Don't provide position information. + if (distanceMeters > totalDistanceToStop) + { + _logger.LogDebug("Distance {Distance}m exceeds total shape distance to stop {Total}m - bus likely on previous trip", distanceMeters, totalDistanceToStop); + return (null, closestPointIndex); + } + // Traverse backwards from the closest point to find the position at the given distance var (busPoint, forwardIndex) = TraverseBackwards(shape.Points.ToArray(), closestPointIndex, distanceMeters); @@ -218,6 +229,25 @@ public class ShapeTraversalService } /// <summary> + /// Calculates the total distance along the shape from the start to a given index + /// </summary> + private double CalculateTotalDistance(Epsg25829[] shapePoints, int endIndex) + { + if (endIndex <= 0 || shapePoints.Length == 0) + { + return 0; + } + + double totalDistance = 0; + for (int i = 1; i <= endIndex && i < shapePoints.Length; i++) + { + totalDistance += CalculateDistance(shapePoints[i - 1], shapePoints[i]); + } + + return totalDistance; + } + + /// <summary> /// Transforms a point from EPSG:25829 (meters) to EPSG:4326 (lat/lng) /// </summary> private Position TransformToLatLng(Epsg25829 point) |
