public List <Trip> GetTripsWithRouteId(int routeId) { var allTrips = new List <Trip>(); foreach (var trip in this) { if (trip.RouteId == routeId) { #if TRIPFILE_DO_REMOVE_DUPLICATES StopTime thisStoptime = trip.Stops[0].StopTime, lastStoptime = trip.Stops[trip.Stops.Count - 1].StopTime; var noDuplicates = true; foreach (var strip in allTrips) { if (!strip.Stops[0].StopTime.Equals(thisStoptime) || !strip.Stops[strip.Stops.Count - 1].StopTime.Equals(lastStoptime)) { continue; } noDuplicates = false; break; } if (noDuplicates) #endif allTrips.Add(trip); } } allTrips.Sort((tripa, tripb) => tripa.Stops[0].StopTime.InSeconds() - tripb.Stops[0].StopTime.InSeconds()); return(allTrips); }
public bool Before(StopTime time) { if (time.Hour < Hour) { return(true); } if (time.Hour != Hour) { return(false); } if (time.Minute < Minute) { return(true); } if (time.Minute != Minute) { return(false); } return(time.Second < Second); }
public bool After(StopTime time) { if (time.Hour > Hour) { return(true); } if (time.Hour != Hour) { return(false); } if (time.Minute > Minute) { return(true); } if (time.Minute != Minute) { return(false); } return(time.Second > Second); }
public Utility.Vertex GetBusLocation(StopTime time) { var ctimeSeconds = time.InSeconds() - (MapUtil.IsTripDelayed(Id) ? MapUtil.DelayTable[Id] : 0); for (var a = 0; a < Stops.Count - 1; a++) { FullStop thisStop = Stops[a], nextStop = Stops[a + 1]; if (!thisStop.StopTime.After(time) || !nextStop.StopTime.Before(time)) { continue; } var progress = (double)(ctimeSeconds - thisStop.StopTime.InSeconds()) / (double)(nextStop.StopTime.InSeconds() - thisStop.StopTime.InSeconds()); for (var b = 0; b < thisStop.DirectionsToNext.Count - 1; b++) { ShapeVertex thisVertex = thisStop.DirectionsToNext[b], nextVertex = thisStop.DirectionsToNext[b + 1]; if (progress >= thisVertex.Distance && progress <= nextVertex.Distance) { return(thisVertex.VertexOnLine( nextVertex, (double)(progress - thisVertex.Distance) / (double)(nextVertex.Distance - thisVertex.Distance))); } } } return(null); }
public FullStop(Stop original, StopTime time) : base(original.Name, original.Id, original.Latitude, original.Longitude) { Pointer = original.Pointer; StopTime = time; }
public bool Equals(StopTime time) { return(time.Hour == Hour && time.Minute == Minute && time.Second == Second); }