Refactor travel segments and simplify trip options

Travel segment architecture:
- Remove departureTime/arrivalTime from TravelSegment (location-based, not date-based)
- Fix travel sections appearing after destination instead of between cities
- Fix missing travel segments when revisiting same city (consecutive grouping)
- Remove unwanted rest day at end of trip

Planning engine fixes:
- All three planners now group only consecutive games at same stadium
- Visiting A → B → A creates 3 stops with proper travel between

UI simplification:
- Remove redundant sort options (mostDriving/leastDriving, mostCities/leastCities)
- Remove unused "Find Other Sports Along Route" toggle (was dead code)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Trey t
2026-01-07 19:39:53 -06:00
parent 40a6f879e3
commit 4184af60b5
29 changed files with 140675 additions and 144310 deletions

View File

@@ -111,21 +111,30 @@ enum ItineraryBuilder {
// MARK: - Common Validators
/// Validator that ensures arrival time is before game start (with buffer).
/// Validator that ensures travel duration allows arrival before game start.
/// Used by Scenario B where selected games have fixed start times.
///
/// This checks if the travel duration is short enough that the user could
/// theoretically leave after the previous game and arrive before the next.
///
/// - Parameter bufferSeconds: Time buffer before game start (default 1 hour)
/// - Returns: Validator closure
///
static func arrivalBeforeGameStart(bufferSeconds: TimeInterval = 3600) -> SegmentValidator {
return { segment, _, toStop in
return { segment, fromStop, toStop in
guard let gameStart = toStop.firstGameStart else {
return true // No game = no constraint
}
// Check if there's enough time between departure point and game start
// Departure assumed after previous day's activities (use departure date as baseline)
let earliestDeparture = fromStop.departureDate
let travelDuration = segment.durationSeconds
let earliestArrival = earliestDeparture.addingTimeInterval(travelDuration)
let deadline = gameStart.addingTimeInterval(-bufferSeconds)
if segment.arrivalTime > deadline {
print("[ItineraryBuilder] Cannot arrive in time: arrival \(segment.arrivalTime) > deadline \(deadline)")
if earliestArrival > deadline {
print("[ItineraryBuilder] Cannot arrive in time: earliest arrival \(earliestArrival) > deadline \(deadline)")
return false
}
return true