temp
This commit is contained in:
@@ -42,7 +42,28 @@ func (t *Trip) AddStopTime(stopTime *StopTime) {
|
||||
if t.Stops == nil {
|
||||
t.Stops = make([]*StopTime, 0)
|
||||
}
|
||||
t.Stops = append(t.Stops, stopTime)
|
||||
// Find the index to insert based on StopSequence
|
||||
idx := 0
|
||||
for i, st := range t.Stops {
|
||||
if stopTime.StopSequence < st.StopSequence {
|
||||
idx = i
|
||||
break
|
||||
}
|
||||
idx = i + 1
|
||||
}
|
||||
// Insert at the correct position
|
||||
t.Stops = append(t.Stops[:idx], append([]*StopTime{stopTime}, t.Stops[idx:]...)...)
|
||||
// Adjust times if necessary for next-day continuation
|
||||
for i := idx; i < len(t.Stops)-1; i++ {
|
||||
curr := t.Stops[i]
|
||||
next := t.Stops[i+1]
|
||||
if next.ArrivalTime < curr.ArrivalTime {
|
||||
next.ArrivalTime += 86400
|
||||
}
|
||||
if next.DepartureTime < curr.DepartureTime {
|
||||
next.DepartureTime += 86400
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (t *Trip) Has(stop *Stop) (*StopTime, bool) {
|
||||
|
||||
Reference in New Issue
Block a user